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:
| Title | Value | Description | Required | Default |
|---|---|---|---|---|
| X-API-Key | your-api-key | Your valid API key | â | null |
| Accept-Language | fa, en, ar | Specify 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
}