v1.0.0 • REST API

Complete Countries API
for Developers

Access detailed information about 240+ countries worldwide through a fast, reliable, and free REST API. Perfect for any application.

240+
Countries
100%
Uptime
<100ms
Response Time
Free
Forever

Why Choose This API?

Built with modern technologies and best practices

Lightning Fast

Optimized response times under 100ms with MongoDB indexing and efficient queries.

🔒

CORS Enabled

Use from any domain without restrictions. Perfect for frontend applications.

📖

Well Documented

Complete OpenAPI/Swagger documentation with interactive examples.

🌐

Complete Data

Population, area, languages, currencies, flags, borders, and much more.

🔍

Flexible Search

Search by name, code, region, subregion, or any parameter you need.

💯

RESTful Design

Standard REST API following best practices and conventions.

API Endpoints

All endpoints return JSON responses

GET /api/countries
Get all countries with complete information
GET /api/countries/code/{code}
Search country by ISO code (cca2 or cca3): ES, ESP, LT, LTU
GET /api/countries/name/{name}
Search country by common name
GET /api/countries/region/{region}
Filter countries by region: Europe, Asia, Americas, Africa, Oceania
GET /api/countries/subregion/{subregion}
Filter by subregion: Southern Europe, Northern Europe, etc.
GET /api/countries/search?q={query}
Flexible search by name or capital
GET /api/countries/stats
Get general API statistics

Quick Start

Get started in seconds with these examples

JavaScript
// Get country by code
fetch('https://countries-api-service.vercel.app/api/countries/code/ES')
  .then(response => response.json())
  .then(data => console.log(data));

// Search countries in Europe
fetch('https://countries-api-service.vercel.app/api/countries/region/Europe')
  .then(response => response.json())
  .then(data => console.log(data));

// Flexible search
fetch('https://countries-api-service.vercel.app/api/countries/search?q=spain')
  .then(response => response.json())
  .then(data => console.log(data));
Response Example
{
  "success": true,
  "data": {
    "name": {
      "common": "Spain",
      "official": "Kingdom of Spain"
    },
    "cca2": "ES",
    "cca3": "ESP",
    "capital": ["Madrid"],
    "region": "Europe",
    "subregion": "Southern Europe",
    "population": 47351567,
    "area": 505992,
    "languages": { "spa": "Spanish" },
    "currencies": {
      "EUR": { "name": "Euro", "symbol": "€" }
    },
    "flags": {
      "png": "https://flagcdn.com/w320/es.png",
      "svg": "https://flagcdn.com/es.svg"
    },
    "borders": ["AND", "FRA", "GIB", "PRT", "MAR"]
  }
}