Compare countries
compare_countriesUse this when the user asks to compare or rank countries on one statistic, such as "compare GDP per capita for Germany, France and Italy" or "rank the Nordic countries by life expectancy". Pass 2 to 6 countries (names or ISO codes), the indicator, and optionally a year and an order. Returns the countries ranked with each value and year, any country without data, the source and the date it was last updated. Expand a group such as Nordic or G7 into its countries first; groups themselves are not accepted.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | No | A specific calendar year; leave out for the latest year with data | |
| order | No | desc ranks the highest value first (default), asc the lowest first | |
| countries | Yes | Between 2 and 6 countries; a country named twice counts once | |
| indicator | Yes | population, gdp, gdp_per_capita, gdp_growth, inflation, unemployment, life_expectancy and the other listed series |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| as_of | Yes | ISO 8601 time the data was published by its source or fetched from it. A cached answer keeps the time of its fetch. | |
| order | Yes | ||
| notice | Yes | ||
| source | Yes | Who the data comes from, to cite and to check it against. | |
| status | Yes | ||
| message | No | ||
| no_data | Yes | ||
| ranking | Yes | ||
| indicator | Yes | ||
| same_year | Yes |