World Bank
World Bank Indicators API — Annual macro for every country with one indicator code — the quickest cross-country table on the web
When the question is 'across countries' and annual is fine — growth, inflation, unemployment, debt, population — or you need the Pink Sheet's monthly commodity prices (energy, metals, food) with history to 1960.
Reach for it when…
When the question is 'across countries' and annual is fine — growth, inflation, unemployment, debt, population — or you need the Pink Sheet's monthly commodity prices (energy, metals, food) with history to 1960.
Not for: Anything monthly or daily for one country (its central bank or statistics office), the latest year (World Bank data lag national sources by months), market prices.
Units, revisions, traps
Units. Per indicator: percent, current US dollars, constant dollars, index. Country codes are ISO-3 (KOR, not KR); aggregates (WLD, EAS) are available too.
Revisions. Annual updates in spring; national revisions flow through with a lag.
- The JSON returns a two-element array: metadata first, data second.
- The most recent year is often null — use mrnev (most recent non-empty value) or drop nulls.
- Pink Sheet is a spreadsheet, not the API; read the xlsx.
- Multi-country requests (KR;JP;…) and some mrv= requests have answered 502 while single-country, date-range calls worked — loop countries and ask for date=YYYY:YYYY when that happens.
Classic mistake: Reading GDP in current dollars as real growth.
Three recipes
- Recipe 1 · Inflation for a set of countries
- Recipe 2 · The Pink Sheet: monthly commodity prices since 1960
- Recipe 3 · Unemployment across a region
Each recipe: Python · Excel · Sheets, with how to read the result. Python recipes run under pandas; recipe 1 is re-run by the weekly check where the source allows it.
How to use it in your own work
Copy the snippet, change the series id, read the result the way the footer says. Replace YOUR_…_KEY with your own key where one is needed.
Recipe 1Inflation for a set of countries
# one call per country (the multi-country form KR;JP and some larger requests answered 502 when we checked)
import requests, pandas as pd
out = {}
for c in ["KR", "JP", "SG", "US", "DE"]:
u = f"https://api.worldbank.org/v2/country/{c}/indicator/FP.CPI.TOTL.ZG?format=json&mrv=5"
rows = requests.get(u, timeout=30).json()[1]
out[rows[0]["country"]["value"]] = {r["date"]: r["value"] for r in rows}
print(pd.DataFrame(out).sort_index().round(1))- Data → From Web → the same URL with &format=xml, or use the site's Download CSV.
- No native JSON import — use the site's CSV download, or the Python recipe.
Recipe 2The Pink Sheet: monthly commodity prices since 1960
import pandas as pd
u = "https://thedocs.worldbank.org/en/doc/18675f1d1639c7a34d463f59263ba0a2-0050012025/related/CMO-Historical-Data-Monthly.xlsx"
df = pd.read_excel(u, sheet_name="Monthly Prices", skiprows=4)
df = df.rename(columns={df.columns[0]: "month"}).dropna(subset=["month"])
print(df[["month", "CRUDE_BRENT", "GOLD", "WHEAT_US_HRW"]].tail())- Open the xlsx from the Commodity Markets page (worldbank.org/en/research/commodity-markets).
- Import the xlsx.
Recipe 3Unemployment across a region
import requests, pandas as pd
u = "https://api.worldbank.org/v2/country/EAS/indicator/SL.UEM.TOTL.ZS?format=json&mrv=10"
rows = requests.get(u, timeout=30).json()[1]
print(pd.DataFrame([(r["date"], r["value"]) for r in rows], columns=["year", "East Asia & Pacific"]))- From Web with &format=xml.
- Use the Python recipe.
Series → question map
The ids we use from World Bank Indicators API, each with the question it answers. The catalog's compare view reads the concept tags behind these rows.
| Series | Answers | Region | Concept |
|---|---|---|---|
| FP.CPI.TOTL.ZG | Inflation, any country, annual | global | cpi |
| NY.GDP.MKTP.KD.ZG | Real GDP growth, any country | global | gdp |
| SL.UEM.TOTL.ZS | Unemployment, any country | global | unemployment |
| Pink Sheet · CRUDE_BRENT | Brent, monthly, since 1960 | global | commodity |
| Pink Sheet · GOLD | Gold, monthly, since 1960 | global | commodity |
| GC.DOD.TOTL.GD.ZS | How indebted is a government? | global | debt |
Compare with
Same question, different source: IMF Data, OECD Data Explorer, EIA API. The compare view lines up coverage, frequency, history and access side by side and lists what the combination makes possible.
Open compare: World Bank Indicators API · IMF Data · OECD Data Explorer →
Questions readers ask
Is the World Bank API free?
Yes, no key, generous paging.
Why is the latest year missing?
National sources report with a lag and the Bank publishes once validated. Use mrnev=1 to get the most recent non-empty value.
Where is the Pink Sheet URL?
On the Commodity Markets page; the file name is stable (CMO-Historical-Data-Monthly.xlsx) but the folder id changes with each release — link from the page.
Educational only — we explain, we never advise · snippet licence: public domain · corrections to [email protected], fixed within a day and logged in the changelog.