# List countries

`GET /v1/data/countries`

Free during preview · test keys only

List the 249 ISO 3166-1 countries and territories in stable alpha-2 order. Free during preview; scoped test keys must allow data.countries. No balance or payment is required.

Pagination: limit defaults to 50 (1–250). When has_more is true, pass next_cursor unchanged as cursor, keeping the same filters. Cursors are opaque, not offsets; they mark an exclusive alpha-2 boundary. A valid cursor remains a boundary even if filters change. The final or empty page has has_more false and next_cursor null. Filters combine with AND; codes selects any listed code.

English display names, code mappings, regions and currencies come from Unicode CLDR JSON 48.2.1 (CLDR 48.2), Unicode License v3. Currency arrays contain legal tender on 2026-10-14, not historical or non-tender entries, and may be empty. Region/subregion follow CLDR containment, including Antarctica under Oceania / Outlying Oceania. Flags are Unicode regional-indicator pairs. Official names and calling codes are omitted because they are not sourced here. XK (Kosovo), AC, CP, CQ, DG, EA, IC and TA, macroregions, deprecated and other user-assigned codes are excluded.

## Parameters

| Parameter | In | Type | Required | Default | Description |
| --- | --- | --- | --- | --- | --- |
| limit | query | integer | no | 50 | Maximum items per page, an integer from 1 to 250. Default 50. |
| cursor | query | string | no | — | Opaque next_cursor from a previous page. Omit on the first page; do not decode, construct or increment it. |
| region | query | string | no | — | UN M49 continent, region or subregion: CLDR English name (case- and accent-insensitive) or three-digit code, e.g. Americas / 019 or Northern America / 021. Includes 003 (North America), 202 (Sub-Saharan Africa) and 419 (Latin America). Not EU/EZ/UN political groupings. |
| currency | query | string | no | — | ISO 4217 code recognized by the CLDR snapshot, case-insensitive, e.g. CAD. Recognized historical/non-tender codes such as BGN or XAU return an empty list when no country uses them on the snapshot date. Unknown codes and CLDR's non-ISO CNH alias are invalid. |
| q | query | string | no | — | Nonempty case- and accent-insensitive English name, alpha-2, alpha-3 or numeric code prefix, e.g. COTE matches Côte d’Ivoire. Not a substring search. |
| codes | query | string | no | — | Comma-separated ISO 3166-1 alpha-2 codes. Case-insensitive; whitespace around each code and duplicates are accepted. Unknown/non-ISO codes are invalid. Results still use alpha-2 order. |

## Examples

### curl

```sh
curl --request GET 'https://api.butter.pub/v1/data/countries?limit=1&codes=CA%2CUS' \
  --header "Authorization: Bearer $APIBUTTER_TEST_KEY"
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken($key)
    ->get('https://api.butter.pub/v1/data/countries', ['limit' => 1, 'codes' => 'CA,US']);

$result = $response->throw()->json();
```

### JavaScript

```js
const url = new URL('https://api.butter.pub/v1/data/countries');
url.search = new URLSearchParams({
    "limit": 1,
    "codes": "CA,US"
}).toString();

const response = await fetch(url, {
  method: 'GET',
  headers: { Authorization: `Bearer ${key}` },
});
if (!response.ok) throw await response.json();
const result = await response.json();
```

## MCP equivalent

Call `data_countries` at https://mcp.butter.pub/mcp.

```json
{
    "name": "data_countries",
    "arguments": {
        "limit": 1,
        "codes": "CA,US"
    }
}
```

## Responses

### 200 · application/json

A country list, including empty results. The next cursor is present only when another page exists. Nothing is charged.

First page: codes=CA,US&limit=1

```json
{
    "object": "list",
    "data": [
        {
            "object": "country",
            "id": "CA",
            "alpha2": "CA",
            "alpha3": "CAN",
            "numeric": "124",
            "name": "Canada",
            "region": "Americas",
            "subregion": "Northern America",
            "currencies": [
                "CAD"
            ],
            "flag": "🇨🇦"
        }
    ],
    "has_more": true,
    "next_cursor": "Q0E="
}
```

Next page: same filters, cursor=Q0E=

```json
{
    "object": "list",
    "data": [
        {
            "object": "country",
            "id": "US",
            "alpha2": "US",
            "alpha3": "USA",
            "numeric": "840",
            "name": "United States",
            "region": "Americas",
            "subregion": "Northern America",
            "currencies": [
                "USD"
            ],
            "flag": "🇺🇸"
        }
    ],
    "has_more": false,
    "next_cursor": null
}
```

No matches: q=Atlantis

```json
{
    "object": "list",
    "data": [],
    "has_more": false,
    "next_cursor": null
}
```

### 401 · application/problem+json

Missing, invalid or revoked bearer key.

unauthorized

```json
{
    "type": "https://apibutter.com/docs/errors/unauthorized",
    "title": "Unauthorized",
    "status": 401,
    "detail": "A valid, unrevoked bearer API key is required.",
    "code": "unauthorized",
    "param": null,
    "errors": null,
    "request_id": "req_01jbz8c6m3x4v9t2q7w5n8r0ka"
}
```

### 403 · application/problem+json

Live keys are refused; scoped test keys must allow data.countries.

test_keys_only

```json
{
    "type": "https://apibutter.com/docs/errors/test_keys_only",
    "title": "Forbidden",
    "status": 403,
    "detail": "This operation is free during preview and accepts abk_test_ keys only.",
    "code": "test_keys_only",
    "param": null,
    "errors": null,
    "request_id": "req_01jbz8c6m3x4v9t2q7w5n8r0ka"
}
```

forbidden

```json
{
    "type": "https://apibutter.com/docs/errors/forbidden",
    "title": "Forbidden",
    "status": 403,
    "detail": "The API key does not allow this operation.",
    "code": "forbidden",
    "param": null,
    "errors": null,
    "request_id": "req_01jbz8c6m3x4v9t2q7w5n8r0ka"
}
```

### 422 · application/problem+json

An invalid filter, limit or cursor. The detail names the parameter to correct.

invalid_parameter

```json
{
    "type": "https://apibutter.com/docs/errors/invalid_parameter",
    "title": "Unprocessable Content",
    "status": 422,
    "detail": "The limit parameter must be an integer from 1 to 250.",
    "code": "invalid_parameter",
    "param": "limit",
    "errors": {
        "limit": [
            "The limit parameter must be an integer from 1 to 250."
        ]
    },
    "request_id": "req_01jbz8c6m3x4v9t2q7w5n8r0ka"
}
```

## Errors

| Code | Status | Meaning |
| --- | --- | --- |
| unauthorized | 401 | A valid, unrevoked bearer API key is required. |
| test_keys_only | 403 | This operation is free during preview and accepts abk_test_ keys only. |
| forbidden | 403 | The API key does not allow this operation. |
| invalid_parameter | 422 | The limit parameter must be an integer from 1 to 250. |
