RestAPI.Countries
1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package RestAPI.Countries --version 1.0.2
NuGet\Install-Package RestAPI.Countries -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RestAPI.Countries" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RestAPI.Countries --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RestAPI.Countries, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RestAPI.Countries as a Cake Addin #addin nuget:?package=RestAPI.Countries&version=1.0.2 // Install RestAPI.Countries as a Cake Tool #tool nuget:?package=RestAPI.Countries&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Introduction
DotNetCoreRESTCountry is a nuget package which acts as a Wrapper Library For REST Country API v2.0.5 provided by https://restcountries.eu/ . REST countries API, includes information like common Name, official Name, TLD,two and three letter country code, ISO numeric code, CIOC,currencies, callingCodes, capital, alternative spellings, region, subRegion, borders, etc.
Usage
Download Nuget package either using Nuget Packekage Manager or .NET CLI
Using Nuget Package Manager Install-Package RestAPI.Countries -Version 1.0.1
Using .NET CLI dotnet add package RestAPI.Countries --version 1.0.1
Use Static methods defined in RestCountry Class to call the specific API Endpoints.
For Example RestCountry.Currency("cop")
will make the GET Request to the https://restcountries.eu/rest/v2/currency/cop
endpoint of REST Countries API.
Static methods defined in RestCountry class returns a list of Country objects. Access the properties defined in Country class to get various information about the countries.
Methods defined in RestCountry Class takes in a list of strings as optional second parameter which filters the output of your request to include only the specified fields.
Make asynchronous requests to the API using the Async version of methods defined in RestCountry Class.
RestCountry.CurrencyAsync("cop")
using DotNetRestCountries; // Reference Nuget Package
using System;
using System.Collections.Generic;
namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
// Call static methods listed in RestCountry class.
// These methods will return a List of Country Objects.
// Use properties in Country Class to access all the informations like name, capital, calling codes, etc. for a given country
// https://restcountries.eu/rest/v2/all
List<Country> allCountries = RestCountry.All();
foreach(var con in allCountries)
{
Console.WriteLine(con.Name + " -- " + con.NativeName + " -- " + con.TopLevelDomain );
}
//[FILTER RESPONSE]
// Pass an optional List of filters to obtain results with only the specified properties for countries
// This will return a List of Countries having string "island" in their name.
// Since we passed in the List of filters, the returned Country objects will only have values for Name and Capital Properties.
// https://restcountries.eu/rest/v2/name/island?fields=name;capital
List<Country> filteredResult = RestCountry.Name("island", new List<string> { Filters.Name, Filters.Capital });
Console.WriteLine(filteredResult[0].Name);
// Make asynchronous requests to the API using the Async version of methods defined in RestCountry Class.
// Makes async request to the RESTCountries endpoint https://restcountries.eu/rest/v2/capital/kathmandu
List<Country> asyncResult = RestCountry.CapitalAsync("Kathmandu");
Console.WriteLine(asyncResult[0].Name);
}
}
}
Credits
Thanks to Fayder Florez for developing REST Countries API
Related Projects
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 2.0
- Newtonsoft.Json (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.