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

- Page: https://fous.com/methods/worldbank.org/compare-countries
- Method: `worldbank.org/compare_countries`, version 1
- Website: worldbank.org
- Returns: statistic name, unit, year, indicator code, ranked countries with values and chart links
- Effect: read (it gets data and changes nothing)
- Sign-in: none needed
- Cost: 1 credit per completed run (1¢ with pay as you go); failed runs are free
- Verified: Nov 2, 2026

## Inputs

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

## Output

From a run on Oct 23, 2026. Its input:

```json
{
  "countries": "United States, Canada",
  "statistic": "infant mortality"
}
```

Its output:

```json
{
  "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)"
}
```

## Run it

From code, with a Fous API key in `FOUS_API_KEY`; the answer's `data` holds the output:

```bash
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"}}'
```

From an AI agent connected to the Fous MCP server: its `run` with the same method and input. To connect one, give it `set up https://fous.com/SKILL.md`.

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

## 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."
    },
    "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

```json
{
  "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."
    }
  }
}
```

## See more

- [World Bank API: Get country statistic](https://fous.com/methods/data.worldbank.org/get-country-statistic.md): Looks up a World Bank statistic for a country and returns its annual values and latest value for the selected years.
- [IMF API: List country rankings](https://fous.com/methods/imf.org/list-country-rankings.md): Ranks countries by a World Economic Outlook indicator for a chosen year, excluding regional and group totals and countries without a value.
- [Our World in Data API: Get statistic](https://fous.com/methods/ourworldindata.org/get-statistic.md): Finds the Our World in Data chart that best matches a statistic and returns its country-by-year numeric values, definition and source.
- [Trading Economics API: List countries by indicator](https://fous.com/methods/tradingeconomics.com/list-countries-by-indicator.md): Compares 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.
- [World Health Organization API: Get country health statistics](https://fous.com/methods/who.int/get-country-health-statistics.md): Gets 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.
- [Premier League API: List top players by stat](https://fous.com/methods/premierleague.com/list-top-scorers.md): Ranks Premier League players for a season by goals, assists or goalkeeper clean sheets, with each player's club and nationality.
- [CompaniesMarketCap API: List largest companies](https://fous.com/methods/companiesmarketcap.com/list-largest-companies.md): Ranks 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.
- [European Union API: Get Eurostat statistic for a country](https://fous.com/methods/ec.europa.eu/get-statistic.md): Looks 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.
- [All World Bank methods](https://fous.com/methods/worldbank.org.md)
