Authentication
Learn how to authenticate your API requests
API Key
Include your API key in the request header
Required HTTP header:
X-API-Key: your_api_key_hereExample Request
Here are examples of authenticated requests in different languages:
curl -X GET "https://api.currencyrest.com/v1/rates?base=USD" \
-H "X-API-Key: your_api_key_here"Example Response
200 OKjson
{
"success": true,
"timestamp": "2024-01-15T10:30:00Z",
"base": "USD",
"rates": {
"EUR": 0.92,
"GBP": 0.79,
"JPY": 148.50,
"BTC": 0.000023,
"ETH": 0.00038
}
}Getting Your API Key
- Sign up for a free CurrencyRest account
- Navigate to your dashboard
- Go to the "API Keys" section
- Click "Create API Key"
Security Best Practices
Never Expose Your Key
Never share your API key publicly or in versioned source code
Use Environment Variables
Store your API keys in environment variables, never hardcode them
Revoke Compromised Keys
If you suspect a key is compromised, revoke it immediately from your dashboard
HTTPS uniquement
All requests must be made over HTTPS. HTTP is not supported
Authentication Error Codes
401 Unauthorized - Missing API Key
{
"error": {
"code": "unauthorized",
"message": "API key is missing",
"type": "authentication_error"
}
}401 Unauthorized - Invalid API Key
{
"error": {
"code": "invalid_api_key",
"message": "The provided API key is invalid",
"type": "authentication_error"
}
}