> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cleariflow.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 货币转换

> `convert` 端点使用实时汇率在货币之间转换特定金额——适用于金融计算和支付处理。

## 快速开始

### 基础 URL

```
https://exchange-rates.cleariflow.com/v1/convert
```

### 验证端点

`convert` 端点需要您的 API 密钥、基础货币和目标参数来执行货币转换。

```
https://exchange-rates.cleariflow.com/v1/convert
? api_key = YOUR_UNIQUE_API_KEY
& base = EUR
& target = USD
```

此成功请求使用最新汇率将 1 EUR 转换为 USD：

<ResponseExample>
  ```json theme={"system"}
  {
      "base": "EUR",
      "target": "USD",
      "base_amount": 1,
      "converted_amount": 1.160968,
      "exchange_rate": 1.160968,
      "last_updated": 1755806612
  }
  ```
</ResponseExample>

### 请求参数

<ParamField query="api_key" type="String" required>
  您的唯一 API 密钥。请注意，每个用户为每个 Cleariflow API 拥有
  独立的 API 密钥，因此您的汇率 API 密钥无法用于 IP
  地理定位 API，例如。
</ParamField>

<ParamField query="base" type="String" required>
  用于获取最新汇率的基础货币。使用 ISO 4217 货币标准（例如 USD 表示美元），与本 API 中所有货币参数相同。
</ParamField>

<ParamField query="target" type="String" required>
  相对于基础货币要获取汇率的目标货币。与 base 参数一样，此处传递的任何货币均遵循 ISO 4217 标准。请注意，与其他端点不同，`convert` 一次仅接受一个目标货币。
</ParamField>

<ParamField query="date" type="String">
  您要获取汇率的历史日期，格式为 YYYY-MM-DD。若留空，将使用最新可用汇率。
</ParamField>

<ParamField query="base_amount" type="Float">
  您要转换为目标货币的基础货币金额。
</ParamField>

### 响应参数

API 响应以通用、轻量的 [JSON 格式](https://www.json.org/json-en.html) 返回。

<ResponseField name="base" type="String">
  用于获取汇率的基础货币。
</ResponseField>

<ResponseField name="target" type="String">
  base\_amount 被转换到的目标货币。
</ResponseField>

<ResponseField name="date" type="String">
  根据成功请求提取货币的日期。
</ResponseField>

<ResponseField name="base_amount" type="Float">
  请求中的基础货币金额。
</ResponseField>

<ResponseField name="converted_amount" type="Float">
  base\_amount 转换后的目标货币金额。
</ResponseField>

<ResponseField name="exchange_rate" type="Float">
  用于将 base\_amount 从基础货币转换为目标货币的汇率。
</ResponseField>
