Countries API

ISO 3166 country and subdivision lookup

Access a complete, standards-compliant dataset of countries, territories, and their subdivisions. Supports alpha-2, alpha-3, and numeric codes with UN M.49 geographic classification.

Full ISO 3166 Coverage

Complete ISO 3166-1 (countries) and ISO 3166-2 (subdivisions) datasets including states, provinces, regions, departments, and more.

Multiple Code Formats

Look up countries by alpha-2 (US), alpha-3 (USA), or numeric (840) codes. All three formats are accepted interchangeably.

Geographic Classification

Filter countries by UN M.49 region, sub-region, and intermediate region for geographic analysis and reporting.

Batch Validation

Validate multiple country or subdivision codes in a single request. Get detailed results with matching country names and error details.

Use Cases

Built for real-world scenarios

Quick Start

Start using this API in seconds

# Look up a country with its subdivisions
$ curl https://api.apicrate.io/api/v1/countries/US \
  -H "X-API-Key: YOUR_API_KEY"

# Response (truncated)
{
  "status": "ok",
  "data": {
    "name": "United States of America",
    "alpha_2": "US",
    "alpha_3": "USA",
    "numeric": "840",
    "region": "Americas",
    "sub_region": "Northern America",
    "subdivisions": [
      {"code": "US-CA", "name": "California", "type": "state"},
      {"code": "US-NY", "name": "New York", "type": "state"}
    ]
  }
}
import requests

# Search countries by region
response = requests.get(
    "https://api.apicrate.io/api/v1/countries",
    headers={"X-API-Key": "YOUR_API_KEY"},
    params={"region": "Europe", "fields": "name,alpha_2"},
)

for country in response.json()["data"]:
    print(f"{country['alpha_2']}: {country['name']}")
// Validate a batch of country codes
const res = await fetch("https://api.apicrate.io/api/v1/countries/validate", {
  method: "POST",
  headers: {
    "X-API-Key": "YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ codes: ["US", "GB", "XX", "DE"] }),
});

const { data } = await res.json();
// data.results: [{code: "US", valid: true, name: "United States"}, ...]
Endpoints

Available endpoints

GET /api/v1/countries List countries
GET /api/v1/countries/{code} Get a country by code
GET /api/v1/countries/{code}/subdivisions List subdivisions of a country
GET /api/v1/subdivisions/{code} Get a subdivision by code
POST /api/v1/countries/validate Validate country codes (batch)
POST /api/v1/subdivisions/validate Validate subdivision codes (batch)
FAQ

Frequently asked questions

How many countries are in the dataset?

The dataset includes all 249 ISO 3166-1 countries and territories, with over 5,000 ISO 3166-2 subdivisions.

Can I search countries by name?

Yes. Use the q query parameter on the /api/v1/countries endpoint to perform free-text search across country names.

What subdivision types are supported?

The API covers all ISO 3166-2 subdivision types including states, provinces, regions, departments, districts, parishes, and more.

How often is the data updated?

The definitions database is updated regularly. Check the X-Definitions-Updated response header for the latest update date.

Ready to start building?

Create a free account and start making requests in under a minute.

Sign Up Free → View Documentation