# API 接口文档

{% hint style="info" %}
API 接口目前仅限高级合作伙伴调用，详情参见 [如何成为高级合作伙伴](https://dev.fatpay.org/zh/get-started/onboarding)。

成为高级合作伙伴后，您将获得专属的 *partnerId* 和密钥，用于 API 接口的调用。
{% endhint %}

## API 接口列表

* [list-all-cyptocurrencies](https://dev.fatpay.org/zh/reference/api-reference/on-ramp-apis/list-all-cyptocurrencies "mention")
  * 查询 FaTPay 当前支持的所有加密货币列表；
* [list-all-fiat-currencies](https://dev.fatpay.org/zh/reference/api-reference/on-ramp-apis/list-all-fiat-currencies "mention")
  * 查询 FaTPay 当前支持的所有法定货币及支持的支付方式；
* [retrieve-quoted-price](https://dev.fatpay.org/zh/reference/api-reference/on-ramp-apis/retrieve-quoted-price "mention")
  * 基于输入的法定货币金额查询当前加密货币报价；
* [list-all-orders](https://dev.fatpay.org/zh/reference/api-reference/on-ramp-apis/list-all-orders "mention")
  * 基于订单起止时间查询订单列表；
* [webhook-for-order-events](https://dev.fatpay.org/zh/reference/api-reference/webhooks/webhook-for-order-events "mention")
  * 订单状态变更时，FaTPay 对合作伙伴服务端发起异步通知；

## API 调用规范

请阁下务必遵照以下规范调用 FaTPay API 接口。

### 请求域名

> <https://api.ramp.fatpay.xyz/>

### 请求协议

<table><thead><tr><th>Protocol<select><option value="0edf5b19ca2b48548cfdd4a95caa6b1d" label="HTTPS" color="blue"></option><option value="f7127ed8a22a4be1a88a587578730afd" label="HTTP" color="blue"></option></select></th><th>Method<select multiple><option value="206aa06ae46f4a359d74b9d64415fc62" label="GET" color="blue"></option><option value="455bf6afe8ce41bda6c9d62fe502debb" label="POST" color="blue"></option></select></th><th>Content-Type<select multiple><option value="444c5596c56d4212b73bb88824763a04" label="application/json" color="blue"></option><option value="40d7161cb170499194363128d527b97e" label="multipart/form-data" color="blue"></option></select></th></tr></thead><tbody><tr><td><span data-option="0edf5b19ca2b48548cfdd4a95caa6b1d">HTTPS</span></td><td><span data-option="206aa06ae46f4a359d74b9d64415fc62">GET, </span><span data-option="455bf6afe8ce41bda6c9d62fe502debb">POST</span></td><td><span data-option="444c5596c56d4212b73bb88824763a04">application/json, </span><span data-option="40d7161cb170499194363128d527b97e">multipart/form-data</span></td></tr></tbody></table>

{% hint style="warning" %}
FaTPay API 接口仅支持 HTTPS 安全连接。
{% endhint %}

### 字符编码

`UTF-8`

### 公共 header 参数 <a href="#common-header-params" id="common-header-params"></a>

调用 FaTPay API 接口，必须在每个 API 请求的 header 里加入以下参数。

{% hint style="warning" %}
参数名称及参数值均为大小写敏感
{% endhint %}

<table><thead><tr><th width="194">参数名</th><th width="97">类型</th><th>含义</th></tr></thead><tbody><tr><td><code>X-Fp-Partner-Id</code></td><td>String</td><td>申请成为高级合作伙伴时，由 FaTPay 分配的 partner ID，如：<em>mqMBpCIP630LJxLY</em></td></tr><tr><td><code>X-Fp-Nonce</code></td><td>Integer(6)</td><td>随机正整数，如：183216</td></tr><tr><td><code>X-Fp-Timestamp</code></td><td>Integer(10)</td><td>Unixtime 时间戳，秒级，如：1656600459</td></tr><tr><td><code>X-Fp-Version</code></td><td>String</td><td>FaTPay API 接口版本，如：v1.0</td></tr><tr><td><code>X-Fp-Signature</code></td><td>String</td><td>基于请求参数和分配给高级合作伙伴的密钥，生成的签名，具体算法详见<a data-mention href="api-reference/verification">verification</a></td></tr></tbody></table>

### 接口返回

API 接口正常都将返回错误码 `code`，错误消息 `msg`，以及数据部分 `data`。只有当 `code` 非 `10000` 时，`data` 部分都为空。数据部分 `data` 可能是一个对象 `Object`，也可能是一个数组 `Array`。视具体接口而定。

{% hint style="info" %}
接口返回错误码及相应错误消息，参见[api-error-codes](https://dev.fatpay.org/zh/appendix/api-error-codes "mention")。
{% endhint %}

<table><thead><tr><th width="131">参数名</th><th width="99">类型</th><th width="146">是否必填</th><th>备注</th></tr></thead><tbody><tr><td>code</td><td>String</td><td>是</td><td>错误码</td></tr><tr><td>msg</td><td>String</td><td>是</td><td>错误消息</td></tr><tr><td>data</td><td>Object</td><td>否</td><td>可能是对象或数组</td></tr></tbody></table>

{% code title="接口返回示例" overflow="wrap" %}

```javascript
// 返回 data 为对象
{
  "code": "10000",
  "msg": "success",
  "data": {
    "foo": "bar"
  }
}

// 返回 data 为数组
{
  "code": "10000",
  "msg": "success",
  "data": [
    {
      "foo": "bar1"
    },
    {
      "foo": "bar2"
    }
  ]
}

// 返回 data 为空
{
  "code": "10002",
  "msg": "incorrect params",
  "data": null
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.fatpay.org/zh/reference/api-reference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
