# World Bank API

> World Bank returns country development statistics and rankings, available as a workflow and API.

Compare countries ranks countries by a development statistic; provide a statistic and optionally a year, countries, or result limit.

- Page: https://fous.com/tools/world-bank
- Handle: `@world-bank`
- Category: [Data](https://fous.com/tools/category/data)
- Source website: https://data.worldbank.org
- Last verified: Sep 29, 2026

## Methods

### Compare countries

Operation `compare_countries`, version 1. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.

Rank countries by a World Bank development statistic, using a requested year or the latest year with broad country coverage. Regional aggregates and countries without data for the selected year are excluded. Statistics are matched against World Development Indicators.

**Input**

| Field | Type | Required | Example | Description |
|---|---|---|---|---|
| `year` | integer | no | `2022` | Calendar year, for example 2022. Leave out to use the latest year with broad country coverage. |
| `countries` | string | no | `"United States, Japan, Canada"` | Comma-separated country names, for example United States, Canada, France. Leave out to rank all countries. |
| `statistic` | string | yes | `"GDP per person"` | Statistic in plain words, for example GDP per person or life expectancy. |
| `max_results` | integer | no | `3` | Maximum number of ranked countries, for example 20. |

**Input schema**

```json
{
  "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.",
      "examples": [
        2022,
        2023
      ]
    },
    "countries": {
      "type": "string",
      "default": "",
      "description": "Comma-separated country names, for example United States, Canada, France. Leave out to rank all countries.",
      "examples": [
        "United States, Japan, Canada",
        "India, China, Brazil"
      ]
    },
    "statistic": {
      "type": "string",
      "description": "Statistic in plain words, for example GDP per person or life expectancy.",
      "examples": [
        "GDP per person",
        "life expectancy",
        "population"
      ]
    },
    "max_results": {
      "type": "integer",
      "default": 20,
      "maximum": 250,
      "minimum": 1,
      "description": "Maximum number of ranked countries, for example 20.",
      "x-fous-developer": true,
      "examples": [
        3
      ]
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "statistic": "GDP per person"
    },
    {
      "year": 2022,
      "countries": "United States, Japan, Canada",
      "statistic": "life expectancy",
      "max_results": 3
    },
    {
      "year": 2023,
      "countries": "India, China, Brazil",
      "statistic": "population"
    }
  ]
}
```

**Output**

| Field | Type | Example | Description |
|---|---|---|---|
| `unit` | string or null | `"USD"` | Measurement unit. |
| `year` | integer | `2025` | Reporting year for the country values. |
| `countries` | array |  | Ranked countries, highest value first. |
| `countries[].rank` | integer | `1` |  |
| `countries[].value` | number | `147252.179121515` |  |
| `countries[].country` | string | `"Luxembourg"` |  |
| `countries[].page_link` | string | `"https://data.worldbank.org/indicator/NY.GDP.PCAP.CD?locations=LUX"` | World Bank chart for this indicator and country. |
| `countries[].country_code` | string | `"LUX"` |  |
| `indicator_code` | string | `"NY.GDP.PCAP.CD"` | World Bank indicator identifier. |
| `statistic_name` | string | `"GDP per capita (current US$)"` | World Bank statistic name. |

**Example input**

```json
{
  "statistic": "GDP per person"
}
```

**Example output**

```json
{
  "unit": "USD",
  "year": 2025,
  "countries": [
    {
      "rank": 1,
      "value": 147252.179121515,
      "country": "Luxembourg",
      "page_link": "https://data.worldbank.org/indicator/NY.GDP.PCAP.CD?locations=LUX",
      "country_code": "LUX"
    },
    {
      "rank": 2,
      "value": 131592.462547877,
      "country": "Ireland",
      "page_link": "https://data.worldbank.org/indicator/NY.GDP.PCAP.CD?locations=IRL",
      "country_code": "IRL"
    },
    {
      "rank": 3,
      "value": 114769.012314293,
      "country": "Switzerland",
      "page_link": "https://data.worldbank.org/indicator/NY.GDP.PCAP.CD?locations=CHE",
      "country_code": "CHE"
    }
  ],
  "indicator_code": "NY.GDP.PCAP.CD",
  "statistic_name": "GDP per capita (current US$)"
}
```

### Get country statistic

Operation `get_country_statistic`, version 1. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.

Get a World Bank statistic for a country by year, including its latest value in the selected years. Supports common measures such as GDP, population, inflation, life expectancy, CO2 emissions per person, and unemployment.

**Input**

| Field | Type | Required | Example | Description |
|---|---|---|---|---|
| `country` | string | yes | `"Brazil"` | Country name, such as Brazil. |
| `to_year` | integer | no | `2024` | Last year to include, such as 2023. Defaults to the most recent year with data. |
| `from_year` | integer | no | `2019` | First year to include, such as 2015. Defaults to nine years before the most recent year with data. |
| `statistic` | string | yes | `"GDP"` | Statistic in everyday words, such as GDP per person or inflation. |

**Input schema**

```json
{
  "type": "object",
  "required": [
    "country",
    "statistic"
  ],
  "properties": {
    "country": {
      "type": "string",
      "minLength": 1,
      "description": "Country name, such as Brazil.",
      "examples": [
        "Brazil",
        "United States",
        "India"
      ]
    },
    "to_year": {
      "type": "integer",
      "description": "Last year to include, such as 2023. Defaults to the most recent year with data.",
      "examples": [
        2024,
        2025
      ]
    },
    "from_year": {
      "type": "integer",
      "description": "First year to include, such as 2015. Defaults to nine years before the most recent year with data.",
      "examples": [
        2019,
        2020,
        2023
      ]
    },
    "statistic": {
      "type": "string",
      "minLength": 1,
      "description": "Statistic in everyday words, such as GDP per person or inflation.",
      "examples": [
        "GDP",
        "unemployment",
        "CO2 emissions per person"
      ]
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "country": "Brazil",
      "to_year": 2024,
      "from_year": 2019,
      "statistic": "GDP"
    },
    {
      "country": "Brazil",
      "statistic": "GDP"
    },
    {
      "country": "United States",
      "statistic": "unemployment"
    }
  ]
}
```

**Output**

| Field | Type | Example | Description |
|---|---|---|---|
| `unit` | string or null | `"current US$"` | Unit of measurement. |
| `source` | string | `"World Development Indicators"` | World Bank data collection supplying this statistic. |
| `values` | array |  | Annual values, oldest first, including years without data. |
| `values[].year` | integer | `2019` |  |
| `values[].value` | number or null | `1873288205059.69` |  |
| `country` | string | `"Brazil"` | World Bank country name. |
| `statistic` | string | `"GDP (current US$)"` | World Bank indicator title. |
| `latest_year` | integer or null | `2024` | Year of the most recent available value within the selected years. |
| `latest_value` | number or null | `2185821610689.31` | Most recent available value within the selected years. |
| `data_page_link` | string | `"https://data.worldbank.org/indicator/NY.GDP.MKTP.CD?locations=BR"` | World Bank page for this country and statistic. |
| `indicator_code` | string | `"NY.GDP.MKTP.CD"` | World Bank indicator identifier. |

**Example input**

```json
{
  "country": "Brazil",
  "to_year": 2024,
  "from_year": 2019,
  "statistic": "GDP"
}
```

**Example output**

```json
{
  "unit": "current US$",
  "source": "World Development Indicators",
  "values": [
    {
      "year": 2019,
      "value": 1873288205059.69
    },
    {
      "year": 2020,
      "value": 1476107231310.49
    },
    {
      "year": 2021,
      "value": 1670647398904.9
    }
  ],
  "country": "Brazil",
  "statistic": "GDP (current US$)",
  "latest_year": 2024,
  "latest_value": 2185821610689.31,
  "data_page_link": "https://data.worldbank.org/indicator/NY.GDP.MKTP.CD?locations=BR",
  "indicator_code": "NY.GDP.MKTP.CD"
}
```

## Quick start

Replace `YOUR_API_KEY` with a Fous API key. To create one, open Developers at the bottom of Fous Studio, turn on Developer mode, then go to API keys (https://app.fous.com/keys). Change the values in `input` to run the same tool on new data.

```bash
curl 'https://api.fous.com/v1/query' \
  --fail-with-body --silent --show-error --max-time 180 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "api": "@world-bank",
  "visibility": "public",
  "operation": "compare_countries",
  "version": 1,
  "input": {
    "statistic": "GDP per person"
  },
  "response": {
    "format": "json"
  }
}'
```

```python
# Save as fous.py and run with python3 fous.py. No packages needed.
import json
import urllib.error
import urllib.request

api_key = "YOUR_API_KEY"

body = json.loads("{\n  \"api\": \"@world-bank\",\n  \"visibility\": \"public\",\n  \"operation\": \"compare_countries\",\n  \"version\": 1,\n  \"input\": {\n    \"statistic\": \"GDP per person\"\n  },\n  \"response\": {\n    \"format\": \"json\"\n  }\n}")
request = urllib.request.Request(
    "https://api.fous.com/v1/query",
    data=json.dumps(body).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    },
    method="POST",
)
try:
    with urllib.request.urlopen(request, timeout=180) as response:
        result = json.load(response)
except urllib.error.HTTPError as error:
    raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8', errors='replace')}") from error
if result.get("success") is False:
    raise RuntimeError(result.get("error", {}).get("message", "Request failed"))
print(json.dumps(result["data"]["output"], indent=2))
```

```typescript
// Save as fous.mts and run with npx tsx fous.mts.
const apiKey = "YOUR_API_KEY";

const response = await fetch("https://api.fous.com/v1/query", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  signal: AbortSignal.timeout(180_000),
  body: JSON.stringify({
  "api": "@world-bank",
  "visibility": "public",
  "operation": "compare_countries",
  "version": 1,
  "input": {
    "statistic": "GDP per person"
  },
  "response": {
    "format": "json"
  }
}),
});
type ApiResult = { success: boolean; data?: { output: unknown }; error?: { message: string } };
const result: ApiResult = await response.json();
if (!response.ok || result.success === false) {
  throw new Error(result.error?.message ?? `HTTP ${response.status}`);
}
if (!result.data) throw new Error("Missing API response data");
console.log(result.data.output);
```

## Use from an AI assistant

Connect this tool to Claude Code, Claude Desktop, Cursor, VS Code, Codex and any MCP client as its own MCP server. Each method is a typed tool whose arguments are the method’s input.

- Server URL: `https://api.fous.com/mcp/tools/world-bank`
- Authorization: `Authorization: Bearer <Fous API key>`

**Tools**

- `compare_countries`: Compare countries. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.
- `get_country_statistic`: Get country statistic. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.
- `fous_get_run`: the result of a run that was still going, by its `request_id`. Free.

Claude Code:

```bash
claude mcp add --scope user --transport http fous-world-bank https://api.fous.com/mcp/tools/world-bank --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"
```

To give the assistant every tool, connect `https://api.fous.com/mcp`: it finds one with `fous_search_tools` and runs it with `fous_run_tool`. Setup for other clients: https://fous.com/llms-full.txt.

## Use cases

- Track a country's GDP, inflation, or population over time
- Compare countries by life expectancy or emissions
- Rank countries by a development statistic
- Review the latest value within a selected year range

## FAQ

### Can I run it with my own inputs?

Yes. Change the inputs in Studio and press Run, or send new inputs from your code, or ask a connected AI assistant.

### Can I call this World Bank tool as an API?

Yes. Send a POST request to /v1/query with your Fous API key and the inputs, and get JSON back.

### How much does it cost?

Each completed run costs 1 credit. Failed runs without a completed receipt are free; completed work can remain charged if delivery is interrupted. With pay as you go, a credit costs 1¢. Monthly plans cost less per credit.

### Do I need a World Bank account?

No. You only need a Fous account.

### How current is the data?

Fous gets the data from data.worldbank.org when you run it. Some results are reused for up to 24 hours, and results that use your account or key are never reused. It was last verified on Sep 29, 2026.

### What was a country's GDP in a given year?

Get country statistic returns a country's GDP values by year; provide the country and statistic, and optionally a year range.

### How do countries rank by life expectancy?

Compare countries ranks countries by life expectancy; optionally provide a year or selected countries.

### What is the latest available value for a statistic?

Get country statistic returns the latest available value within the selected years.

## Related

- [IMF API](https://fous.com/tools/imf.md): IMF economic data provides country and regional forecasts with actual or forecast labels, and country rankings by World Economic Outlook indicators, excluding groups and missing values.
- [Our World in Data API](https://fous.com/tools/our-world-in-data.md): Research and data on global challenges and long-term trends.
- [World Health Organization API](https://fous.com/tools/world-health-organization.md): The World Health Organization provides public health information, latest outbreak reports, country health statistics with up to 10 years of history when available, and topic fact sheets.
- [Eurostat API](https://fous.com/tools/eurostat.md): Official European statistics from Eurostat.
- [Trading Economics API](https://fous.com/tools/trading-economics.md): Trading Economics provides economic indicators, market data and country statistics, including country overviews, latest reported country comparisons and current commodity prices reflecting reported trading days.
- [FIFA API](https://fous.com/tools/fifa.md): FIFA provides official men’s and women’s national-team rankings, excluding unranked teams, and year-specific tournament matches with scores, teams, stages and venues.
- [Wikipedia API](https://fous.com/tools/wikipedia.md): Wikipedia returns article summaries, images, facts, relevant search matches, readable text and daily historical events, plus human-view counts from July 2015 onward.
- [QS Top Universities API](https://fous.com/tools/qs-top-universities.md): QS Top Universities provides rankings and profiles with latest world ranks, student figures, up to five subject ranks and listed tuition; subject editions may differ.
- [All Data tools](https://fous.com/tools/category/data)
