Getting Started with RESTCountries.NET
Tags: xamarinforms, nugetpackage, countrydata, netcore
Published: 2020-05-24 01:44:59

---
title: Getting Started with RESTCountries.NET
published: true
date: 2020-05-24 01:30:00 UTC
tags: xamarin-forms,nuget-package,country-data,net-core
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/1024/1*eRBPmddj7YoW-37diJITPA.png)

In this article, Let me show you my open source Nuget package [RESTCountries.NET](https://www.nuget.org/packages/RESTCountries.NET/) developed in .NET Standard.

[RESTCountries.NET](https://www.nuget.org/packages/RESTCountries.NET/) is a .NET Standard wrapper library around the API provided by REST Countries([https://restcountries.eu](https://restcountries.eu)).

[htpps://restcountries.eu](https://restcountries.eu) is a RESTful API which provides information about countries such as name , capital city , population , currencies ,borders info , languages , flag , calling codes , etc.

With **RESTCountries.NET** , we can:

- Retrieve a list of countries.
- Get a list of country names in others languages such as **_German_** , **_Spanish_** , **_French_** , **_Italian, Portuguese, Dutch, Croatian_** , **_Japanese_** , **_Breton_** , and **_Persian_** language.
- Search by country name.
- Search by capital city.
- Search by ISO 4217 currency code.
- Search by continent: Africa, Americas, Asia, Europe, Oceania.
- Search by regional bloc.
- Apply filters to retrieve what we need.
- etc.

### Setup

- The library is available on NuGet at [https://www.nuget.org/packages/RESTCountries.NET/](https://www.nuget.org/packages/RESTCountries.NET/)
- Install it into your .NET project(.NET Standard, .NET Core, Xamarin, etc).

![](https://cdn-images-1.medium.com/max/864/1*oqjo0kuxpH66pZne91RW_A.png)

### Usage

- **Add namespace**

{% gist https://gist.github.com/egbakou/dad47cb477b4104309284aeb8572a236.js %}

- **Get all countries**

{% gist https://gist.github.com/egbakou/197c509e884d71608b383bb3ae4ce611.js %}

> Each method return an object of type [_Country_](https://github.com/egbakou/RESTCountries.NET/blob/master/src/RESTCountries.NET/Models/Country.cs) or a _List_ of [_Country_](https://github.com/egbakou/RESTCountries.NET/blob/master/src/RESTCountries.NET/Models/Country.cs). You can apply filters on the returned value to retrieve what you need.

- **Get a list of country names**

{% gist https://gist.github.com/egbakou/8201eb32d05f40d4481867f8795e43f2.js %}

> Country names are in English by default.

- **Retrieve a list of country names in Spanish**

{% gist https://gist.github.com/egbakou/6ab0734f2b0cd482d5a25b5cd22e72b6.js %}

> Available languages are: de(German language), es(Spanish language), fr(French language), ja(Japanese language), it(Italian language), br(Breton language), pt(Portuguese language), nl(Dutch language), hr(Croatian language) and fa(Persian language).

- **Search by country partial name or full name**

{% gist https://gist.github.com/egbakou/5af4bde42a1e6bd744a437494f6840f0.js %}

> The first method could return a list of countries or a list of one element.

- **Search by continent: Africa, Americas, Asia, Europe, Oceania**

{% gist https://gist.github.com/egbakou/6a7b204c3da5e0fd1712ec77c0138621.js %}

> Possibles values of “continent” are **Africa, Americas, Asia, Europe and Oceania.**

For more information, check out the full documentation at [https://github.com/egbakou/RESTCountries.NET](https://github.com/egbakou/RESTCountries.NET)

### Conclusion

In web applications(.NET or .NET Core) RESTCountries.NET allows us to populate country select tag options dynamically. Populate Xamarin Picker with a list of countries become easy.