# 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/workflows/world-bank
- Handle: `@world-bank`
- Category: [Data](https://fous.com/workflows/category/data)
- Source website: https://data.worldbank.org
- Last verified: Sep 29, 2026
- Fous is not affiliated with World Bank.

## Methods

### Compare countries

Operation `compare_countries`, version 1. 1 credit per call.

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 call.

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

Call the API with a Fous API key (`FOUS_API_KEY`). To create one, turn on Developer mode in Fous Studio, then open Keys & connections → API keys (https://app.fous.com/keys).

```bash
# First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
: "${FOUS_API_KEY:?Set FOUS_API_KEY before running this example}"

curl 'https://api.fous.com/v1/query' \
  --fail-with-body --silent --show-error --max-time 120 \
  -H "Authorization: Bearer $FOUS_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.
# First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
import json
import os
import urllib.error
import urllib.request

api_key = os.environ.get("FOUS_API_KEY")
if not api_key:
    raise RuntimeError("Set FOUS_API_KEY before running this example")

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=120) 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.
// First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
const apiKey = process.env.FOUS_API_KEY;
if (!apiKey) throw new Error("Set FOUS_API_KEY before running this example");

const response = await fetch("https://api.fous.com/v1/query", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  signal: AbortSignal.timeout(120_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);
```

Or describe the data in plain language: send `{"api":"@world-bank","prompt":"Describe the data you need, with every detail"}` to the same URL. Fous fills in the input, runs the method that fits and returns only the fields you asked for; `data.route.calls[].request` is the exact call it made. Routing is free; the run costs the same.

## 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

### Is Fous affiliated with World Bank?

No. Fous is not affiliated with World Bank. This workflow reads the public data.worldbank.org website and returns its data.

### How much does it cost?

Each run costs 1 credit. 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; repeating the same request within a day may return the saved result. Fous checks this workflow automatically; it last passed a check 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/workflows/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/workflows/our-world-in-data.md): Research and data on global challenges and long-term trends.
- [World Health Organization API](https://fous.com/workflows/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/workflows/eurostat.md): Official European statistics from Eurostat.
- [Trading Economics API](https://fous.com/workflows/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/workflows/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/workflows/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/workflows/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 workflows](https://fous.com/workflows/category/data)
