# erapi.latest

**stable** **Standard**

Latest open exchange rates for a base currency (open.er-api.com, attribution required).

`GET /v1/erapi/latest`

## What you get

One Erapi record in Onekey's unified shape, in `data`. If the record does not exist you get a `404 not_found` and are not charged.

## What it costs

- **Standard · 1 credit** for a fresh fetch, charged only when it succeeds.
- **Free when served from cache (0.2 credit for a cached response over 100 KB).**
- **Free** if the request is invalid (never charged) or the source fails or reports not found (refunded).

## Parameters

| Name | Type | Required | Default | What it is | Constraints |
| --- | --- | --- | --- | --- | --- |
| `base` | string | no | `USD` | Base currency, UPPERCASE ISO 4217 | max 3 chars; must match `[A-Z]{3}`; trimmed |

## Request

```bash
curl "https://api.onekey.dev/v1/erapi/latest?base=USD" \
  -H "x-api-key: YOUR_API_KEY"
```

```python
import requests

res = requests.get(
    "https://api.onekey.dev/v1/erapi/latest",
    params={"base": "USD"},
    headers={"x-api-key": "YOUR_API_KEY"},
)
body = res.json()

if body["success"]:
    print(body["data"])
else:
    print(body["error"]["code"], body["error"]["message"])
```

```javascript
const params = new URLSearchParams({ base: "USD" });
const res = await fetch(`https://api.onekey.dev/v1/erapi/latest?${params}`, {
  headers: { "x-api-key": "YOUR_API_KEY" },
});
const body = await res.json();

