REST Countries

Data API · All 250+ countries · Flags, currencies, languages · Public domain data

TL;DR

REST Countries provides detailed information about every country in the world — flags (SVG/PNG), currencies, languages, capital cities, population, area, bordering countries, timezones, calling codes, and regional groupings. Data is sourced from public domain datasets and is updated regularly. Perfect for country dropdowns, flag displays, travel apps, and geographic reference tools.

Quick start: https://restcountries.com/v3.1/name/usa

No API key needed — just make a request!

How to Use This API

1. Search by Country Name

https://restcountries.com/v3.1/name/usa

Returns US data: capital (Washington DC), population, area, currency (USD), languages (English), flag SVG URL, timezones, and more. Also works for "United States" or "America".

2. Search by Country Code

https://restcountries.com/v3.1/alpha/DE

ISO 3166-1 alpha-2 codes. Multiple codes: alpha?codes=DE,FR,IT.

3. Get All Countries

https://restcountries.com/v3.1/all

All 250+ countries. Use ?fields=name,capital,population,flags to limit response size.

4. Filter by Region

https://restcountries.com/v3.1/region/europe

Regions: Africa, Americas, Asia, Europe, Oceania, Antarctic.

5. JavaScript — Country Display Cards

async function getCountry(name) {
  const resp = await fetch(
    `https://restcountries.com/v3.1/name/${name}`
  );
  const [country] = await resp.json();
  return {
    name: country.name.common,
    official: country.name.official,
    capital: country.capital?.[0],
    population: country.population,
    area: country.area,
    flag: country.flags.svg,
    currency: Object.values(country.currencies || {})
      .map(c => `${c.name} (${c.symbol})`).join(', '),
    languages: Object.values(country.languages || {}).join(', ')
  };
}

getCountry('japan').then(jp => {
  console.log(`${jp.name} — Capital: ${jp.capital}`);
  console.log(`Population: ${(jp.population/1e6).toFixed(1)}M`);
  console.log(`Currency: ${jp.currency}`);
});

6. Python — Find Bordering Countries

import requests

def get_with_borders(country_name):
    resp = requests.get(
        f'https://restcountries.com/v3.1/name/{country_name}'
    )
    main = resp.json()[0]
    borders = main.get('borders', [])
    
    if borders:
        border_resp = requests.get(
            'https://restcountries.com/v3.1/alpha',
            params={'codes': borders.join(',')}
        )
        border_names = [c['name']['common']
                       for c in border_resp.json()]
    else:
        border_names = []
    
    return main['name']['common'], border_names

country, borders = get_with_borders('france')
print(f"{country} borders: {', '.join(borders) if borders else 'None'}")
Try searching USA: https://restcountries.com/v3.1/name/usa

Frequently Asked Questions

What fields does each country response include?
Over 40 fields: name (common, official, native), tld, cca2/ccn3/cca3/cioc codes, independent status, unMember status, currencies, capital, alt spellings, region, subregion, languages, translations, latlng, landlocked status, borders, area, demonyms, flag URLs (SVG/PNG), maps (Google/OpenStreetMap), population, fifa code, car signs, timezones, continents, flags, coat of arms, start of week, postal code format.
How accurate and up-to-date is the data?
Data is sourced from public domain datasets including UN, World Bank, and national statistics. Updates are made periodically as countries change (name changes, new capitals, population updates).
Are there any query limits?
No documented rate limits. REST Countries is a free, public service. For high-volume production use, consider downloading the dataset or caching responses.
Can I filter by language?
Yes! /v3.1/lang/spanish returns all Spanish-speaking countries. The language parameter is the common English name.
Does it include dependent territories?
Yes, the API includes all UN member states plus dependent territories, overseas departments, and special sovereign entities — about 250 total.
How do I get country flags?
The flags object has png and svg URLs. The coatOfArms object also has SVG/PNG URLs for coat of arms images.

API Details

API URL
https://restcountries.com/v3.1
Documentation
restcountries.com
Category
Data
Authentication
Not Required
Geographic Coverage
Global — all 250+ countries and territories

What You Can Build