REST Countries API

⭐ Beginner's Pick Geocoding / No Auth Required Beginner HTTPS CORS
Free to Use Varies (check documentation)

Overview

REST Countries is a free API that provides detailed information about every country in the world, including population, capital, currencies, languages, flags, and bordering countries. No API key is needed, and you can filter results by country name, code, region, or language. It is one of the most beginner-friendly and practical geography APIs available.

💡

Beginner Tip

Use the /name/{country} endpoint for easy lookups by name, and add ?fields=name,capital,population to limit the response to only the fields you need, keeping responses fast and clean.

Available Data

country name and code
population
capital city
region and subregion
flag image URL

Example Response

JSON Response
{
  "name": "Japan",
  "capital": "Tokyo",
  "population": 125800000,
  "region": "Asia",
  "languages": [
    "Japanese"
  ],
  "flag": "https://flagcdn.com/jp.svg",
  "currencies": [
    {
      "code": "JPY",
      "name": "Japanese yen"
    }
  ]
}

Field Reference

name Country name with common and official variants, plus native language names.
capital List of capital city names (some countries have multiple capitals).
population Total population of the country.
region Broad geographic region such as Asia, Europe, or Africa.
currencies Object keyed by ISO currency code with name and symbol for each currency.
flags URLs to the country flag image in PNG and SVG formats.

Implementation Example

const url = "https://restcountries.com/";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

404 Not Found The country name or code was misspelled or not recognized.
Try using the ISO 3166-1 alpha-2 or alpha-3 country code (e.g., US or USA) via /alpha/{code} for more reliable lookups.
Very large response payload Fetching all countries returns a large JSON array with many fields per country.
Use the ?fields= query parameter to specify only the fields you need, e.g., ?fields=name,population,capital.
Unexpected data structure for currencies or languages These fields are objects with ISO codes as keys, not plain arrays.
Access currency info with Object.values(country.currencies) in JavaScript or iterate over the object keys in Python.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 15/20
🔒 Security 15/15
🛠 Developer XP 20/20
✓ Reliability 7/15
Response Time 206ms

Fully tested on Apr 5, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS YES
Category Geocoding
Difficulty Beginner
Verified: 2026-04-04

Similar APIs

View All →