Get API Key
To get the API key, please log in first.
đĄ How to Use the API Key
To use the API, you need an API Key which works like a password and verifies your access to the service. This key allows you to access various features and data of the service, and all requests must be made using it.
đ Why use X-API-Key?
X-API-Key is a standard way to send authentication keys supported by many APIs. This method:
- Is more secure than sending the key in URL parameters.
- Makes requests simpler and more readable.
- Is recommended by many modern APIs.
đ How to Send the API Key in an HTTP Request
To send the API Key using X-API-Key, just place its value in the headers section:
đ Request Code Sample:
fetch("https://www.world-api.ir/api/v1/countries", {
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));â ī¸ Important Security Tips for Using an API Key
- Never put your API Key in public code (like GitHub).
- Use environment variables (.env) to store your key.