How to use World Bank population data
The World Bank Indicators API provides free, unauthenticated access to population data for 218 countries from 1960 onward. This guide walks through finding indicators, constructing API queries, handling the response format, and reconciling World Bank data with UN WPP series.
Step 1 Navigate the World Bank Open Data portal
The starting point is data.worldbank.org — the World Bank's public data portal. From the homepage you can:
- Search by keyword: Type "population" or "fertility rate" into the search bar to find relevant indicators.
- Browse by topic: Navigate to Health → Population Dynamics for all population-related indicators.
- Download directly: Each indicator page offers CSV and Excel downloads for all countries and years in one file — useful for offline analysis without building an API query.
- Explore the DataBank: The DataBank tool (databank.worldbank.org) allows custom table building across multiple indicators and countries with a graphical interface.
Each indicator has a unique alphanumeric code displayed on its page (e.g., SP.POP.TOTL for total population). Note this code — you will need it for API queries in Step 3.
The World Bank sources most population data from the UN World Population Prospects. For a complementary guide to UN data specifically, see how to use UN population data.
Step 2 Identify the right indicator codes
The World Bank has over 16,000 indicators. For demographic analysis, the most commonly used population indicators are:
SP.POP.TOTL Total population (persons) 1960–present SP.DYN.TFRT.IN Fertility rate, total (births per woman) 1960–present SP.DYN.LE00.IN Life expectancy at birth, total (years) 1960–present SP.POP.GROW Population growth, annual % 1961–present SP.POP.0014.TO.ZS Population ages 0–14 (% of total) 1960–present SP.POP.65UP.TO.ZS Population ages 65+ (% of total) 1960–present SP.DYN.IMRT.IN Infant mortality rate (per 1,000 live births) 1960–present SP.URB.TOTL.IN.ZS Urban population (% of total) 1960–present These indicators cover the core metrics discussed throughout this site — see total fertility rate, life expectancy at birth, and infant mortality rate for conceptual definitions.
Step 3 Construct an API query
The World Bank Indicators API v2 base URL is https://api.worldbank.org/v2. No API key or authentication is required.
Basic single-country query
This returns Japan's total population for 1960–2025 as a JSON array.
Multiple countries in one call
Separate country codes with semicolons. Set per_page high enough to include all results.
All countries
Returns data for all 218 countries and territories for 2024. Includes regional aggregates — filter these in your code (see Step 4).
Most recent value only
The mrv=1 parameter returns only the most recent non-null value per country, regardless of year — useful for building country comparison tables.
Step 4 Handle the response format: aggregates, nulls, and pagination
The World Bank API response is a two-element JSON array — not a typical object with a data key:
Always check that response[1] exists and is not null before iterating — error responses arrive as HTTP 200 with a one-element array containing a message key.
Filter aggregates: When using country/all, the response includes regional and income-group aggregates (e.g., "East Asia & Pacific", "High income"). Identify and exclude these by checking country.region.value !== "Aggregates".
Handle null values: Some country-year combinations have no data — the value field will be null. Skip these rather than treating them as zero.
Pagination: If response[0].pages > 1, fetch subsequent pages by appending &page=2, &page=3, etc. Alternatively, set per_page=16000 to attempt all records in one call (works for most indicators).
For a practical implementation example, see the API client code in this site's own data layer at how to use UN population data for comparison of the two response formats.
Step 5 Compare and reconcile with UN WPP data
The World Bank's population data (source 2, World Development Indicators) draws primarily from UN WPP estimates, so values should be broadly consistent. However, small differences arise from:
- Revision vintages: The World Bank may be using an older WPP revision (e.g., WPP 2022) while the UN has published a newer one (WPP 2024). The revision year is visible in the indicator metadata.
- World Bank adjustments: For a small number of countries, the World Bank applies its own adjustments to the WPP estimates based on additional national sources.
- Coverage differences: UN WPP covers 1950–2100 (including projections); World Bank covers 1960–present (no projections). For historical data pre-1960 or projection scenarios, use UN WPP directly.
Recommended workflow: Use World Bank API for convenient access to 1960-present cross-country data in code; use UN WPP download for projection scenarios, age-disaggregated data, and historical series pre-1960. When values diverge by more than 1%, check the indicator metadata page for the WPP revision year and source notes.
For guidance on the UN data, see how to use UN population data. For understanding what population projections mean and how to interpret them, see understanding population projections and how to build a population projection.
Frequently asked questions
Is the World Bank Indicators API free to use?
Yes. The World Bank Indicators API v2 is completely free, requires no API key or authentication, and has no documented rate limits for reasonable use. Data is published under the CC BY 4.0 license, requiring attribution to the World Bank.
What is the indicator code for total population?
The World Bank indicator code for total population is SP.POP.TOTL. It covers 1960 to the most recent year available, for 218 countries and territories, in persons (the raw number, not thousands or millions). Values are sourced primarily from UN World Population Prospects.
How do I get data for multiple countries in one API call?
Separate multiple ISO-2 country codes with semicolons: /country/US;DE;JP/indicator/SP.POP.TOTL?format=json&per_page=200. For all countries use /country/all/indicator/... — remember to filter out regional aggregate entries (region.value === "Aggregates") from the response.
Why do World Bank and UN figures sometimes differ?
Small differences arise from different WPP revision vintages — the World Bank may be using an older WPP revision while the UN has released a newer one — and from World Bank adjustments for specific countries. For the most current estimates, check the WPP revision year in the World Bank metadata.