认证与限额
数据接口支持匿名试用:每个 IP 每分钟 10 次、每小时 100 次。带密钥的请求使用账户月度额度。 Free 价格延迟 15 分钟(响应头 X-Price-Delay-Seconds: 900)。
Authorization: Bearer YOUR_KEYX-RateLimit-Remaining: 9999X-RateLimit-Reset: 1788220800说明数据新鲜度的字段
source 表示来源类别,market_session 表示市场状态,data_updated_at 表示对响应有贡献的最早观测时间。建议全部保存。
接口
| GET /v1/latest[/{BASE}] | 当前汇率,可返回全部或按 symbols 筛选。 |
| GET /v1/{YYYY-MM-DD}[/{BASE}] | 指定日期和基准货币的历史快照。 |
| GET /v1/convert/{FROM}/{TO}[/{AMOUNT}] · POST /v1/convert | 金额换算,支持单次 GET 和批量 POST。 |
| GET /v1/rate/{slug} | 按 slug 返回单一货币对。 |
| GET /v1/range | 每日时间序列,支持分页和下载。 |
| GET /v1/currencies | 支持的货币列表,不接受参数。 |
| GET /v1/account | 账户、套餐、当前密钥和本月用量。 |
| GET /v1/indices/{index_slug} · GET /v1/indices/{index_slug}/timeseries | USD 指数最新值及历史序列。 |
日内序列与覆盖范围
/v1/timeseries 支持 1m、5m、15m、1h、4h 和日参考数据 1d,不支持 2h。不含 USD 的 SGD 交叉盘不支持 4h;USD/SGD 及反向支持。市场数据从 2026-09-14 开始采集。1m 保留 30 天,更大间隔没有计划到期删除。保留期限不代表已经积累了同样长度的历史。 1m 至 1h 日内覆盖 221 个唯一货币对:143 个 USD 货币对及 78 个交叉盘。
历史交叉盘要求真实收盘观测位于同一 UTC 区间内,时间差不超过 5 秒。effective_at 使用较早的观测时间。不填补缺口;尚未结束的区间可能变化。1d 使用全目录的日参考数据。表中每个货币对只计一次,支持双向。
| interval | 唯一货币对 |
|---|---|
1m | 221 |
5m | 221 |
15m | 221 |
1h | 221 |
4h | 209 |
1d | 10296 |
curl "https://api.exchangerate.dev/v1/timeseries?base=EUR&symbols=JPY&interval=15m&from=2026-09-14T12:00:00Z&to=2026-09-14T13:00:00Z" \ -H "Authorization: Bearer YOUR_API_KEY"支持的时间窗口没有观测时返回 HTTP 200,包含 data: []、has_more: false 和 next_cursor: null。未知间隔返回 unsupported_interval;范围外货币对返回 unsupported_pair_interval 和 rejected_pairs(HTTP 400)。混合请求会整体拒绝。
实时 WebSocket
连接 wss://api.exchangerate.dev/v1/stream,并在 10 秒内发送 auth。密钥必须留在服务器,不能放在 URL 或公开 JavaScript 中。不支持匿名连接。收到 authenticated 后发送 subscribe。支持下列货币;交叉盘要求两条最新观测均未过期且相差不超过 5 秒。状态可能为 unavailable 或 stale。每条获准连接消耗一个月度配额单位。
表为新账户限制。现有账户保留旧 Basic 3 × 25 或旧 Pro 10 × 100(连接数 × 每个连接的货币对数)。authenticated 消息会显示您的实际限制。
AUD, CAD, CHF, EUR, GBP, JPY, MXN, NOK, NZD, PLN, SEK, SGD, USD, ZAR
| 计划 | 并发连接 | 每条连接的货币对 |
|---|---|---|
| Free | 0 | 0 |
| Basic | 0 | 0 |
| Plus | 1 | 10 |
| Pro | 3 | 100 |
{"action":"auth","api_key":"YOUR_KEY"}{"action":"subscribe","base":"EUR","symbols":["USD","JPY"]}错误
REST: 错误统一为 { result: "error", code, message }。429 还会返回 Retry-After;数据源失败时不会悄悄改用模拟值。 HTTP 403 plan_gated 包含 tier、interval;超出历史窗口时还包含 history_days、earliest_allowed。若升级后可完成请求,则包含 upgrade_plans、upgrade_offers(plan、loses)、upgrade_url。
{ "result": "error", "code": "missing_parameter", "message": "required parameter missing: symbols"}{ "result": "error", "code": "plan_gated", "message": "The 15m interval is not included in your plan.", "tier": "plus_2026", "interval": "15m", "upgrade_plans": ["pro_2026"], "upgrade_offers": [{ "plan": "pro_2026", "loses": [] }], "upgrade_url": "https://exchangerate.dev/pricing?plan=pro_2026&source=api&reason=plan_gated"}curl -fsS --max-time 10 "https://api.exchangerate.dev/v1/latest/USD?symbols=EUR,GBP"from urllib.request import Request, urlopenimport json# Identify your application explicitly when calling the API.request = Request("https://api.exchangerate.dev/v1/latest/USD?symbols=EUR,GBP", headers={"User-Agent": "exchangerate-docs/1.0"})with urlopen(request, timeout=10) as response: data = json.load(response)print(data["rates"]["EUR"])const response = await fetch("https://api.exchangerate.dev/v1/latest/USD?symbols=EUR,GBP", { signal: AbortSignal.timeout(10_000),});if (!response.ok) throw new Error(`HTTP ${response.status}`);const data = await response.json();console.log(data.rates.EUR);集成指南: Python · JavaScript / Node.js · Google Sheets · Excel · Go · Swift · Zapier