5 atoms
Base tier

About

The API lets you retrieve details about a specific country.
The API is ideal for a wide range of applications, including geolocation-based services, research, and education. The API provides detailed information about countries, such as states, flags, and calling codes, allowing developers to easily integrate specific data into their applications. Whether you're building a travel application, an educational tool, or a global directory, this API offers comprehensive data that is required.
Try out the API in the API playground and see how this free online country data API can help you save time and access country information services with a simple API call.

API Playground

API Documentation

country data
GET
https://api.apyhub.com/data/info/country

Request example

1
```cURL
2
3
curl --location --request GET 'https://api.apyhub.com/data/info/country?country=UK' \
4
--header 'apy-token: {{token}}' \
5
--header 'Content-Type: application/json' \
Method: GET
Content Type: application/json
Query Parameter(s)
AttributeTypeMandatoryDescription
countryStringYesThe name of the country for which you want to find the details (country name or country code)
Response
AttributeTypeDescription
data.keyStringCountry code
data.valueStringName of the country
data.cca3StringThree digit country code
data.emojiStringFlag emoji for the country
data.calling_codeArray of IntegersArray of country codes (most often it is just one)
data.subdivisionArrayArray of subdivision elements (states or regions )
data.subdivision[a].codeStringSubdivision code
data.subdivision[a].nameStringName of the subdivision
data.currency.keyStringCurrency code
data.currency.valueStringName of the Currency
data.currency.symbolStringCurrency Symbol
data.currency.emojiStringCurrency emoji for that currency
Sample Response
A successful request returns country informaiton in JSON format. If the request fails, the response contains an error code and a message to help determine what went wrong.
1
{
2
"data": {
3
"value": "United Kingdom",
4
"key": "GB",
5
"cca3": "GBR",
6
"emoji": "🇬🇧",
7
"calling_code": [
8
44
9
],
10
"subdivision": [
11
{
12
"code": "GB-ABC",
13
"name": "Armagh, Banbridge and Craigavon"
14
},
15
{
16
"code": "GB-ABD",
17
"name": "Aberdeenshire"
18
},
19
....
20
],
21
"currency": {
22
"emoji": "💷",
23
"key": "GBP",
24
"symbol": "£",
25
"value": "Pound Sterling"
26
}
27
}
28
}

HTTP Response Codes

The method may return one of the following HTTP status codes:
Status CodeDescription
200The request was successful.
400Invalid input - the country is not provided.
401Required authentication information is either missing or not valid for the resource.
500If any unexpected error occurs while processing the request

Authentication

All API requests to ApyHub services need to be authenticated. Currently we support tokens or basic authentication mechanisms. You can generate and view your existing credentials from your workspace settings (on the left side of the navbar) and go to “API Keys".
Points to note:
  • Credential secrets are generated on the fly and are not stored in plain text, so on generating a credential please save the secrets somewhere safe.
  • Use the apy-token as the header parameter to pass the token.
  • Use the Authorization header to send the basic authentication credentials.

Error codes

1
{
2
"error": {
3
"code": 105,
4
"message": "Invalid URL"
5
}
6
}
To search for a specific error code, enter the code in the search box below. Alternatively, you can click on the button to view a complete list of all error codes.