Population API
The Population API provides historical, current, and projected future population statistics about every country in the world.
From 8,616 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 314ms | 354ms | 364ms | 685ms | 1254ms |
Similar APIs
Didn't find what you were looking for? Suggest an improvement
/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
countryoptionalCountry name (case-insensitive) or 2-letter ISO-3166 alpha-2 code of the country. E.g.
JapanorJP.min_populationoptionalMinimum population of country.
max_populationoptionalMaximum population of country.
offsetoptionalOffset results for pagination.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
A JSON object with the following fields or an error if the request is unsuccessful.
country_nameThe name of the country.
historical_populationArray of historical population data objects, each containing the following fields:
yearThe year for which the population data is recorded.
populationTotal population count for the country in the given year.
yearly_change_percentagePercentage change in population from the previous year (can be positive or negative).
yearly_changeAbsolute change in population from the previous year (can be positive or negative).
migrantsNet number of migrants (immigrants minus emigrants) for the year.
median_ageMedian age of the population in years.
fertility_rateAverage number of children born per woman in the population.
densityPopulation density per square kilometer.
urban_population_pctPercentage of the total population living in urban areas.
urban_populationTotal number of people living in urban areas.
percentage_of_world_populationPercentage of the world's total population represented by this country.
rankWorld ranking by population size (1 being the most populous country).
population_forecastArray of projected future population data objects with the same structure as
historical_population.
Sample Request Live Demo!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
https://api.api-ninjas.com/v1/population?country=JapanHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/population?country=United%20States" \
-H "X-Api-Key: YOUR_API_KEY"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.
Frequently Asked Questions
Can I use the Population API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Population API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Population API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Population API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.How do I query population data for a specific country?
Set thecountryparameter to either a country name (case-insensitive) or its 2-letter ISO-3166 alpha-2 code, for exampleJapanorJP. To enrich those results with broader country-level details, pair it with the Country API.What does each population data point in the response include?
The response returnscountry_nameplus ahistorical_populationarray and apopulation_forecastarray, where every entry includesyear,population,yearly_change,yearly_change_percentage,migrants,median_age,fertility_rate,density,urban_population,urban_population_pct,percentage_of_world_population, and the country's globalrank. Browse related economic datasets in the API catalog.Can I filter countries by population size instead of querying by name?
Yes, use themin_populationandmax_populationparameters to return only countries within a population range; at least one ofcountry,min_population, ormax_populationmust be set. For economic indicators across those same countries, try the GDP API or the Unemployment API.Why do I only get a few countries back, and how do I page through more?
The/v1/populationendpoint returns up to 5 matching country population records per request, so use theoffsetparameter to paginate through additional results when filtering by a population range. If you receive an unexpected response, consult the error codes reference.