API Directory › 📚 Data, Text & Words › REST Countries (data)
No authHTTPSCORS

REST Countries (data) API

Cross-listed: rich structured data about every country.

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

What it does

REST Countries is a free, key-less API of reference data for every country — names and ISO codes, calling codes, currencies, languages, capitals, regions, flags, timezones and population. This is the data you need to build country dropdowns, phone-number inputs, currency selectors and localisation defaults.

Base URL

https://restcountries.com/v3.1

Authentication

None. Endpoints: /all?fields=… (the fields parameter is now required on /all), /name/{name}, /alpha/{code}, /currency/{code}, /lang/{language}.

Code examples

curl (country picker data)
curl -s "https://restcountries.com/v3.1/all?fields=name,cca2,idd,flags,currencies"
JavaScript (build a <select>)
const rows = await fetch(
  "https://restcountries.com/v3.1/all?fields=name,cca2"
).then(r => r.json());
rows.sort((a, b) => a.name.common.localeCompare(b.name.common));
select.innerHTML = rows.map(c =>
  `<option value="${c.cca2}">${c.name.common}</option>`).join("");

Rate limits & quotas

No formal rate limit on the community-hosted service, but be a good citizen: fetch once at build time or cache for a long TTL — country data changes maybe once or twice a year. Always pass ?fields= to keep the payload small. The project is open source and self-hostable.

Key response fields

name.common / name.officialDisplay name and formal name
cca2 / cca3 / ccn3ISO 3166 alpha-2, alpha-3 and numeric codes
idd.root + idd.suffixes[]International dialing code (e.g. + 234)
currenciesKeyed by ISO 4217 code, each with name and symbol
languages / flags.svg / flags.png / timezones[]For localisation and display

Common errors

400 on /allYou omitted the mandatory ?fields= parameter.
404No country matched a /name/ lookup — use /alpha/ with an ISO code, or add fullText=true.
(v2 shape)v2 is retired — v3.1 nests data (name.common, currency/language objects).

When to use it (and alternatives)

The go-to for form and localisation data: country <select> menus, dial-code pickers, currency and language defaults, flag icons. For the geographic/mapping angle (coordinates, borders, area) see the same API documented under geo › REST Countries; for live IP→country detection, country.is.

FAQ

How do I build a phone-number country code list?

Request fields=name,cca2,idd. The dialing code is idd.root + one of idd.suffixes (some countries like the US/Canada share +1 with multiple suffixes).

Why does /all fail now?

REST Countries made ?fields= mandatory on /all to reduce bandwidth. List the fields you need explicitly.

Should I call this on every page load?

No — fetch it once (build step or a daily cache) and serve it as a static asset. The data is effectively constant.

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.

Word CounterJSON Formatter

Related Data, Text & Words APIs

← Back

More Data, Text & Words APIs · All 196 APIs