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

# 签名

接口后面会标注鉴权类型，遇到 `SIGNED` 标记，说明这个接口需要签名才能访问。遇到 `KEYED` 标记，说明这个接口只需要在请求头设置 API KEY 即可。

#### 鉴权类型

* `NONE` ：不需要鉴权的接口，所有人都可以访问
* `KEYED` ：需要有效的 X-API-KEY
* `SIGNED` ：需要有效的 X-API-KEY 和签名 X-API-SIGN

#### 1. 设置请求参数

**header key 设置**

* `X-API-KEY` （你创建的 API Access KEY）
* `X-API-SIGN` （使用 HmacSHA256 签名）
* `X-API-TIMESTAMP` （发起请求的当前时间戳，精确到毫秒）

```text theme={null}
// X-API-TIMESTAMP 生成

// Java
System.currentTimeMillis();

// Python
int(time.time() * 1000)

// Golang
time.Now().UnixNano() / int64(time.Millisecond)

// Nodejs & TypeScript
Date.now();

// Javascript
Date.now();

// PHP
round(microtime(true) * 1000)

// C#
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
```

**body 参数设置**

* `GET/DELETE` 的请求方式，query string 是 `symbol=BMX&side=BUY` 的form表单格式
* `POST/PUT的` 请求方式，query string 是 `{"symbol":"BMX","side":"BUY"}` 的json格式

#### 2. 例子

* 请求接口：`/account/v1/transfer-contract` (SIGNED)
* 请求方式: POST
* 假设当前时间戳: timestamp= `1589793796145`
* request body=`{"currency":"USDT","amount":"10","transferType":"spot_to_contract"}`

则设置如下：

* X-API-TIMESTAMP= `1589793796145`
* X-API-KEY= `Your_api_access_key`
* X-API-SIGN= hmac\_sha256( `Your_api_secret_key` , `X-API-TIMESTAMP` + '#' + `Your_api_memo` + '#' + `'{"currency":"USDT","amount":"10","transferType":"spot_to_contract"}'`)

假设您申请的 key 如下：

* accessKey =`80618e45710812162b04892c7ee5ead4a3cc3e56`
* secretKey =`6c6c98544461bbe71db2bca4c6d7fd0021e0ba9efc215f9c6ad41852df9d9df9`
* memo =`test001`

以下是一个完整的请求

```shell theme={null}
# Shell 完整请求示例

echo -n '1589793796145#test001#{"currency":"USDT","amount":"10","transferType":"spot_to_contract"}' \
  | openssl dgst -sha256 -hmac "6c6c98544461bbe71db2bca4c6d7fd0021e0ba9efc215f9c6ad41852df9d9df9"
# (stdin)= bbd57e119c53e7cd28c5097f596822173fbf883c94c8bcc9a61ec2da9e143778

curl --location --request POST 'https://cloud-api.wooxpro.com/account/v1/transfer-contract' \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: 80618e45710812162b04892c7ee5ead4a3cc3e56' \
  --header 'X-API-SIGN: bbd57e119c53e7cd28c5097f596822173fbf883c94c8bcc9a61ec2da9e143778' \
  --header 'X-API-TIMESTAMP: 1589793796145' \
  --data '{"currency":"USDT","amount":"10","transferType":"spot_to_contract"}'
```