if (body.success) console.log(body.data);
else console.error(body.error.code, body.error.message);
```

## Recorded response

A real Erapi response, recorded and returned in Onekey's shape. Fields the platform does not provide are `null`.

```json
{
  "success": true,
  "data": {
    "market": {
      "symbol": "USD"
    },
    "entity": {
      "date": "2026-09-28T00:02:31Z"
    },
    "ext": {
      "rates": {
        "USD": 1,
        "AED": 3.6725,
        "AFN": 64.382574,
        "ALL": 80.758863,
        "AMD": 363.612931,
        "ANG": 1.79,
        "AOA": 922.434976,
        "ARS": 1523.9662,
        "AUD": 1.425788,
        "AWG": 1.79,
        "AZN": 1.699654,
        "BAM": 1.717205,
        "BBD": 2,
        "BDT": 122.984636,
        "BGN": 1.717205,
        "BHD": 0.376,
        "BIF": 2991.219168,
        "BMD": 1,
        "BND": 1.278286,
        "BOB": 12.233272,
        "BRL": 5.189503,
        "BSD": 1,
        "BTN": 95.933534,
        "BWP": 13.869151,
        "BYN": 3.023827,
        "BZD": 2,
        "CAD": 1.414854,
        "CDF": 2311.600613,
        "CHF": 0.829327,
        "CLF": 0.024345,
        "CLP": 962.264198,
        "CNH": 6.721742,
        "CNY": 6.719488,
        "COP": 3334.28191,
        "CRC": 452.97621,
        "CUP": 24,
        "CVE": 96.81192,
        "CZK": 21.399634,
        "DJF": 177.721,
        "DKK": 6.558672,
        "DOP": 59.459173,
        "DZD": 133.749756,
        "EGP": 51.744321,
        "ERN": 15,
        "ETB": 162.473672,
        "EUR": 0.878356,
        "FJD": 2.247813,
        "FKP": 0.755703,
        "FOK": 6.559467,
        "GBP": 0.755594,
        "GEL": 2.601676,
        "GGP": 0.755703,
        "GHS": 11.635545,
        "GIP": 0.755703,
        "GMD": 74.45814,
        "GNF": 8794.340706,
        "GTQ": 7.634677,
        "GYD": 209.161176,
        "HKD": 7.844488,
        "HNL": 26.831065,
        "HRK": 6.61524,
        "HTG": 130.84643,
        "HUF": 320.923923,
        "IDR": 17921.041858,
        "ILS": 3.045597,
        "IMP": 0.755703,
        "INR": 95.927874,
        "IQD": 1309.290097,
        "IRR": 1601445.352353,
        "ISK": 120.290023,
        "JEP": 0.755703,
        "JMD": 157.933178,
        "JOD": 0.709,
        "JPY": 157.489371,
        "KES": 129.619855,
        "KGS": 87.466985,
        "KHR": 4048.914544,
        "KID": 1.425975,
        "KMF": 431.944336,
        "KRW": 1356.044355,
        "KWD": 0.308332,
        "KYD": 0.833333,
        "KZT": 442.635582,
        "LAK": 22248.985644,
        "LBP": 89500,
        "LKR": 330.026559,
        "LRD": 171.975328,
        "LSL": 16.319117,
        "LYD": 6.39137,
        "MAD": 9.59777,
        "MDL": 17.63128,
        "MGA": 4396.225344,
        "MKD": 53.729511,
        "MMK": 2101.962031,
        "MNT": 3571.718831,
        "MOP": 8.079862,
        "MRU": 40.212208,
        "MUR": 47.574262,
        "MVR": 15.439048,
        "MWK": 1747.266506,
        "MXN": 17.735545,
        "MYR": 4.074399,
        "MZN": 63.848352,
        "NAD": 16.319117,
        "NGN": 1327.301923,
        "NIO": 36.794545,
        "NOK": 9.514776,
        "NPR": 153.493654,
        "NZD": 1.767657,
        "OMR": 0.384497,
        "PAB": 1,
        "PEN": 3.392941,
        "PGK": 4.451592,
        "PHP": 62.449889,
        "PKR": 276.909534,
        "PLN": 3.840834,
        "PYG": 5923.870669,
        "QAR": 3.64,
        "RON": 4.629417,
        "RSD": 103.117796,
        "RUB": 84.192029,
        "RWF": 1478.239841,
        "SAR": 3.75,
        "SBD": 8.009459,
        "SCR": 14.56798,
        "SDG": 458.664298,
        "SEK": 9.923533,
        "SGD": 1.278218,
        "SHP": 0.755703,
        "SLE": 24.613943,
        "SLL": 24613.943162,
        "SOS": 571.851717,
        "SRD": 37.681529,
        "SSP": 5996.789368,
        "STN": 21.510833,
        "SYP": 121.690091,
        "SZL": 16.319117,
        "THB": 33.416091,
        "TJS": 9.227178,
        "TMT": 3.49828,
        "TND": 2.947661,
        "TOP": 2.395317,
        "TRY": 48.948487,
        "TTD": 6.792403,
        "TVD": 1.425975,
        "TWD": 31.7654,
        "TZS": 2657.137693,
        "UAH": 44.845393,
        "UGX": 3891.437778,
        "UYU": 40.063086,
        "UZS": 11830.201553,
        "VES": 857.0058,
        "VND": 25936.548312,
        "VUV": 118.474346,
        "WST": 2.731292,
        "XAF": 575.925782,
        "XCD": 2.7,
        "XCG": 1.79,
        "XDR": 0.734931,
        "XOF": 575.925782,
        "XPF": 104.772684,
        "YER": 236.507833,
        "ZAR": 16.322134,
        "ZMW": 19.560933,
        "ZWG": 26.6294,
        "ZWL": 26.6294
      }
    }
  },
  "metadata": {
    "platform": "erapi",
    "endpoint": "latest",
    "cached": false,
    "stale": false,
    "age_s": 0,
    "fetched_at": "2026-01-01T12:00:00+00:00",
    "credits_charged": 1,
    "request_id": "7f3a9c2e5b1d4c8fa2e6d0b9c4f18e37"
  },
  "error": null
}
```

## Field mapping

How this endpoint's source fields become Onekey's [unified schema](https://onekey.dev/docs/schema.md). Fields the source lacks come back as `null`.

| Source path | Onekey field | Transform |
| --- | --- | --- |
| `base_code` | `market.symbol` | - |
| `time_last_update_unix` | `entity.date` | `toIsoDate` |
| `rates` | `ext.rates` | - |

## Caching and freshness

- Fresh for about 30 seconds. Repeat calls in that window are served from cache and are free.
- Between 30 seconds and 5 minutes the cached copy is still served instantly and marked `stale: true` while Onekey refreshes it in the background.
- If the source is down when a refresh is needed, the last copy can be served for up to 1 hour more (marked stale).
- A "not found" is remembered for 1 minute and is free.
- The cache is shared across all customers, which is what keeps repeat calls cheap.

## What can go wrong

| Status | Code | What to do |
| --- | --- | --- |
| 401 | `unauthorized` | Check the `x-api-key` header. |
| 402 | `insufficient_credits` | [Add credits](https://onekey.dev/pricing); your balance must cover the price. |
| 404 | `not_found` | That record does not exist. Free; do not retry. |
| 422 | `invalid_params` | Fix the parameters using the table above. Free. |
| 429 | `rate_limited` | Wait `Retry-After` seconds, then retry. |
| 502 | `upstream_error` | The source failed. Refunded; retry with backoff. |

See [Errors](https://onekey.dev/docs/errors.md) for the full list and retry guidance.

Status: stable (verified against the live source).
