A free REST API for country data - perfect for testing, demos, prototypes, and learning.
Get comprehensive information about all 195 countries including names, capitals, populations, currencies, languages, flags, and more. No authentication required, CORS enabled, and powered by Cloudflare Workers for blazing-fast global performance.
Live API: https://countries-api.davegarvey.workers.dev
# Get all countries
curl https://countries-api.davegarvey.workers.dev/countries
# Get a specific country
curl https://countries-api.davegarvey.workers.dev/countries/US
# Get a random country (great for testing!)
curl https://countries-api.davegarvey.workers.dev/countries/random
# Filter by region
curl https://countries-api.davegarvey.workers.dev/countries?region=Europe
# Search for countries
curl https://countries-api.davegarvey.workers.dev/search?q=island- 195 Countries - Complete dataset with all recognized countries
- Rich Data - Names, capitals, populations, currencies, languages, flags, calling codes
- Flexible Filtering - By region, subregion, currency, language
- No Auth Required - Open API, no API keys needed
- CORS Enabled - Use directly from frontend applications
- Fast & Reliable - Powered by Cloudflare's global network
- Pretty JSON - Human-readable formatted responses
GET /countriesReturns all 195 countries with complete data.
GET /countries/{code}Get country by 2-letter (US, FR) or 3-letter (USA, FRA) ISO code.
Example Response:
{
"name": "United States",
"code": "US",
"alpha3Code": "USA",
"capital": "Washington, D.C.",
"region": "Americas",
"subregion": "Northern America",
"population": 331002651,
"languages": ["English"],
"currency": "USD",
"flag": "🇺🇸",
"callingCode": "+1"
}GET /countries/randomReturns a random country - perfect for quiz apps, testing, or learning!
GET /countries?region={region}Available regions: Africa, Americas, Asia, Europe, Oceania
Example:
GET /countries?region=EuropeGET /countries?currency={currency}Example:
GET /countries?currency=EUR # All countries using EuroGET /countries?language={language}Example:
GET /countries?language=SpanishGET /search?q={query}Search by country name or capital.
Example:
GET /search?q=unitedGET /statsReturns global statistics including total population, most/least populous countries, and country counts by region.
GET /countries/{code}/flagReturns just the flag emoji.
- Learning & Education - Build geography quiz apps
- Testing & Development - Populate dropdowns and forms with real data
- Prototypes & Demos - Quick country data for MVPs
- Data Visualization - Create maps and charts
- Mobile Apps - Country pickers with flags
- Tutorials - Teach API consumption and async programming
# Install dependencies
npm install
# Run locally
npm run dev
# Deploy to Cloudflare
npm run deployEach country includes:
name- Country namecode- 2-letter ISO codealpha3Code- 3-letter ISO codecapital- Capital cityregion- Geographic regionsubregion- Geographic subregionpopulation- Population countlanguages- Array of official languagescurrency- Currency codeflag- Flag emojicallingCode- International calling code
Visit the API root endpoint for complete documentation:
GET /MIT