World Bank Data

Data API · Development indicators · Economic data · Global statistics

TL;DR

The World Bank Data API provides programmatic access to over 16,000 development indicators spanning 217 countries and regions. Query GDP, population, literacy rates, CO2 emissions, internet users, life expectancy, and thousands more metrics. Data goes back decades, with many indicators updated annually. Returns JSON or XML. Used by economists, researchers, and data journalists worldwide. No API key required.

Quick start: https://api.worldbank.org/v2/country/all/indicator/NY.GDP.MKTP.CD

No API key needed — free global development data!

How to Use This API

1. Get GDP for All Countries

Returns GDP (current US$) for every country, latest data first:

https://api.worldbank.org/v2/country/all/indicator/NY.GDP.MKTP.CD?format=json&per_page=50

2. Get Population Data

https://api.worldbank.org/v2/country/US/indicator/SP.POP.TOTL?format=json

3. Search Indicators

Find indicators related to internet access:

https://api.worldbank.org/v2/indicator?format=json&search=internet

4. JavaScript — Compare Two Countries

async function compareGDP(country1, country2) {
  for (const c of [country1, country2]) {
    const resp = await fetch(
      `https://api.worldbank.org/v2/country/${c}/indicator/NY.GDP.MKTP.CD?format=json&per_page=5`
    );
    const [, data] = await resp.json();
    console.log(`\n${c}:`);
    data.forEach(d => console.log(`  ${d.date}: $${(d.value/1e9).toFixed(2)}B`));
  }
}
compareGDP('US', 'CN');

5. Python — Life Expectancy Trend

import requests

resp = requests.get(
    'https://api.worldbank.org/v2/country/BR/indicator/SP.DYN.LE00.IN',
    params={'format': 'json', 'per_page': 30}
).json()

for entry in resp[1]:
    if entry['value']:
        print(f"{entry['date']}: {float(entry['value']):.1f} years")
US Population: https://api.worldbank.org/v2/country/US/indicator/SP.POP.TOTL?format=json

Frequently Asked Questions

How many indicators are available?
Over 16,000 indicators across 21 topics including agriculture, education, energy, finance, health, infrastructure, poverty, and trade. Use the /v2/indicator endpoint to browse them all.
What country codes should I use?
Use ISO 3166-1 alpha-2 codes (US, GB, BR, IN, CN, etc.). Use all for all countries or WLD for world aggregate. The /v2/country endpoint lists all available codes.
Can I filter by date range?
Yes — use the date parameter: date=2000:2020 returns data between those years. Use per_page (max 1200) and page for pagination.
What formats are supported?
JSON (?format=json) and XML (default). JSON responses include an array with metadata and data entries. Each data entry contains value, date, and metadata like country and indicator.
Is the API updated regularly?
Indicators are updated as new data becomes available, typically annually. The World Bank updates its databases throughout the year as countries submit new statistics.
Does it include regional aggregates?
Yes — use codes like EAS (East Asia), ECS (Europe), LCN (Latin America), MEA (Middle East), NAC (North America), SAS (South Asia), and SSF (Sub-Saharan Africa).

API Details

API URL
https://api.worldbank.org/v2/
Documentation
World Bank Data Help Desk
Category
Data
Authentication
Not Required
Output Formats
JSON, XML

What You Can Build