# Country Statistics API
> Geographic, demographic and political statistics for every country as an API — the reference a research dashboard, data-journalism piece or analytics tool needs. For each country: its government type, whether it is landlocked, surface area (km²), population, population density (people/km²) and life expectancy (years), enriched with the ISO 3166-1 alpha-2 code and flag emoji. Look a country up by name or code, or RANK every country by any numeric statistic — the ten largest by area, the most densely populated, the highest life expectancy — in ascending or descending order. Search by name or government type, or list them all. This is the country statistics reference — distinct from countries-api (ISO identifiers: codes, dialing, currency, region) and disease-api (public-health data). Served from memory — always fast.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/countrystats-api/..."
```

## Pricing
- **Free** (Free) — 18,000 calls/Mo, 3 req/s
- **Starter** ($7/Mo) — 200,000 calls/Mo, 10 req/s
- **Pro** ($22/Mo) — 1,000,000 calls/Mo, 25 req/s
- **Mega** ($54/Mo) — 5,000,000 calls/Mo, 60 req/s

## Endpoints

### Lookup

#### `GET /v1/country` — All statistics for a country

**Parameters:**
- `country` (query, optional, string) — Country name Example: `Germany`
- `code` (query, optional, string) — ISO 3166-1 alpha-2 code Example: `de`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/countrystats-api/v1/country?country=Germany&code=de"
```

**Response:**
```json
{
    "data": {
        "country": {
            "code": "DE",
            "emoji": "🇩🇪",
            "country": "Germany",
            "area_km2": 357022,
            "government": "Federal Republic",
            "landlocked": false,
            "population": 82905782,
            "life_expectancy": 77.4,
            "population_density": 237.4
        }
    },
    "meta": {
        "timestamp": "2026-06-08T18:25:08.432Z",
        "request_id": "ebe015b1-cecf-4524-ad2a-01f187bd372b"
    },
    "status": "ok",
    "message": "Country statistics retrieved successfully",
    "success": true
}
```

### Rank

#### `GET /v1/rank` — Rank countries by a numeric metric

