签名
ACCESS-SIGN的请求头是对 timestamp + method.toUpperCase() + requestPath + "?" + queryString + body 字符串(+表示字符串连接)使用 HMAC SHA256 方法加密,通过BASE64 编码输出而得到的。
签名各字段说明
- timestamp:与 ACCESS-TIMESTAMP 请求头相同。
 - method:请求方法(POST/GET),字母全部大写。
 - requestPath:请求接口路径。
 - queryString:请求URL中(?后的请求参数)的查询字符串。
 - body:请求主体对应的字符串,如果请求没有主体(通常为GET请求)则body可省略。
 
queryString为空时,签名格式
- timestamp + method.toUpperCase() + requestPath + body
 
queryString不为空时,签名格式
- timestamp + method.toUpperCase() + requestPath + "?" + queryString + body
 
举例说明
获取深度信息,以 btcusdt 为例:
- Timestamp = 1591089508404
 - Method = "GET"
 - requestPath = "/api/v2/market/depth"
 - queryString= "?symbol=btcusdt_spbl&limit=20"
 
生成待签名的字符串:
- '1591089508404GET/api/v2/market/depth?symbol=btcusdt_spbl&limit=20'
 
下单,以 btcusdt 为例:
- 
Timestamp = 1561022985382
 - 
Method = "POST"
 - 
requestPath = "/api/v2/order/order"
 - 
body =
{"symbol":"btcusdt_spbl","quantity":"8","side":"buy","price":"1","orderType":"limit","clientOrderId":"ww#123456"} 
生成待签名的字符串:
- 
'1561022985382POST/api/spotPro/v3/order/order{"symbol":"btcusdt_spbl","size":"8","side":"buy","price":"1","orderType":"limit","clientOrderId":"ww#123456"}' 
生成最终签名的步骤
- 将待签名字符串使用私钥secretkey进行hmac sha256加密
- Signature = hmac_sha256(secretkey, Message)
 
 - 对于Signature进行base64编码
- Signature = base64.encode(Signature)