Get Country by ISO2

By using the 2-letter international code (ISO2) of a country, you can access its complete and accurate information. This information includes the country name, flag, capital, dialing code, continent, and geographical location.

🚀 Request to get country by ISO2

GET https://www.world-api.ir/api/v1/countries?iso2={iso2}

Required Headers:

TitleValueDescriptionRequiredDefault
X-API-Keyyour-api-keyYour valid API key✅null
Accept-Languagefa, en, arSpecify response language❌OS Language

📝 Request Code Sample:

fetch("https://www.world-api.ir/api/v1/countries?iso2=ir", { 
  method: "GET", 
  headers: { 
    "X-API-Key": "your-api-key",  // 🔴 Replace your key here
    "Accept-Language" : "fa" // en , ar or fa
  } 
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));

📝 Response sample:

[{
"id": 364,
"iso2": "ir",
"iso3": "irn",
"name": "Ø§ÛŒØąØ§Ų†",
"flag": "https://www.world-api.ir/v1/countries/flag/IR.svg",
"capital": "ØĒŲ‡ØąØ§Ų†",
"calling_code": 98,
"continent": "ØĸØŗÛŒØ§",
"lat": 32.0,
"long": 53.0
}]

🔴 Invalid ISO2 submission error :

{
  "error": "Invalid iso2 parameter. It must be exactly 2 
    characters long (e.g., 'ir' for Iran).",
  "status": 400
}

🔴 API Key Missing or Invalid Error :

{
  "error": "API key is missing or invalid. Please provide a valid API key.",
  "status": 401
}