World Bank API: Compare countries by a statistic
Ranks countries by a World Development Indicators statistic for a given year, or for the latest year with broad country coverage. Regional aggregates and countries without data for that year are left out.
Unofficial. Not affiliated with or endorsed by World Bank.
Inputs
Values from the run on Oct 23, 2026, shown under Output.
- Year optional
year Calendar year, for example 2022. Leave out to use the latest year with broad country coverage.
Not set
Whole number from 1960 to 2100.
- Countries optional
countries Comma-separated country names, for example United States, Canada, France. Leave out to rank all countries.
United States, Canada
Default
.- Statistic, required
statistic Statistic in plain words, for example GDP per person or life expectancy.
infant mortality
- Max Results optional
max_results Maximum number of ranked countries, for example 20.
20 (default)
Whole number from 1 to 250.
Input as JSON
{ "countries": "United States, Canada", "statistic": "infant mortality"}Output
{ "unit": "per 1,000 live births", "year": 2024, "countries": [ { "rank": 1, "value": 5.5, "country": "United States", "page_link": "https://data.worldbank.org/indicator/SP.DYN.IMRT.IN?locations=USA" , "country_code": "USA" }, { "rank": 2, "value": 4.7, "country": "Canada", "page_link": "https://data.worldbank.org/indicator/SP.DYN.IMRT.IN?locations=CAN" , "country_code": "CAN" } ], "indicator_code": "SP.DYN.IMRT.IN", "statistic_name": "Mortality rate, infant (per 1,000 live births)"}Code
curl https://api.fous.com/v1/runs \ -H "Authorization: Bearer $FOUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"method":"worldbank.org/compare_countries","input":{"countries":"United States, Canada","statistic":"infant mortality"}}' # Save as fous.py, then run: python3 fous.pyimport json, os, timefrom urllib.error import HTTPErrorfrom urllib.request import Request, urlopenAPI = "https://api.fous.com/v1/runs" KEY = os.environ["FOUS_API_KEY"]HEADERS = { "Authorization": f"Bearer {KEY}", "Content-Type": "application/json" ,}def call(url, body=None): data = json.dumps(body).encode() if body else None request = Request(url, data, HEADERS) try: with urlopen(request, timeout=120) as r: return r.status, json.load(r) except HTTPError as error: message = json.load(error)["error"]["message"] raise RuntimeError(message) from errorstatus, run = call(API, { "method": "worldbank.org/compare_countries" , "input": { "countries": "United States, Canada", "statistic": "infant mortality" }})# 202: still going after 30 s. Ask again until it ends.while status == 202: time.sleep(2) status, run = call(f"{API}/{run['id']}")print(json.dumps(run["data"], indent=2))// Save as fous.mjs, then run: node fous.mjsconst api = "https://api.fous.com/v1/runs" ;const headers = { Authorization: `Bearer ${process.env.FOUS_API_KEY}`, "Content-Type": "application/json" ,};let response = await fetch(api, { method: "POST", headers, body: JSON.stringify({ "method": "worldbank.org/compare_countries" , "input": { "countries": "United States, Canada", "statistic": "infant mortality" } }), signal: AbortSignal.timeout(120_000),});let run = await response.json();// 202: still going after 30 s. Ask again until it ends.while (response.status === 202) { await new Promise((done) => setTimeout(done, 2_000)); response = await fetch(`${api}/${run.id}`, { headers }); run = await response.json();}if (!response.ok) throw new Error(run.error.message);console.log(run.data);# Connect your agent to Fous once, over MCP (Streamable HTTP):# https://api.fous.com/mcp# Set FOUS_API_KEY first: create a key at https://app.fous.com/keys.# Claude Codeclaude mcp add \ --scope user \ --transport http fous https://api.fous.com/mcp \ --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"# Codexcodex mcp add fous \ --url https://api.fous.com/mcp \ --bearer-token-env-var FOUS_API_KEY# Cursor, VS Code, Windsurf, Cline and morenpx -y add-mcp https://api.fous.com/mcp -g -n fous \ --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"# Then ask your agent:# "Use Fous to run worldbank.org/compare_countries# with {"countries":"United States, Canada","statistic":"infant mortality"}"Over HTTP, the answer’s data holds the output. A run still going after 30 seconds answers 202 with its id: ask GET /v1/runs/{id} until it ends.
Schema
Input schema
{ "type": "object", "required": [ "statistic" ], "properties": { "year": { "type": "integer", "maximum": 2100, "minimum": 1960, "description": "Calendar year, for example 2022. Leave out to use the latest year with broad country coverage." }, "countries": { "type": "string", "default": "", "description": "Comma-separated country names, for example United States, Canada, France. Leave out to rank all countries." }, "statistic": { "type": "string", "description": "Statistic in plain words, for example GDP per person or life expectancy." }, "max_results": { "type": "integer", "default": 20, "maximum": 250, "minimum": 1, "description": "Maximum number of ranked countries, for example 20." } }}Output schema
{ "type": "object", "required": [ "statistic_name", "year", "indicator_code", "countries" ], "properties": { "unit": { "type": [ "string", "null" ], "description": "Measurement unit." }, "year": { "type": "integer", "description": "Reporting year for the country values." }, "countries": { "type": "array", "items": { "type": "object", "required": [ "rank", "country", "value", "country_code", "page_link" ], "properties": { "rank": { "type": "integer" }, "value": { "type": "number" }, "country": { "type": "string" }, "page_link": { "type": "string", "description": "World Bank chart for this indicator and country." }, "country_code": { "type": "string" } } }, "description": "Ranked countries, highest value first." }, "indicator_code": { "type": "string", "description": "World Bank indicator identifier." }, "statistic_name": { "type": "string", "description": "World Bank statistic name." } }}- Price
- 1 credit per completed run (1¢ with pay as you go); failed runs are free.
- Method
worldbank.org/compare_countries- Returns
- statistic name, unit, year, indicator code, ranked countries with values and chart links
Use it from your agent
Give your agent this line. It reads SKILL.md, gets a Fous API key and connects the Fous MCP server. Its run then takes the method worldbank.org/compare_countries with the inputs above.
Ask your agent
- Rank countries by life expectancy in 2021, top 15
- Which countries have the highest GDP per person in 2022? Show me the top 20
- Compare infant mortality rate for United States, Canada, Japan and Germany in 2019
- On worldbank.org, rank all countries by CO2 emissions per person for the latest year
- Show unemployment rate ranking for Brazil, Mexico, Chile, Argentina in 2020 with chart links
See more
All World Bank methodsLooks up a World Bank statistic for a country and returns its annual values and latest value for the selected years.
data.worldbank.org/get_country_statisticRanks countries by a World Economic Outlook indicator for a chosen year, excluding regional and group totals and countries without a value.
imf.org/list_country_rankingsFinds the Our World in Data chart that best matches a statistic and returns its country-by-year numeric values, definition and source.
ourworldindata.org/get_statisticCompares the latest reported value of an economic indicator across countries in a region, highest first. World includes all listed countries; Australia uses the Oceania region.
tradingeconomics.com/list_countries_by_indicatorGets the latest WHO value of a health statistic for a country, with sex-specific values, the regional value for the same year, and up to 10 years of history.
who.int/get_country_health_statisticsRanks Premier League players for a season by goals, assists or goalkeeper clean sheets, with each player's club and nationality.
premierleague.com/list_top_scorersRanks public companies worldwide, or by country and industry, by market cap, revenue, earnings, employees or dividend yield. When both a country and an industry are set, the industry ranking order is kept and only companies from that country are shown.
companiesmarketcap.com/list_largest_companiesLooks up an official Eurostat statistic for an EU or EEA country and the EU27 figure for the same period. Quarterly and half-yearly series return the reporting period that contains a requested month.
ec.europa.eu/get_statistic