Skip to main content

Get country details by ISO2 code or ID

GET http://api.countrystatecity.org/v1/countries/{cisoORid}

Authentication#

This free api uses API Key to authenticate. API Key needs to be passed in headers.

  • Header Name : X-API-KEY

Request Parameters#

NameLocationDescriptionRequiredType
{cisoORid}URLISO2 Code OR IDYESstring

Response#

CodeDescription
200Returns a country detail
401Unauthorized
404Not Found

Example Usage#

script.js
var headers = new Headers();
headers.append("X-API-KEY", "api key value");
var requestOptions = {
method: 'GET',
headers: headers,
redirect: 'follow'
};
fetch("https://api.countrystatecity.org/v1/countries/IN", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Example Success Response#

Success Response
[
{
"id": 101,
"name": "India",
"iso3": "IND",
"iso2": "IN",
"phonecode": "91",
"capital": "New Delhi",
"currency": "INR",
"native": "भारत",
"emoji": "🇮🇳",
"emojiU": "U+1F1EE U+1F1F3",
"longitude":28,
"latitude":77
},
...
]

Example Error Response#

Error Response
{
"error":"Unauthorized. Please provide X-API-KEY and api key value in header."
}

Example NotFound Response#

Error Response
{
"error":"No country found."
}