API Directory › 🌍 Geo & Location › REST Countries
No authHTTPSCORS

REST Countries API

Free info about every country — flags, capitals, currencies, languages and more.

Auth
No auth needed
HTTPS
Yes
CORS
Yes
Open REST Countries docs ↗

What it does

REST Countries returns reference data about the world’s countries — names, capitals, region and subregion, population, area, borders, currencies, languages, calling codes, timezones, coordinates and flag images — from a single free endpoint. No key.

Base URL

https://restcountries.com/v3.1

Authentication

None. Free and key-less. Note the /all endpoint now requires a ?fields= parameter — you must name the fields you want or the request is rejected.

Code examples

curl
curl -s "https://restcountries.com/v3.1/name/nigeria?fields=name,capital,currencies,population"
curl -s "https://restcountries.com/v3.1/all?fields=name,cca2,flags,region"
JavaScript
const res = await fetch(
  "https://restcountries.com/v3.1/alpha/de?fields=name,capital,currencies,languages"
);
const [de] = await res.json();
console.log(de.capital[0], Object.keys(de.currencies), Object.values(de.languages));

Rate limits & quotas

No formal rate limit on the hosted service, but it is community-run — cache responses (country data barely changes) and always send ?fields= to keep payloads small. The project is open source and can be self-hosted.

Key response fields

name.common / name.officialShort and formal country name
cca2 / cca3ISO 3166 alpha-2 and alpha-3 codes
capital[]Capital city (array)
currenciesObject keyed by currency code, each with name and symbol
languages / flags.svg / latlng / bordersLanguages, flag URL, coordinates, neighbours

Common errors

400 (on /all)You omitted the required ?fields= parameter.
404No country matched the name or code — try fullText=true or an ISO code.
(shape change)v2 is retired; use v3.1 and expect nested objects (name.common, not name).

When to use it (and alternatives)

The go-to for country dropdowns, phone-code pickers, currency and flag lookups, and geography quizzes. For live IP-based country detection use country.is; for place-name search use GeoNames.

FAQ

Why does /all return a 400 now?

To cut bandwidth, REST Countries made ?fields= mandatory on /all. List the fields you actually need, e.g. /all?fields=name,cca2,flags.

How do I get a country by its 2-letter code?

/v3.1/alpha/{code} — e.g. /alpha/us. It also accepts alpha-3 and numeric codes, and a comma list for several at once.

The response structure looks different from tutorials.

Older tutorials use v2. In v3.1 many fields are nested: the common name is name.common, currencies and languages are objects keyed by code, and capital is an array.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

IP LookupDNS Lookup

Related Geo & Location APIs

← Back

More Geo & Location APIs · All 196 APIs