---
title: "汇率 API | Narwhal API"
description: "支持 144 种货币和 10,296 个货币对的汇率 API，提供当前指示性汇率、货币换算和历史观测值。"
url: "https://narwhalapi.com/zh/api/fx"
---

所有 API

# 汇率 API

通过 REST 或 MCP 获取当前汇率。同一个 API 密钥可用于金额换算和查询已保存的历史汇率。每月免费 10 美元，无需绑卡。

[获取免费 API 密钥](https://narwhalapi.com/zh/signup)
[阅读文档 →](https://narwhalapi.com/zh/docs/api/fx.md)

## 首次请求

### 获取当前汇率

```
curl --request GET \
  --url "https://api.narwhalapi.com/v1/fx/rates/USD?currencies=EUR,JPY" \
  --header "Authorization: Bearer $NARWHAL_API_KEY"
```

响应示例

```
{
  "base": "USD",
  "market_session": "open",
  "rates": [
    {
      "currency": "EUR",
      "rate": "0.9200",
      "timestamp": "2026-08-22T06:29:41Z",
      "stale": false
    },
    {
      "currency": "JPY",
      "rate": "147.23",
      "timestamp": "2026-08-22T06:29:39Z",
      "stale": false
    }
  ]
}
```

### 将美元兑换为韩元

```
curl --request GET \
  --url "https://api.narwhalapi.com/v1/fx/convert?from=USD&to=KRW&amount=100.00" \
  --header "Authorization: Bearer $NARWHAL_API_KEY"
```

响应示例

```
{
  "from": "USD",
  "to": "KRW",
  "rate": "1330.99",
  "converted": "133099",
  "market_session": "open",
  "timestamp": "2026-11-12T06:45:46.265344Z",
  "stale": false
}
```

### 换算金额

```
curl --request GET \
  --url "https://api.narwhalapi.com/v1/fx/convert?from=USD&to=JPY&amount=100.00" \
  --header "Authorization: Bearer $NARWHAL_API_KEY"
```

响应示例

```
{
  "from": "USD",
  "to": "JPY",
  "rate": "159.200",
  "converted": "15920",
  "market_session": "open",
  "timestamp": "2026-11-20T05:54:38.708502Z",
  "stale": false
}
```

### 获取历史汇率

```
curl --request GET \
  --url "https://api.narwhalapi.com/v1/fx/rates/USD/observations?currencies=EUR,NZD&start_date=2026-08-20&end_date=2026-08-28&limit=100" \
  --header "Authorization: Bearer $NARWHAL_API_KEY"
```

响应示例

```
{
  "base": "USD",
  "observations": [
    {
      "date": "2026-08-20",
      "rates": [
        {
          "currency": "EUR",
          "rate": "0.85609"
        },
        {
          "currency": "NZD",
          "rate": "1.681"
        }
      ]
    }
  ],
  "next_cursor": null
}
```

## 端点

GET 获取当前汇率`/v1/fx/rates/{base}`

某一种基准货币的当前汇率。用来显示价格或汇率表。

#### 参数

- `base` 必填 基准货币，使用大写的 ISO 4217 代码。
- `currencies` 可选 以逗号分隔的 1 到 64 种不同报价货币。省略则返回所有受支持的报价货币。

#### 响应字段

- `base` 字符串 基准货币。
- `market_session` 字符串 市场是开市、周末还是处于交易时段之间的休市。
- `rates` 数组 每种报价货币一条记录。
- `rates[].currency` 字符串 报价货币。
- `rates[].rate` 字符串 1 单位基准货币折合多少报价货币，以十进制字符串表示。
- `rates[].timestamp` 日期时间 此汇率的时间。
- `rates[].stale` 布尔值 此汇率是否已过时。

---

[完整参考文档 →](https://narwhalapi.com/zh/docs/api/fx/rates.md)

GET 换算金额`/v1/fx/convert`

使用一个选定汇率换算正数金额The result is rounded once, to the target currency’s minor unit.

#### 参数

- `from` 必填 源货币。
- `to` 必填 目标货币。必须与 from 不同。
- `amount` 必填 正的十进制字符串，最大 1000000000000。

#### 响应字段

- `from` 字符串 源货币。
- `to` 字符串 目标货币。
- `rate` 字符串 所用汇率。
- `converted` 字符串 换算后的金额，以十进制字符串表示。
- `market_session` 字符串 市场是开市、周末还是处于交易时段之间的休市。
- `timestamp` 日期时间 汇率的时间。
- `stale` 布尔值 汇率是否已过时。

---

[完整参考文档 →](https://narwhalapi.com/zh/docs/api/fx/conversion.md)

GET 获取历史汇率`/v1/fx/rates/{base}/observations`

按日期顺序分页返回已存储的汇率。没有存储汇率的日期会被略去，绝不会补上数据。

#### 参数

- `base` 必填 基准货币，使用大写的 ISO 4217 代码。
- `currencies` 必填 以逗号分隔的 1 到 64 种不同报价货币。其中不能包含基准货币。
- `start_date` 必填 第一天，不早于 1971-01-01。包含当天。
- `end_date` 必填 最后一天，不早于 start_date，且不能在未来。包含当天。
- `limit` 可选 每page.日期The default is 100 and the most is 366.
- `cursor` 可选 沿用上一页返回的 next_cursor，并使用相同的筛选条件。

#### 响应字段

- `base` 字符串 基准货币。
- `observations` 数组 每个日期一条记录，附带为该日存储的汇率。
- `next_cursor` 字符串 下一页的游标。最后一页为 Null。

---

[完整参考文档 →](https://narwhalapi.com/zh/docs/api/fx/history.md)

## 使用场景

### 过去某一天的汇率

获取某一天的汇率，并处理没有汇率的日子。

[阅读指南 →](https://narwhalapi.com/zh/how-to/get-an-exchange-rate-on-a-past-date.md)

### 发票日期的汇率

换算有日期的发票，并处理周末和货币方向。

[阅读指南 →](https://narwhalapi.com/zh/how-to/find-the-exchange-rate-on-an-invoice-date.md)

### 交叉汇率

由两个美元报价算出 EUR 兑 IDR。

[阅读指南 →](https://narwhalapi.com/zh/how-to/calculate-a-cross-rate.md)

### 月平均汇率

为你的账目计算一个月内每日汇率的平均值。

[阅读指南 →](https://narwhalapi.com/zh/how-to/calculate-a-monthly-average-exchange-rate.md)

### 每日数据拉取

每天运行一次小脚本，把汇率追加到 CSV 文件。

[阅读指南 →](https://narwhalapi.com/zh/how-to/schedule-a-daily-data-pull.md)

## 覆盖范围

- [USD → IDR](https://narwhalapi.com/zh/fx/usd-idr.md)
- [USD → INR](https://narwhalapi.com/zh/fx/usd-inr.md)
- [GBP → INR](https://narwhalapi.com/zh/fx/gbp-inr.md)
- [AED → INR](https://narwhalapi.com/zh/coverage.md#fx)
- [USD → PHP](https://narwhalapi.com/zh/fx/usd-php.md)
- [EUR → INR](https://narwhalapi.com/zh/fx/eur-inr.md)
- [USD → PKR](https://narwhalapi.com/zh/coverage.md#fx)
- [USD → AUD](https://narwhalapi.com/zh/fx/usd-aud.md)
- [GBP → USD](https://narwhalapi.com/zh/fx/gbp-usd.md)
- [CAD → USD](https://narwhalapi.com/zh/fx/cad-usd.md)
- [SAR → INR](https://narwhalapi.com/zh/coverage.md#fx)
- [AED → PKR](https://narwhalapi.com/zh/coverage.md#fx)

Show all 24 pairs

- [USD → NGN](https://narwhalapi.com/zh/coverage.md#fx)
- [KWD → INR](https://narwhalapi.com/zh/coverage.md#fx)
- [SAR → PKR](https://narwhalapi.com/zh/coverage.md#fx)
- [AED → PHP](https://narwhalapi.com/zh/coverage.md#fx)
- [USD → AED](https://narwhalapi.com/zh/coverage.md#fx)
- [AUD → PKR](https://narwhalapi.com/zh/coverage.md#fx)
- [GBP → PKR](https://narwhalapi.com/zh/coverage.md#fx)
- [EUR → USD](https://narwhalapi.com/zh/fx/eur-usd.md)
- [USD → MXN](https://narwhalapi.com/zh/fx/usd-mxn.md)
- [EUR → GBP](https://narwhalapi.com/zh/fx/eur-gbp.md)
- [OMR → INR](https://narwhalapi.com/zh/coverage.md#fx)
- [QAR → INR](https://narwhalapi.com/zh/coverage.md#fx)

## 相关 API

### 现货金属价格 API

黄金、白银、铂金和钯金的现货价格，以及 WTI、布伦特和铜的参考价格。

[探索 API →](https://narwhalapi.com/zh/api/commodities/spot.md)

### 节假日 API

按国家列出的官方公共假日，区分全国与地区范围。

[探索 API →](https://narwhalapi.com/zh/api/calendars/holidays.md)

### 价格

预付额度，每1,000次调用2美元，没有套餐或档位。

[查看价格 →](https://narwhalapi.com/zh/pricing.md)

## 常见问题

FX汇率是什么意思？

一个单位的基准货币等值于返回金额的报价货币。

支持哪些货币？

144 种货币。覆盖范围页面列出了每一种。

API 是否包含历史汇率？

有。历史数据基于实际存储的日期，采用每页大小有限制的分页方式和不透明游标。

周末会发生什么？

最新接受的汇率可能仍会连同时间戳、stale 状态和周末市场时段一起提供。缺失的发布日期不会用合成汇率填充。

有免费额度吗？

可以。每个账户每月可获 10 美元免费额度，汇率接口每 1,000 次调用 2 美元。 [查看价格](https://narwhalapi.com/zh/pricing.md).

这些是可执行的交易商报价吗？

不是。汇率和换算结果仅供参考，不是交易商报价或官方定盘价。

## 从免费密钥开始

每月赠送 10 美元免费额度，无需绑卡。每月 10 美元免费额度，无需绑卡。

[获取免费 API 密钥](https://narwhalapi.com/zh/signup)
