Trusted by thousands of developers worldwide

Gorillaz Tal Tech Wanderlust Much Better Adventures Fx Skross Xero One Finestay

The reliable country data solution

Free

Improves user experience

Customize user experience by identifying accurately users’ country, city, language, and more.

Simple & Easy To Integrate

Reliable

Accurate country database based on official information from each country.

Information

Easy to Integrate

Delivered in portable JSON format for maximum usability, ease of integration, and compatibility with any programming language.

Country List

Extensive Country Information

Provides accurate country data, including geographical position, population, codes, currencies, languages, flag images,phone number format, and much more.

Access to Worldwide Country Data, Developer friendly

Get instant access to accurate country data for various geo-points in the world and enjoy a rich set of capabilities:

  • Accurate Country API
  • Forms Autocomplete
  • Bulk API Endpoint

Code Samples

You can integrate our countrylayer API into any of your applications written in any programming language.
The following code examples show how to use the countrylayer API with some common programming languages:
Search by country name. It can be a native or partial name.

var client = new
RestClient(“https://api.countrylayer.com/v2/all
? access_key = ((YOUR_ACCESS_KEY))”);
client.Timeout = -1
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
var settings = {
“url”: “https://api.countrylayer.com/v2/all
? access_key = ((YOUR_ACCESS_KEY))”,
“method”: “GET”,
“timeout”: 0,
};

$.ajax(settings).done(function (response) {
console.log (response);
});
$curl = curl.init();

curl.setopt_array($curl, array(
CURLOPT_URL=>
‘https://api.countrylayer.com/v2/all
? access_key = ((YOUR_ACCESS_KEY))’,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => ’’,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => ‘GET’,
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Documentation

Let’s send your first email. Grab the code below in your preferred language and paste it into your terminal.

Endpoint for country search by name

This endpoint will return available country data when it is searched by name of the country. If we search using a partial name, for example, “aus” then the API will return all countries that contain “Aus”. If we want to search for a country by the correct full name, then in the query we will have to add the parameter FullText, true or false.

API Request:

GET https://api.countrylayer.com/v2/name/{name}
    ? access_key = API_KEY & FullText=

Request Parameters:

Parameter Description
access_key [Required] Your API Key.
name As part of the URL
fullText A boolean parameter in the URL

The API response and parameters are given above in the /all endpoint example.

Sign Up for our Free Plan to get instant access to country data