countries

location

Country geographic, demographic, and administrative information including ISO codes, capital city, region, population, area, languages, currency, and timezone. Used for country databases, internationalization, and geographic applications.

Request Builder

https://api.mockly.codes/countries?page=1&limit=10&count=10

Configure your request and click Send Request to see the response here.

Endpoints

GET/countries

Get a collection of countries

Alternative: /location/countries
GET/countries/:id

Get a single country by ID

Alternative: /location/countries/:id
GET/countries/meta

Get resource metadata and schema

Alternative: /location/countries/meta

How to Use Search

The search feature allows you to filter results by searching for text across all or specific fields. Choose between ?q= or ?search= parameter names.

1. Basic Search

Search across all text fields:

Basic Search
GET https://api.mockly.codes/countries?q=laptop

2. Search Specific Fields

Field-Specific Search
GET https://api.mockly.codes/countries?q=laptop&search_fields=name,description

Pro Tips

  • Search is case-insensitive and performs partial matching
  • Without search_fields, all text fields are searched
  • Combine with pagination to handle large result sets efficiently

Code Examples

JavaScript

Fetch Collection
// Get 10 countries
fetch('https://api.mockly.codes/countries?count=10')
  .then(res => res.json())
  .then(data => console.log(data));

Python

Fetch with Requests
import requests

response = requests.get(
    'https://api.mockly.codes/countries?count=10'
)
data = response.json()

cURL

Command Line
curl "https://api.mockly.codes/countries?count=10"

Bypass Cache

Get Fresh Data
fetch('https://api.mockly.codes/countries?nocache=true')

Schema Properties

idintegerrequired

Unique identifier for the country record

Gen:random_int
namestringrequired

Official name of the country

Gen:country
codestringrequired

ISO 3166-1 alpha-2 two-letter country code (e.g., US, GB, FR, DE)

Gen:country_code
code3string

ISO 3166-1 alpha-3 three-letter country code (e.g., USA, GBR, FRA, DEU)

Gen:country_code3
capitalstring

Name of the capital city of the country

Gen:capital
regionstring

Geographic region or continent (e.g., Europe, Asia, Americas, Africa)

Gen:region
subregionstring

Geographic subregion (e.g., Western Europe, South Asia, North America)

Gen:subregion
populationinteger

Total population of the country

Gen:population
areanumber

Total land area in square kilometers

Gen:area
languagesarray

Array of official languages spoken in the country

Gen:languages_array
currencystring

ISO 4217 currency code used in the country (e.g., USD, EUR, GBP)

Gen:currency_code
calling_codestring

International phone calling code (e.g., +1, +44, +33)

Gen:calling_code
timezonestring

Primary IANA timezone identifier for the country

Gen:timezone
flagstring

URL to the country's flag image

Gen:flag_urluri

Query Parameters

countinteger

Number of items to return (default: 10, max: 100)

seedinteger

Seed for reproducible data generation

nocacheboolean

Bypass cache and generate fresh data on every request