Change language using Accept-Language

To change the language of API responses, you can use the Accept-Language header in your HTTP requests. This header informs the server about your preferred language, and the server will return the response in the selected language.

â„šī¸ If Accept-Language is not sent:

If the Accept-Language header is not sent, the response language will be automatically set based on the user's system language. This means that:

  • đŸŸĸ If the system language is Persian, the response will be sent in "fa".
  • âš ī¸ If the system language is not recognized or supported, the response will be sent in Persian by default ("fa").

🔄 Change language manually:

TitleValue
Country information in Persian"Accept-Language": "fa"
Country information in English"Accept-Language": "en"
Country information in Arabic"Accept-Language": "ar"
Invalid language (default country information in Persian)"Accept-Language": "xx"

📝 Request Code Sample:

fetch("https://www.world-api.ir/api/v1/countries?id=364", { 
  method: "GET", 
  headers: { 
    "X-API-Key": "your-api-key",  // 🔴 Replace your key here
    "Accept-Language" : "en" // 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": "Iran",
"flag": "https://www.world-api.ir/v1/countries/flag/IR.svg",
"capital": "Tehran",
"calling_code": 98,
"continent": "Asia",
"lat": 32.0,
"long": 53.0
}]
Country Information Web Service | Documentation | Change Language