Free Countries API
The Countries API provides detailed geographical, political, and demographic data for every country in the world. Use this API to power location selectors, build interactive maps, or display local information like currency and language in your internationalized applications. It supports searching by name, region, or ISO codes.
What is a REST API?
An API (Application Programming Interface) allows two software programs to communicate. A REST API uses standard HTTP requests like GET (to read data), POST (to create data), PUT (to update), and DELETE (to remove).
When you send a request to our https://techidea.online/api/v1/countries endpoint, our server responds with a JSON (JavaScript Object Notation) array containing data. You can then display this data in your frontend React, Next.js, or mobile applications.
Developer Features
Pagination
Use ?limit=10&page=2
Filtering
Use ?search=keyword
Sorting
Use ?sort=id&order=asc
Code Examples
import { useState, useEffect } from 'react';
function CountryList() {
const [countries, setCountries] = useState([]);
useEffect(() => {
fetch('https://api.example.com/v1/countries?region=Europe')
.then(res => res.json())
.then(data => setCountries(data));
}, []);
return (
<ul>
{countries.map(c => <li key={c.cca3}>{c.name.common}</li>)}
</ul>
);
}Sample Response
[
{
"name": {
"common": "France",
"official": "French Republic"
},
"cca3": "FRA",
"capital": ["Paris"],
"region": "Europe",
"population": 67391582,
"flags": {
"png": "https://flagcdn.com/w320/fr.png",
"svg": "https://flagcdn.com/fr.svg"
}
}
]What to Build (Project Ideas)
Interactive Globe Explorer
Build an interactive 3D globe where users can click on countries to see detailed statistics.
Implementation Steps
- 1. Render a 3D globe using Three.js or similar libraries.
- 2. Fetch country data from the API including lat/lng and borders.
- 3. When a user clicks on a coordinate, find the matching country and display a modal.
- 4. Show interesting facts like population density, capital city, and spoken languages.
Travel Itinerary Planner
Help users plan trips by providing essential information about their destination countries.
Implementation Steps
- 1. Allow users to select a list of countries they want to visit.
- 2. Fetch currency, timezone, and language data from the API.
- 3. Generate a unified itinerary document summarizing what they need to know before traveling.
- 4. Integrate a weather API to show current conditions in the capital cities.
Frequently Asked Questions
What format are the country codes in?
The API provides both ISO 3166-1 alpha-2 (cca2) and alpha-3 (cca3) codes for broad compatibility.
Are historical countries included?
No, this API only provides data for currently recognized sovereign states and territories.
Continue Learning
Use these resources to deepen your understanding of API integration and build portfolio-worthy projects.