Latest Rates API
Fetch the latest exchange rates for a specified base currency.
Endpoint
GET /latest_rates
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | string | Yes | Base currency code (ISO 4217) - e.g., USD, EUR, GBP |
targets | string | No | Comma-separated target currencies - e.g., EUR,GBP,JPY. Defaults to all currencies if omitted. |
Request Example
curl -X GET "https://api.openfxrates.com/latest_rates?base=USD&targets=EUR,GBP,JPY" \
-H "X-API-Key: your-api-key-here"
Response Schema
{
"base": "USD",
"date": "2024-12-25",
"rates": {
"EUR": 0.92,
"GBP": 0.79,
"JPY": 150.25
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
base | string | The base currency code |
date | string | The date of the rates (YYYY-MM-DD format) |
rates | object | Exchange rates with currency codes as keys and rates as values |
Status Codes
| Status | Description |
|---|---|
| 200 | Success - Rates returned |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid or missing API key |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Server Error - Internal error |
Examples
Get rates for all currencies
curl -X GET "https://api.openfxrates.com/latest_rates?base=USD" \
-H "X-API-Key: your-api-key"
Get rates for specific currencies
curl -X GET "https://api.openfxrates.com/latest_rates?base=EUR&targets=USD,GBP,JPY,CHF" \
-H "X-API-Key: your-api-key"
Rate Limiting
Rate limits depend on your plan. Check response headers:
X-RateLimit-Limit- Requests allowed per minuteX-RateLimit-Remaining- Requests remainingX-RateLimit-Reset- Unix timestamp when limit resets
Caching
For optimal performance, cache latest rates for 1-5 minutes depending on your requirements.
See Also
- Historical Rates API - Get historical rates
- Currency Conversion API - Convert amounts between currencies
- List Currencies - Get all supported currencies