Countries
Ce contenu n’est pas encore disponible dans votre langue.
Overview
Section titled “Overview”The Countries resource provides fake country data with names, codes, capitals, currencies, languages, and geographic information.
Endpoints
Section titled “Endpoints”| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/countries | List all countries |
| GET | /v1/countries/:id | Get a specific country |
| GET | /v1/countries/:id/cities | Get country's cities |
Country Object
Section titled “Country Object”{ "id": 1, "name": "United States", "code": "US", "slug": "united-states", "capital": "Washington, D.C.", "currency": "USD", "language": "English", "population": 331002651, "area": 9833520, "timezone": "America/New_York", "flag": "https://example.com/flags/us.png", "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-01-15T10:30:00.000Z"}| Field | Type | Description |
|---|---|---|
id |
number |
Unique identifier |
name |
string |
Country name |
code |
string |
ISO country code (e.g. US) |
slug |
string |
URL-friendly unique slug |
capital |
string |
Capital city name |
currency |
string |
Currency code (e.g. USD) |
language |
string |
Primary language |
population |
number |
Population count |
area |
number |
Area in square kilometers |
timezone |
string |
Primary timezone |
flag |
string |
Flag image URL |
createdAt |
string |
ISO 8601 timestamp |
updatedAt |
string |
ISO 8601 timestamp |
List Countries
Section titled “List Countries”curl https://api.phantomjson.app/v1/countriesQuery Parameters
Section titled “Query Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
page |
number |
1 |
Page number |
limit |
number |
20 |
Items per page (max: 100) |
sort |
string |
— | Sort field and direction |
q |
string |
— | Search query |
fields |
string |
— | Fields to return |
code |
string |
— | Filter by country code |
currency |
string |
— | Filter by currency code |
language |
string |
— | Filter by language |
Response
Section titled “Response”{ "data": [ { "id": 1, "name": "United States", "code": "US", "slug": "united-states", "capital": "Washington, D.C.", "currency": "USD" } ], "meta": { "total": 50, "page": 1, "limit": 20, "totalPages": 3 }}Get Country by ID
Section titled “Get Country by ID”curl https://api.phantomjson.app/v1/countries/1Response
Section titled “Response”{ "data": { "id": 1, "name": "United States", "code": "US", "slug": "united-states", "capital": "Washington, D.C.", "currency": "USD", "language": "English", "population": 331002651, "area": 9833520, "timezone": "America/New_York" }}Get Country’s Cities
Section titled “Get Country’s Cities”curl https://api.phantomjson.app/v1/countries/1/citiesResponse
Section titled “Response”{ "data": [ { "id": 1, "countryId": 1, "name": "New York", "slug": "new-york", "population": 8336817 } ], "meta": { "total": 10, "page": 1, "limit": 20, "totalPages": 1 }}Examples
Section titled “Examples”Search Countries
Section titled “Search Countries”curl "https://api.phantomjson.app/v1/countries?q=united"Filter by Code
Section titled “Filter by Code”curl "https://api.phantomjson.app/v1/countries?code=US"Filter by Currency
Section titled “Filter by Currency”curl "https://api.phantomjson.app/v1/countries?currency=EUR"Filter by Language
Section titled “Filter by Language”curl "https://api.phantomjson.app/v1/countries?language=Spanish"Sort by Population
Section titled “Sort by Population”# Smallest firstcurl "https://api.phantomjson.app/v1/countries?sort=population:asc"
# Largest firstcurl "https://api.phantomjson.app/v1/countries?sort=population:desc"Field Selection
Section titled “Field Selection”curl "https://api.phantomjson.app/v1/countries?fields=id,name,capital,currency"Relations
Section titled “Relations”- Cities — Each country has many cities (access via
/v1/countries/:id/cities) - Airlines — Each country may have many airlines