**Parameters:**
- `by` (query, required, string) — population, area_km2, population_density or life_expectancy Example: `population`
- `order` (query, optional, string) — desc or asc Example: `desc`
- `limit` (query, optional, string) — How many (1-250) Example: `10`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/countrystats-api/v1/rank?by=population&order=desc&limit=10"
```

**Response:**
```json
{
    "data": {
        "count": 10,
        "order": "desc",
        "metric": "population",
        "ranking": [
            {
                "code": "CN",
                "rank": 1,
                "emoji": "🇨🇳",
                "value": 1392730000,
                "country": "China",
                "area_km2": 9572900,
                "government": "People's Republic",
                "landlocked": false,
                "population": 1392730000,
                "life_expectancy": 71.4,
                "population_density": 148.3
            },
            {
                "code": "IN",
                "rank": 2,
                "emoji": "🇮🇳",
                "value": 1352617328,
                "country": "India",
                "area_km2": 3287263,
                "government": "Federal Republic",
                "landlocked": false,
                "population": 1352617328,
                "life_expectancy": 62.5,
                "population_density": 454.9
            },
            {
                "code": "US",
                "rank": 3,
                "emoji": "🇺🇸",
                "value": 326687501,
                "country": "United States",
                "area_km2": 9363520,
                "government": "Federal Republic",
                "landlocked": false,
                "population": 326687501,
                "life_expectancy": 77.1,
                "population_density": 35.8
            },
            {
                "code": 
…(truncated, see openapi.json for full schema)
```

### Search

#### `GET /v1/search` — Search by name or government type

**Parameters:**
- `q` (query, required, string) — Search query (min 2 chars) Example: `republic`
- `limit` (query, optional, string) — Max results (1-100) Example: `25`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/countrystats-api/v1/search?q=republic&limit=25"
```

**Response:**
```json
{
    "data": {
        "count": 25,
        "query": "republic",
        "total": 146,
        "countries": [
            {
                "code": "AL",
                "emoji": "🇦🇱",
                "country": "Albania",
                "area_km2": 28748,
                "government": "Republic",
                "landlocked": false,
                "population": 2866376,
                "life_expectancy": 71.6,
                "population_density": 104.6
            },
            {
                "code": "DZ",
                "emoji": "🇩🇿",
                "country": "Algeria",
                "area_km2": 2381741,
                "government": "Republic",
                "landlocked": false,
                "population": 42228429,
                "life_expectancy": 69.7,
                "population_density": 17.7
            },
            {
                "code": "AO",
                "emoji": "🇦🇴",
                "country": "Angola",
                "area_km2": 1246700,
                "government": "Republic",
                "landlocked": false,
                "population": 30809762,
                "life_expectancy": 38.3,
                "population_density": 24.7
            },
            {
                "code": "AR",
                "emoji": "🇦🇷",
                "country": "Argentina",
                "area_km2": 2780400,
                "government": "Federal Republic",
                "landlocked": false,
                "populati
…(truncated, see openapi.json for full schema)
```

### List

#### `GET /v1/list` — List countries

**Parameters:**
- `limit` (query, optional, string) — Page size (1-300) Example: `50`
- `offset` (query, optional, string) — Offset Example: `0`
- `landlocked` (query, optional, string) — Filter landlocked countries Example: `true`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/countrystats-api/v1/list?limit=50&offset=0&landlocked=true"
```

**Response:**
```json
{
    "data": {
        "count": 43,
        "total": 43,
        "countries": [
            {
                "code": "AF",
                "emoji": "🇦🇫",
                "country": "Afghanistan",
                "area_km2": 652090,
                "government": "Islamic Emirate",
                "landlocked": true,
                "population": 37172386,
                "life_expectancy": 45.9,
                "population_density": 56.9
            },
            {
                "code": "AD",
                "emoji": "🇦🇩",
                "country": "Andorra",
                "area_km2": 468,
                "government": "Parliamentary Coprincipality",
                "landlocked": true,
                "population": 77006,
                "life_expectancy": 83.5,
                "population_density": 163.8
            },
            {
                "code": "AM",
                "emoji": "🇦🇲",
                "country": "Armenia",
                "area_km2": 29800,
                "government": "Republic",
                "landlocked": true,
                "population": 2951776,
                "life_expectancy": 66.4,
                "population_density": 103.7
            },
            {
                "code": "AT",
                "emoji": "🇦🇹",
                "country": "Austria",
                "area_km2": 83859,
                "government": "Federal Republic",
                "landlocked": true,
                "population": 8840521,
…(truncated, see openapi.json for full schema)
```

### Meta

#### `GET /v1/meta` — Service metadata

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/countrystats-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "service": "countrystats-api",
        "endpoints": {
            "GET /v1/list": "List countries (limit, offset, landlocked=true to filter).",
            "GET /v1/meta": "This document.",
            "GET /v1/rank": "Rank countries by a metric (by=population|area_km2|population_density|life_expectancy, order=desc|asc, limit).",
            "GET /v1/search": "Search by country name or government type (q=).",
            "GET /v1/country": "All statistics for a country (country=, e.g. Germany — or code=, e.g. de)."
        },
        "description": "Country statistics: government type, landlocked flag, surface area (km²), population, population density and life expectancy, enriched with ISO 3166-1 alpha-2 code and flag emoji. Look up by country or code, rank by any numeric metric, search or list. Distinct from countries-api (ISO identifiers) and disease-api (health). No key.",
        "total_countries": 250,
        "rankable_metrics": [
            "population",
            "area_km2",
            "population_density",
            "life_expectancy"
        ],
        "landlocked_countries": 43
    },
    "meta": {
        "timestamp": "2026-06-08T18:25:08.844Z",
        "request_id": "ecfe2253-d3a7-4bba-b28f-976ca5151353"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/countrystats-api
OpenAPI spec: https://www.oanor.com/api/countrystats-api/openapi.json
