Country API

The Country API provides useful statistics about every country in the world.

/v1/country GET

https://api.api-ninjas.com/v1/country

Get country data from given parameters. Returns a list of country statistics that satisfy the parameters.


Parameters

  • name  optional

    Plain English name, 2-letter ISO-3166 alpha-2, or 3-letter ISO-3166 alpha-3 code of country.

  • currency  optional

    3-letter currency code of country (e.g. USD).

  • min_gdp  optional

    Minimum gross domestic product (GDP) of country, in US Dollars.

  • max_gdp  optional

    Maximum gross domestic product (GDP) of country, in US Dollars.

  • min_population  optional

    Minimum population of country.

  • max_population  optional

    Maximum population of country.

  • min_area  optional

    Minimum surface area of country in km2.

  • max_area  optional

    Maximum surface area of country in km2.

  • min_unemployment  optional

    Minimum unemployment rate in %.

  • max_unemployment  optional

    Maximum unemployment rate in %.

  • min_gdp_growth  optional

    Minimum GDP growth rate in %.

  • max_gdp_growth  optional

    Maximum GDP growth rate in %.

  • min_infant_mortality  optional

    Minimum infant mortality rate in %.

  • max_infant_mortality  optional

    Maximum infant mortality rate in %.

  • min_fertility  optional

    Minimum fertility rate in %.

  • max_fertility  optional

    Maximum fertility rate in %.

  • min_urban_pop_rate  optional

    Minimum urban population rate in %.

  • max_urban_pop_rate  optional

    Maximum urban population rate in %.

  • limit  optional

    How many results to return. Must be between 1 and 30. Default is 5.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

country
https://api.api-ninjas.com/v1/country?name=United States

Sample Response

JSON
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" } ]

Code Examples

1 2 3 4 5 6 7 8 import requests api_url = 'https://api.api-ninjas.com/v1/country?name=United States' 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.