TL;DR
The World Bank API provides programmatic access to thousands of global development indicators spanning economics, education, health, environment, infrastructure, and poverty. Track GDP growth, population trends, literacy rates, CO2 emissions, internet penetration, and life expectancy — for every country from 1960 to present. The API is extremely stable, well-documented, and has been the backbone of international development data for decades.
Quick start: https://api.worldbank.org/v2/country/all/indicator/SP.POP.TOTL?format=json
No API key needed — just make a request!
How to Use This API
1. Get World Population (SP.POP.TOTL)
https://api.worldbank.org/v2/country/all/indicator/SP.POP.TOTL?format=json
Returns population data for every country, every year. The response is an array where the first element is metadata and the second is the data array.
2. GDP for a Specific Country — United States
https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD?format=json
Returns US GDP (current US$) year by year. Country codes are ISO 3166-1 alpha-2.
3. Multiple Indicators at Once
https://api.worldbank.org/v2/country/CN/indicator/NY.GDP.MKTP.CD;SP.POP.TOTL;SE.ADT.LITR.ZS?format=json
China's GDP, population, and literacy rate in one request. Separate indicator codes with semicolons.
4. JavaScript — GDP Comparison
async function getIndicator(country, indicator) {
const resp = await fetch(
`https://api.worldbank.org/v2/country/${country}/indicator/${indicator}?format=json`
);
const [, data] = await resp.json();
return data
.filter(d => d.value !== null)
.map(d => ({ year: d.year, value: parseFloat(d.value) }))
.reverse();
}
async function compareGDP() {
const us = await getIndicator('US', 'NY.GDP.MKTP.CD');
const cn = await getIndicator('CN', 'NY.GDP.MKTP.CD');
console.log('Year | US GDP | China GDP');
us.slice(0, 5).forEach((d, i) => {
console.log(`${d.year} | $${(d.value/1e12).toFixed(2)}T | $${(cn[i].value/1e12).toFixed(2)}T`);
});
}
compareGDP();
5. Python — Countries with Highest GDP Growth
import requests
def get_top_gdp_growth(year=2025):
resp = requests.get(
'https://api.worldbank.org/v2/country/all/indicator/NY.GDP.MKTP.KD.ZG',
params={'format': 'json', 'per_page': 100, 'date': year}
)
_, data = resp.json()
sorted_data = sorted(
[(d['country']['value'], float(d['value']))
for d in data if d['value']],
key=lambda x: x[1],
reverse=True
)
print(f"Top GDP growth rates in {year}:")
for name, growth in sorted_data[:10]:
print(f" {name}: {growth:.2f}%")
get_top_gdp_growth()
https://api.worldbank.org/v2/country/all/indicator/SP.POP.TOTL?format=json
Frequently Asked Questions
- How do I find indicator codes?
- Browse
/v2/indicator?format=jsonfor all 10,000+ indicators. Or use the World Bank Data Catalog online. Common codes: SP.POP.TOTL (population), NY.GDP.MKTP.CD (GDP current US$), NY.GDP.MKTP.KD.ZG (GDP growth %), SE.ADT.LITR.ZS (literacy rate), SP.DYN.LE00.IN (life expectancy). - What country codes are used?
- ISO 3166-1 alpha-2 codes (US, GB, CN, IN, etc.). Special values:
all(all countries),WLD(world aggregate),EAS(East Asia),EUU(European Union). - How much historical data is available?
- Most indicators go back to 1960. Some go to 1950 or earlier. Data runs to the most recent year available (typically 1-2 years behind present due to collection lag).
- Can I get data in XML or other formats?
- Yes! Default is JSON with
?format=json. Also supports XML, and CSV-like responses. The API also supports JSONP for cross-domain requests. - What are the rate limits?
- No strict rate limits, but the API has been known to throttle excessive requests. The World Bank encourages caching and responsible use. It's extremely stable for regular use.
- Does it include sub-national/regional data?
- Limited. Most indicators are country-level. Some have regional aggregates (East Asia & Pacific, Sub-Saharan Africa, etc.). Use region codes like
SASfor South Asia.
API Details
- API URL
https://api.worldbank.org/v2- Documentation
- datahelpdesk.worldbank.org
- Category
- Government
- Authentication
- Not Required
- Geographic Coverage
- Global — 200+ countries and regional aggregates
What You Can Build
- Economic dashboard comparing GDP, inflation, and trade across countries
- Population growth visualizer with historical trends since 1960
- Development indicators tracker — SDG progress by country
- Education data explorer — literacy rates, enrollment, spending
- Environmental data viewer — CO2 emissions, energy use, forest area