Population API

The Population API provides historical, current, and projected future population statistics about every country in the world.

/v1/population GET

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

Get population data from given parameters. Returns a list of up to 5 country population statistics that satisfy the parameters. For more results use the offset parameter.


Parameters

At least one of the following parameters must be set: country, min_population, max_population

  • country  optional

    Country name (case-insensitive) or 2-letter ISO-3166 alpha-2 code of the country. E.g. Japan or JP.

  • min_population  optional

    Minimum population of country.

  • max_population  optional

    Maximum population of country.

  • offset  optional

    Offset results for pagination.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

country
https://api.api-ninjas.com/v1/population?country=Japan

Headers

X-Api-KeyLog in or sign up to get your API Key

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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 { "country_name": "Japan", "historical_population": [ { "year": 2024, "population": 123753041, "yearly_change_percentage": -0.5, "yearly_change": -617906, "migrants": 153357, "median_age": 49.4, "fertility_rate": 1.22, "density": 339, "urban_population_pct": 92.9, "urban_population": 114979260, "percentage_of_world_population": 1.52, "rank": 12 }, { "year": 2023, "population": 124370947, "yearly_change_percentage": -0.5, "yearly_change": -626631, "migrants": 175003, "median_age": 49, "fertility_rate": 1.21, "density": 341, "urban_population_pct": 92.7, "urban_population": 115292289, "percentage_of_world_population": 1.54, "rank": 12 }, ... ], "population_forecast": [ { "year": 2025, "population": 123103479, "yearly_change_percentage": -0.51, "yearly_change": -640213, "migrants": 140579, "median_age": 49.8, "fertility_rate": 1.23, "density": 338, "urban_population_pct": 93.1, "urban_population": 114645589, "percentage_of_world_population": 1.5, "rank": 12 }, { "year": 2030, "population": 119584121, "yearly_change_percentage": -0.58, "yearly_change": -703872, "migrants": 123993, "median_age": 51.5, "fertility_rate": 1.26, "density": 328, "urban_population_pct": 94.3, "urban_population": 112710068, "percentage_of_world_population": 1.4, "rank": 15 }, ... ] }

Code Examples

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