The Country API provides useful statistics about every country in the world.
https://api.api-ninjas.com/v1/country
Get country data from given parameters. Returns a list of country statistics that satisfy the parameters.
name
optionalPlain English name, 2-letter ISO-3166 alpha-2, or 3-letter ISO-3166 alpha-3 code of country.
currency
optional3-letter currency code of country (e.g. USD
).
min_gdp
optionalMinimum gross domestic product (GDP) of country, in US Dollars.
max_gdp
optionalMaximum gross domestic product (GDP) of country, in US Dollars.
min_population
optionalMinimum population of country.
max_population
optionalMaximum population of country.
min_area
optionalMinimum surface area of country in km2.
max_area
optionalMaximum surface area of country in km2.
min_unemployment
optionalMinimum unemployment rate in %.
max_unemployment
optionalMaximum unemployment rate in %.
min_gdp_growth
optionalMinimum GDP growth rate in %.
max_gdp_growth
optionalMaximum GDP growth rate in %.
min_infant_mortality
optionalMinimum infant mortality rate in %.
max_infant_mortality
optionalMaximum infant mortality rate in %.
min_fertility
optionalMinimum fertility rate in %.
max_fertility
optionalMaximum fertility rate in %.
min_urban_pop_rate
optionalMinimum urban population rate in %.
max_urban_pop_rate
optionalMaximum urban population rate in %.
limit
optionalHow many results to return. Must be between 1
and 30
. Default is 5
.
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/country?name=United States
Headers
X-Api-Key
Log in or sign up to get your API Key
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[
{
"gdp": "20580223",
"sex_ratio": "97.9",
"surface_area": "9833517",
"life_expectancy_male": "76.3",
"unemployment": "3.9",
"imports": "2567490",
"homicide_rate": "5",
"currency": {
"code": "USD",
"name": "Us Dollar"
},
"iso2": "US",
"gdp_growth": "2.9",
"employment_services": "79",
"urban_population_growth": "0.9",
"secondary_school_enrollment_female": "98.7",
"employment_agriculture": "1.3",
"capital": "Washington, D.C.",
"co2_emissions": "4761.3",
"forested_area": "33.9",
"tourists": "79746",
"exports": "1644280",
"life_expectancy_female": "81.3",
"post_secondary_enrollment_female": "102.0",
"post_secondary_enrollment_male": "75.0",
"primary_school_enrollment_female": "101.4",
"infant_mortality": "5.8",
"secondary_school_enrollment_male": "99.2",
"threatened_species": "1655",
"population": "331003",
"urban_population": "82.5",
"employment_industry": "19.7",
"name": "United States",
"pop_growth": "0.6",
"region": "Northern America",
"pop_density": "36.2",
"internet_users": "87.3",
"gdp_per_capita": "62917.9",
"fertility": "1.8",
"refugees": "1043.2",
"primary_school_enrollment_male": "102.2"
}
]
1
2
3
4
5
6
7
8
9
import requests
country = 'United States'
api_url = 'https://api.api-ninjas.com/v1/country?name={}'.format(country)
response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'})
if response.status_code == requests.codes.ok:
print(response.text)
else:
print("Error:", response.status_code, response.text)
If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.