countrylayer – The Must-Have API for Any Website
Original Source: http://feedproxy.google.com/~r/1stwebdesigner/~3/PSlPUZl9wug/
If you have ever worked on a project that deals with geographic information of any type – which, let’s face it, most websites and applications do these days – then you have likely had to come up with a solution for providing or accessing information about one if not more countries. Whether it’s population, location, currencies, languages, or any other information about a country you need, it can be challenging to find a way to dynamically bring those details into your project.
There are tools available to help you solve this problem, but all too often there are obstacles such as programming language, ease of use, complexity of integration, pricing, and other hurdles that you may encounter.
Until now.
countrylayer is a JSON API that is compatible with all programming languages, provides extensive and accurate data from almost 200 different countries, is simple and easy to integrate, and is affordable to use – starting at free!
In this article, we’re taking a look at what countrylayer has to offer and how you can start using it in your projects.
What Is countrylayer?
countrylayer is a service brought to you by apilayer that provides common information about countries via a REST API. With this API, users will be able to get detailed information about countries in the world. Because they can filter by name of a country, language, code, currency, the capital city, calling code, region, or regional bloc.
Using your project’s API key, you can access country data that is returned in a standard JSON format, which can then be easily parsed in any programming language.
Here is an example of an API response. Check out all of the information it provides:
[
{
"name": "Germany",
"topLevelDomain": [
".de"
],
"alpha2Code": "DE",
"alpha3Code": "DEU",
"callingCodes": [
"49"
],
"capital": "Berlin",
"altSpellings": [
"DE",
"Federal Republic of Germany",
"Bundesrepublik Deutschland"
],
"region": "Europe",
"subregion": "Western Europe",
"population": 81770900,
"latlng": [
51,
9
],
"demonym": "German",
"area": 357114,
"gini": 28.3,
"timezones": [
"UTC+01:00"
],
"borders": [
"AUT",
"BEL",
"CZE",
"DNK",
"FRA",
"LUX",
"NLD",
"POL",
"CHE"
],
"nativeName": "Deutschland",
"numericCode": "276",
"currencies": [
{
"code": "EUR",
"name": "Euro",
"symbol": "€"
}
],
"languages": [
{
"iso639_1": "de",
"iso639_2": "deu",
"name": "German",
"nativeName": "Deutsch"
}
],
"translations": {
"br": "Alemanha",
"de": "Deutschland",
"es": "Alemania",
"fa": "آلمان",
"fr": "Allemagne",
"hr": "Njemačka",
"it": "Germania",
"ja": "ドイツ",
"nl": "Duitsland",
"pt": "Alemanha"
},
"flag": "https://restcountries.eu/data/deu.svg",
"regionalBlocs": [
{
"acronym": "EU",
"name": "European Union"
}
],
"cioc": "GER"
},
{…}
]
Available API Endpoints
The countrylayer API comes with a number of endpoints, each providing different functionality. You can customize the request output data to get only the fields you need. This causes the request to execute faster, and reduces the response size.
Endpoint for all countries
GET https://api.countrylayer.com/v2/all
? access_key = API_KEY
Endpoint for country search by name
GET https://api.countrylayer.com/v2/name/{name}
? access_key = API_KEY & FullText=
Endpoint for country search by capital
GET https://api.countrylayer.com/v2/capital/{capital}
? access_key = API_KEY
Endpoint for country search by language
GET https://api.countrylayer.com/v2/language/{language}
? access_key = API_KEY
Endpoint for country search by currency
GET https://api.countrylayer.com/v2/currency/{currency}
? access_key = API_KEY
Endpoint for country search by region
GET https://api.countrylayer.com/v2/region/{region}
? access_key = API_KEY
Endpoint for country search by region block
GET https://api.countrylayer.com/v2/regionalbloc/{regionalbloc}
? access_key = API_KEY
Endpoint for country search by calling code
GET https://api.countrylayer.com/v2/callingcode/{callingcode}
? access_key = API_KEY
Endpoint for country search by alpha code
GET https://api.countrylayer.com/v2/alpha/{code}
? access_key = API_KEY
As you can see, these endpoints can be very useful for you to be able to access and utilize the country information needed for your project in a variety of manners, and helps to streamline and speed up your requests for the fastest execution possible.
You can learn more about how to integrate the countrylayer API into your projects by reading their extensive (yet surprisingly succinct and simple) documentation.
How Much Does Using The countrylayer API Cost?
You can get started for free with 100 searches per month and a rate limit of 1 per second. From there, pricing goes up from $9.99 per month for up to 5,000 searches, all the way to $149.99 per month for 250,000 searches. Enterprise pricing is also available on request. It’s important to note that SSL encryption is only available with paid subscription plans.
How Will You Use The countrylayer API In Your Projects?
As you can see, countrylayer is a relatively simple yet robust solution that can be used in a multitude of ways in your current and future projects. It is easy to integrate, provides accurate and extensive data, and is very affordable. We encourage you to give it a try – especially since you can get started for free! When you do, be sure to let us know what you think by reaching out on any of our social channels.
Leave a Reply
Want to join the discussion?Feel free to contribute!