下方有示例代码,请求和返回示例。 点击上方的语言 tab 来切换各语言的代码示例。
API 全面支持跨所账户核心能力,覆盖资金划转、查询、交易、账户信息更改、订阅及推送等全流程操作。
REST API BaseURL:
https://api.gateio.ws/api/v4/crossex可用的 SDK:
除了 API 示例,部分 SDK 还提供了额外的演示应用程序。 演示应用程序是一个相对完整的示例,展示了如何使用 SDK。 可以单独构建和运行。详细信息请参考相应的仓库。
CrossEx 是一个跨交易所交易平台,允许用户通过统一账户在多个交易所(币安、欧易、Gate.io)进行交易。CrossEx API 提供完整的账户管理、资产划转、下单和仓位管理功能,支持跨交易所操作。
如果您在使用过程中有任何问题或建议,可以通过以下方式联系我们:
如果您遇到 API 错误,建议您整理以下内容,以便我们快速为您分析问题:
DANGER
即使您提交问题,也不应向客服或他人提交 API key 信息,否则将存在严重的资产风险。如果已经意外泄露,请删除现有 API 并重新创建。
v1.0.0
2026-01-20
API 全面支持跨所账户核心能力,覆盖资金划转、查询、交易、账户信息更改、订阅及推送等全流程操作。
Gate 数据中心位于 AWS 日本 ap-northeast-1 区域。
| API 分类 | 分类链接 | 概述 |
|---|---|---|
host + /api/v4/crossex/* | CrossEx API | 跨交易所交易 API,提供统一账户管理和跨交易所交易功能 |
CrossEx 是一个跨交易所交易平台,提供以下功能:
在使用 CrossEx API 之前,请确保:
CrossEx API 主要包括以下功能模块:
在调用私有API接口前,需要生成账户的API key来验证身份。 您可以在网页端登录成功后,在【账户管理】-> 【APIv4 Keys】中生成, 或点击 这里 生成 API keys
每个账户最多可以创建 20 个 API key,每个 Key 的权限配置都是相互独立的。 建议给每个 Key 设置能够标明用途的备注名
Key 访问密钥
Secret Key 签名认证加密所使用的密钥
除此之外,还可以配置 IP 白名单,只允许服务端接收来自 IP 白名单里的客户端请求。每个 Key 最多可配置 20 个 IP 地址,IP 地址按照 IPv4 配置, 不支持 IP 地址段。若不设置 IP 白名单,服务端不会验证客户端 IP 来源。
TIP
注:如果发现 Key 的名字是 spot 或者 futures ,该 Key 很有可能是迁移之后系统的默认命名,
详情参考 “关于 APIv4 Key 升级” 一节。
创建的 Key 还可以更新和删除,不过需要注意的是 Key 的更新和删除,最多需要 5 分钟才能生效。
另外模拟合约与实盘合约属于两套不同的环境,实盘合约的 API Key 不可用于模拟合约。 如果需要使用模拟合约做 API 接口联调测试,需要在个人账户 APIv4Keys 页面的模拟合约入口单独申请。 模拟合约与实盘合约的接口请求方式完全相同,区别只是在 API 的 Base URL 和使用的 API Key
创建 Key 的时候,可以为该 Key 配置是否开启现货杠杆、合约、钱包或者提现的权限, 开启的权限可以配置读写或者只读。
| 产品 | 权限 |
|---|---|
现货/杠杆 | 只读查询订单 读写查询订单&下单 |
永续合约 | 只读查询订单 读写查询订单&下单 |
交割合约 | 只读查询订单 读写查询订单&下单 |
钱包 | 只读查询充提划转记录 读写 查询账户记录&资金划转 |
提现 | 只读查询提现记录 读写 查询提现记录&提现 |
所有请求方法为 GET 的都是读操作,其他的则是写请求。每个权限组可以设置为禁用、只读或读写。
值得注意的一点是,尽管提现操作组只有一个 API (即 POST /withdrawals ),考虑到一般使用情况,
还是将其从钱包操作里独立成一个权限组,而包括了提现记录的账户转出流水记录查询(即
GET /wallet/withdrawals )还是保留在钱包 API 权限组了。
KEY ,即 APIv4 密钥对的 KeyTimestamp ,即请求发送的时间,格式是秒级精度的 Unix 时间戳。
同时该时间不能与当前时间差距超过 60 秒。SIGN ,即将请求生成签名字符串并用 APIv4 Secret 加密后生成的签名。
签名字符串生成方法参看下节,加密算法为 HexEncode(HMAC_SHA512(secret, signature_string)) ,
即通过 HMAC-SHA512 加密算法,将 APIv4 Secret 作为加密密钥,签名字符串作为加密消息,
生成加密结果的 16 进制输出。APIv4 中签名字符串按照如下方式拼接生成:
Request Method + "\n" + Request URL + "\n" + Query String + "\n" + HexEncode(SHA512(Request Payload)) + "\n" + Timestamp
请求方法,全大写, 如 POST, GET
请求 URL,不包括服务地址和端口,如 /api/v4/futures/orders
没有使用 URL 编码的请求参数,请求参数在参与计算签名时的顺序一定要保证和实际请求里的顺序一致。
如 status=finished&limit=50 。
如果没有请求参数,使用空字符串 ("")
将请求体字符串使用 SHA512 哈希之后的结果。如果没有请求体,使用空字符串的哈希结果,即
cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
设置在请求头部 Timestamp 里的值
示例
注:示例中所有的换行都是为了方便显示人为添加的,实际只有示例中的一个 \n 保留
假设使用的 Key 为 key ,Secret 为 secret
GET /api/v4/futures/orders?contract=BTC_USD&status=finished&limit=50 HTTP/1.1
签名字符串:
GET\n
/api/v4/futures/orders\n
contract=BTC_USD&status=finished&limit=50\n
cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e\n
1541993715
说明
/api/v4/futures/orders: 请求 URLcontract=BTC_USD&status=finished&limit=50: 请求参数,与实际请求的顺序完全一致1541993715: Unix 时间戳签名结果
55f84ea195d6fe57ce62464daaa7c3c02fa9d1dde954e4c898289c9a2407a3d6fb3faf24deff16790d726b66ac9f74526668b13bd01029199cc4fcc522418b8a
POST /api/v4/futures/orders HTTP/1.1
{"contract":"BTC_USD","type":"limit","size":100,"price":6800,"time_in_force":"gtc"}
签名字符串:
POST\n
/api/v4/futures/orders\n
\n
ad3c169203dc3026558f01b4df307641fa1fa361f086b2306658886d5708767b1854797c68d9e62fef2f991645aa82673622ebf417e091d0bd22bafe5d956cca\n
1541993715
说明
签名结果
eae42da914a590ddf727473aff25fc87d50b64783941061f47a3fdb92742541fc4c2c14017581b4199a1418d54471c269c03a38d788d802e2c306c37636389f0
# coding: utf-8
# Python 示例验签代码
"""
本示例仅作为演示签名计算方式使用,推荐使用各语言的 SDK ,因为已经集成了验签规则
"""
# coding: utf-8
import time
import hashlib
import hmac
import requests
import json
def gen_sign(method, url, query_string=None, payload_string=None):
key = '' # api_key
secret = '' # api_secret
t = time.time()
m = hashlib.sha512()
m.update((payload_string or "").encode('utf-8'))
hashed_payload = m.hexdigest()
s = '%s\n%s\n%s\n%s\n%s' % (method, url, query_string or "", hashed_payload, t)
sign = hmac.new(secret.encode('utf-8'), s.encode('utf-8'), hashlib.sha512).hexdigest()
return {'KEY': key, 'Timestamp': str(t), 'SIGN': sign}
if __name__ == "__main__":
host = "https://api.gateio.ws"
prefix = "/api/v4"
common_headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/futures/orders'
body = {"contract": "BTC_USD", "size": 100, "price": "30", "tif": "gtc"}
request_content = json.dumps(body)
sign_headers = gen_sign('POST', prefix + url, "", request_content)
sign_headers.update(common_headers)
print('signature headers: %s' % sign_headers)
res = requests.post(host + prefix + url, headers=sign_headers, data=request_content)
print(res.status_code)
print(res.content)
APIv4 对于所有的异常请求,会设置状态码为非 2xx ,同时返回一个 JSON 格式的返回体来描述具体的错误信息。
返回体的格式通常如下所示:
{
"label": "COMMON_PARAM_BIND_ERROR",
"message": "参数非法,请查阅api文档"
}
label 用于标识某种错误的类型,格式 string ,它的值是一个固定的列表(见下方)。程序处理可以使用 label 字段的内容来设定和捕获异常message (或 detail) 表示详细的错误信息,方便 API 对接时,理解具体是因为什么样的参数设置导致请求出现了异常。
该字段内容不建议用于异常的捕获或识别。以 Python requests (opens new window) 为例,异常的处理流程可以参考如下所示:
以下示例的异常捕获流程只涉及到业务相关的异常,网络连接超时等其他非业务相关的异常还需要自行处理。
import requests
r = requests.get("https://api.gateio.ws/api/v4/crossex/accounts")
try:
r.raise_for_status()
except requests.HTTPError:
# 捕获非 2xx 错误,尝试解析 body 里返回的错误消息,并根据不同 label 做不同的异常处理
if r.json()['label'] == 'xxx':
print(r.json())
label 列表label | 含义 |
|---|---|
| COMMON_PARAM_BIND_ERROR | 参数非法,请查阅api文档 |
| TRADE_UNSUPPORTED_OPERATION | 当前操作不被允许 |
label | 含义 |
|---|---|
| USER_NOT_EXIST | 用户不存在 |
| USER_DEACTIVATED | 用户已注销 |
| QUERY_INVALID_EXCHANGE_TYPE | 交易所非法,分所模式下交易所类型必须为BINANCE,OKX,GATE |
| TRADE_CHANGE_PZ_MODE_SAME_ERROR | 无需重复设置仓位模式 |
| TRADE_PZ_MODE_HAVE_ORDER_ERROR | 有挂单,无法设置仓位模式 |
| TRADE_PZ_MODE_HAVE_POSITION_ERROR | 有未平仓位,无法设置仓位模式 |
| UPDATE_ACCOUNT_PARAMETERS_ALL_EMPTY_ERROR | 参数不能全为空 |
| UPDATE_ACCOUNT_PARAMETERS_ERROR | 无法同时设置账户模式和仓位模式 |
| UPDATE_ACCOUNT_EXCHANGE_TYPE_PARAMETERS_ERROR | 若传参交易所则仓位模式必须传值 |
| UPDATE_ACCOUNT_ACCOUNT_MODE_ERROR | 非法账户模式,请查阅api文档 |
| UPDATE_ACCOUNT_EXCHANGE_TYPE_ERROR | 非法交易所类型,请查阅api文档 |
| UPDATE_ACCOUNT_PZ_ISOLATED_MODE_NOT_EXCHANGE_TYPE_ERROR | 分所模式下修改仓位模式交易所必传 |
| UPDATE_ACCOUNT_MODE_OPEN_ORDERS_EXIST_ERROR | 有挂单无法修改账户模式 |
| UPDATE_ACCOUNT_MODE_POSITION_NOT_EMPTY_ERROR | 有未平仓位无法修改账户模式 |
| UPDATE_ACCOUNT_MODE_INITIAL_MARGIN_NOT_ZERO_ERROR | 账户有初始保证金无法修改账户模式 |
| UPDATE_ACCOUNT_MODE_MAINTENANCE_MARGIN_NOT_ZERO_ERROR | 账户有维持保证金无法修改账户模式 |
| UPDATE_ACCOUNT_MODE_ACCOUNT_STATUS_NOT_NORMAL_ERROR | 账户状态不是NORMAL无法修改账户模式 |
| UPDATE_ACCOUNT_CROSSEX_MODE_EXCHANGE_TYPE_NOT_CROSSEX_ERROR | 跨所模式下交易所类型只能是CROSSEX |
| UPDATE_ACCOUNT_ISOLATED_MODE_EXCHANGE_TYPE_NOT_CROSSEX_ERROR | 分所模式下交易所类型不能是CROSSEX |
label | 含义 |
|---|---|
| TRADE_CLIENT_ORDER_ID_LENGTH_ERROR | 用户自定义订单id过长 |
| TRADE_CLIENT_ORDER_ID_MATCH_ERROR | 用户自定义订单id仅支持字母(a-z)、数字(0-9)、符号(-,_) |
| TRADE_INVALID_SIDE | 订单side非法 |
| TRADE_INVALID_ORDER_TYPE | 订单类型非法 |
| TRADE_INVALID_TIME_IN_FORCE | timeInForce非法 |
| TRADE_INVALID_POC | 市价单timeInForce不能为poc |
| TRADE_INVALID_ORDER_QTY | 订单数量非法 |
| TRADE_INVALID_QUOTE_ORDER_QTY | 订单报价数量非法 |
| TRADE_INVALID_LIMIT_PRICE | 订单限价非法 |
| TRADE_INVALID_REDUCE_ONLY | 订单reduceOnly非法 |
| TRADE_ORDER_DUPLICATE_ERROR | 用户自定义订单id重复 |
| TRADE_SYM_NOT_SUPPORT | 当前symbol不支持 |
| MARGIN_ORDER_NOT_SUPPORT | 分所模式暂不支持现货杠杆功能 |
| TRADE_MARGIN_INVALID_PZ_SIDE_ERROR | 杠杆仅支持双向模式, 下单必须传LONG/SHORT |
| TRADE_DELIST_OPEN_PROHIBITED_ERROR | 币对已下架, 仅支持平仓操作 |
| TRADE_INVALID_POSITION_SIDE | positionSide非法 |
| TRADE_REDUCE_ONLY_SIDE_ERROR | reduceOnly订单不能与仓位方向相同 |
| TRADE_REDUCE_ONLY_POSITION_QTY_ERROR | 仓位量为0,无法reduceOnly |
| TRADE_ONE_OF_ORDER_ID_ERROR | 撤单orderId/text必须传一个 |
| TRADE_ORDER_NOT_FOUND_ERROR | 订单不存在或已终态 |
| TRADE_NOT_ALLOW_REPLACE | 市价单不允许改单 |
| TRADE_ORDER_REPLACE_QTY_PRICE_ERROR | 改单数量或价格违法 |
| TRADE_ORDER_REPLACE_QTY_PRICE_SAME_ERROR | 改单数量和价格与现有订单相同 |
| TRADE_ORDER_REPLACE_ALLOW_ERROR | 订单状态不允许改单 |
| TRADE_ORDER_LOT_SIZE_ERROR | 订单数量必须是lotSize的整数倍 |
| TRADE_ORDER_QUANTITY_MAX_ERROR | 订单数量超过了最大数量限制 |
| TRADE_ORDER_QUANTITY_MIN_ERROR | 订单数量超过了最小数量限制 |
| TRADE_ORDER_TICK_SIZE_ERROR | 订单价格必须是tickSize的整数倍 |
| TRADE_ORDER_AMOUNT_MIN_ERROR | 订单价值小于最小价值限制 |
| TRADE_OKX_LIMIT_BUY_ORDER_PRICE_ERROR | OKX限制价格偏离盘口过大 |
| TRADE_MAX_ORDERS_ERROR | 挂单数量超过限制 |
| TRADE_INVALID_PZ_MODE_ERROR | 仓位模式非法 |
label | 含义 |
|---|---|
| TRADE_SET_LEVERAGE_ERROR | 杠杆非法 |
| TRADE_INVALID_SYM_BUSINESSTYPE_ERROR | 调杠杆必须是合约币对 |
| TRADE_SET_LEVERAGE_EXCEED_LIMIT_ERROR | 杠杆超过了最大杠杆限制 |
| TRADE_INVALID_MARGIN_SYM_BUSINESSTYPE_ERROR | 调杠杆必须是杠杆币对 |
label | 含义 |
|---|---|
| CONVERT_TRADE_QUOTE_UNKNOWN_ERROR | 闪兑请求错误,请稍后再试 |
| CONVERT_TRADE_QUOTE_EXCHANGE_INVALID_ERROR | 交易所类型非法,请查看api文档 |
| CONVERT_TRADE_QUOTE_FROM_COIN_INVALID_ERROR | fromCoin非法,请查看api文档 |
| CONVERT_TRADE_QUOTE_TO_COIN_INVALID_ERROR | toCoin非法,请查看api文档 |
| CONVERT_TRADE_QUOTE_FROM_AMOUNT_INVALID_ERROR | fromAmount非法,请查看api文档 |
| CONVERT_TRADE_QUOTE_FROM_AMOUNT_LIMIT_ERROR | fromAmount非法,不允许为0 |
| CONVERT_TRADE_QUOTE_FROM_AMOUNT_MAX_ERROR | fromAmount非法,金额不允许超过10U |
| CONVERT_TRADE_QUOTE_EXCHANGE_REJECT_ERROR | 闪兑请求被交易所拒绝,请查看原因 |
label | 含义 |
|---|---|
| CAN_NOT_DELETE_POSITION | 仓位量已为0,无法一键平仓 |
| CAN_NOT_DELETE_LARGE_POSITION | 仓位量过大,请先通过下单平仓 |
| OPEN_ORDERS_CAN_NOT_DELETE_POSITION | 有挂单,无法一键平仓 |
示例代码
# coding: utf-8
import requests
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/rule/symbols'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
curl -X GET /rule/symbols \
-H 'Accept: application/json'
GET /rule/symbols
[公共接口]查询币对信息
查询交易对信息
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| symbols | 请求参数 | string | 否 | 币对列表,多个以逗号分隔 |
symbols: 币对列表,多个以逗号分隔
示例值: BINANCE_FUTURE_ADA_USDT,OKX_FUTURE_ADA_USDT
返回示例
200 返回
[
{
"symbol": "BINANCE_FUTURE_ADA_USDT",
"exchange_type": "BINANCE",
"business_type": "FUTURE",
"state": "live",
"min_size": "1",
"min_notional": "5",
"lot_size": "1",
"tick_size": "0.00010",
"max_num_orders": "200",
"max_market_size": "300000",
"max_limit_size": "2000000",
"contract_size": "1",
"liquidation_fee": "0.012500",
"default_leverage": "3",
"delist_time": "0"
},
{
"symbol": "OKX_FUTURE_ADA_USDT",
"exchange_type": "OKX",
"business_type": "FUTURE",
"state": "suspend",
"min_size": "10",
"min_notional": "0",
"lot_size": "10",
"tick_size": "0.0001",
"max_num_orders": "10",
"max_market_size": "1000000",
"max_limit_size": "10000000000",
"contract_size": "100",
"liquidation_fee": "0",
"default_leverage": "3",
"delist_time": "1762163297615"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Symbol] |
示例代码
# coding: utf-8
import requests
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/rule/risk_limits'
query_param = 'symbols=BINANCE_FUTURE_AAVE_USDT'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())
curl -X GET /rule/risk_limits?symbols=BINANCE_FUTURE_AAVE_USDT \
-H 'Accept: application/json'
GET /rule/risk_limits
[公共接口]查询风险限额信息
查询合约/杠杆交易对风险限额信息
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| symbols | 请求参数 | string | 是 | 币对列表,多个以逗号分隔 |
symbols: 币对列表,多个以逗号分隔 示例值: BINANCE_FUTURE_ADA_USDT,GATE_MARGIN_ADA_USDT
返回示例
200 返回
[
{
"symbol": "BINANCE_FUTURE_BTC_USDT",
"tiers": [
{
"min_risk_limit_value": "0",
"max_risk_limit_value": "50000",
"leverage_max": "20",
"maintenance_rate": "0.004",
"tier": "1"
},
{
"min_risk_limit_value": "50000",
"max_risk_limit_value": "100000",
"leverage_max": "18",
"maintenance_rate": "0.005",
"tier": "2"
}
]
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » symbol | string | |
| » tiers | array | |
| »» min_risk_limit_value | string | 最小风险限额价值 |
| »» max_risk_limit_value | string | 最大风险限额价值 |
| »» leverage_max | string | 最大杠杆 |
| »» maintenance_rate | string | 维持保证金率 |
| »» tier | string | 档位 |
示例代码
# coding: utf-8
import requests
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/transfers/coin'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
curl -X GET /transfers/coin \
-H 'Accept: application/json'
GET /transfers/coin
[公共接口]查询划转币种支持
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| coin | 请求参数 | string | 否 | 币种 |
返回示例
200 返回
[
{
"coin": "string",
"min_trans_amount": 0,
"est_fee": 0,
"precision": 0,
"is_disabled": 0
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » coin | string | 币种 |
| » min_trans_amount | number | 最小划转数量(需要加上预估手续费) |
| » est_fee | number | 预估手续费 |
| » precision | integer | 精度 |
| » is_disabled | integer | 是否禁用,0 表示未禁用 |
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/transfers'
query_param = ''
body='{"coin":"USDT","amount":"242.45","from":"SPOT","to":"CROSSEX"}'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="POST"
url="/transfers"
query_param=""
body_param='{"coin":"USDT","amount":"242.45","from":"SPOT","to":"CROSSEX"}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
POST /transfers
资金划转
限频:每10秒10次请求
from & to任意一侧必须为SPOT, 相应地另一侧应该是CROSSEX
如果填写的是CROSSEX_${exchange_type}(如CROSSEX_GATE),会默认为你设置为CROSSEXfrom & to任意一侧必须为CROSSEX_${exchange_type},相应地另一侧应该是SPOT或者CROSSEX_${exchange_type}
如果填写的是CROSSEX,会默认为你设置为CROSSEX_GATEfrom & to 任意一侧都不可以是CROSSEX,必须指定为CROSSEX_${exchange_type}CROSSEX_{exchange_type} 的划转,如from = CROSSEX_BINANCE , to = CROSSEX_GATE请求体示例
{
"coin": "USDT",
"amount": "242.45",
"from": "SPOT",
"to": "CROSSEX"
}
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| body | body | object | 否 | |
| » coin | body | string | 是 | 币种 |
| » amount | body | string | 是 | 转账数量 |
| » from | body | string | 是 | 转入账户: CROSSEX_BINANCE, CROSSEX_OKX, CROSSEX_GATE, CROSSEX, SPOT |
| » to | body | string | 是 | 转出账户: CROSSEX_BINANCE, CROSSEX_OKX, CROSSEX_GATE, CROSSEX, SPOT |
| » text | body | string | 否 | 用户自定义id |
返回示例
200 返回
{
"tx_id": "23453",
"text": "23453"
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | Inline |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » tx_id | string | 操作单号 |
| » text | string | 用户自定义订单号 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/transfers'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/transfers"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /transfers
查询资金划转历史
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| coin | 请求参数 | string | 否 | 指定币种名称查询 |
| order_id | 请求参数 | string | 否 | 支持查询创建订单时返回的订单ID即tx_id字段,支持用户创建时指定的自定义ID即text字段 |
| from | 请求参数 | integer | 否 | 查询记录的起始时间 |
| to | 请求参数 | integer | 否 | 查询记录的结束时间,不指定则默认为当前时间 |
| page | 请求参数 | integer | 否 | 列表页数 |
| limit | 请求参数 | integer | 否 | 列表返回的最大数量,最大1000 |
order_id: 支持查询创建订单时返回的订单ID即tx_id字段,支持用户创建时指定的自定义ID即text字段
返回示例
200 返回
[
{
"id": "33829017692939266",
"text": "33829017692939266",
"from_account_type": "CROSSEX_BINANCE",
"to_account_type": "CROSSEX_OKX",
"coin": "BTC",
"amount": "1.1234567",
"actual_receive": "1.123",
"status": "SUCCESS",
"fail_reason": null,
"create_time": 1750681141933,
"update_time": 1750681141933
},
{
"id": "38083797492939266",
"text": "38083797492939266",
"from_account_type": "CROSSEX",
"to_account_type": "SPOT",
"coin": "USDT",
"amount": "100",
"actual_receive": null,
"status": "FAIL",
"fail_reason": "Insufficient transferAvailable",
"create_time": 1750681141933,
"update_time": 1750681141933
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » id | string | 订单 ID |
| » text | string | 客户自定义Id |
| » from_account_type | string | 操作的from账户(CROSSEX_BINANCE, CROSSEX_OKX, CROSSEX_GATE, CROSSEX,SPOT) |
| » to_account_type | string | |
| » coin | string | 币种 |
| » amount | string | 转账数量,发起请求转账的数量 |
| » actual_receive | string | 真实到帐金额(当 status = SUCCESS 时有值,其余状态时为空) |
| » status | string | 划转状态 - FAIL : 失败- SUCCESS : 成功- PENDING : 划转执行中 |
| » fail_reason | string | 失败原因(当 status = FAIL时有值,其余状态时为空) |
| » create_time | integer | 订单创建时间 |
| » update_time | integer | 订单更新时间 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/orders'
query_param = ''
body='{"symbol":"BINANCE_SPOT_ADA_USDT","side":"BUY","type":"MARKET","quote_qty":"10"}'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="POST"
url="/orders"
query_param=""
body_param='{"symbol":"BINANCE_SPOT_ADA_USDT","side":"BUY","type":"MARKET","quote_qty":"10"}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
POST /orders
下单
限频:每10秒100次请求
请求体示例
{
"symbol": "BINANCE_SPOT_ADA_USDT",
"side": "BUY",
"type": "MARKET",
"quote_qty": "10"
}
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| body | body | object | 否 | |
| » text | body | string | 否 | 客户定义的订单ID,仅支持字母(a-z)、数字(0-9)、符号(-,_) |
| » symbol | body | string | 是 | 唯一标识 Exchange_Business_Base_Counter |
| » side | body | string | 是 | BUY, SELL |
| » type | body | string | 否 | 订单类型(默认LIMIT,支持类型列举:LIMIT、MARKET) |
| » time_in_force | body | string | 否 | 默认GTC,支持类型枚举,GTC,IOC,FOK,POC |
| » qty | body | string | 否 | 订单数量(强制性,除非现货市价买入) |
| » price | body | string | 否 | 限价订单价格(限价订单必须) |
| » quote_qty | body | string | 否 | 订单报价数量,现货和杠杆市价买单必传 |
| » reduce_only | body | string | 否 | 只减仓:true或者false |
| » position_side | body | string | 否 | 仓位方向:NONE, LONG, SHORT |
» symbol: 唯一标识 Exchange_Business_Base_Counter
示例:
如果您想在币安交易所上为ADA/USDT交易对下现货订单,您可以使用这样的唯一标识符:BINANCE_SPOT_ADA_USDT;
如果您想在欧易交易所上为ADA/USDT交易对下U本位永续合约订单,您可以使用这样的唯一标识符:OKX_FUTURE_ADA_USDT;
如果您想在Gate交易所上为ADA/USDT交易对下现货杠杆订单,您可以使用这样的唯一标识符:GATE_MARGIN_ADA_USDT;
目前支持三种订单:现货订单、U本位永续合约订单和现货杠杆订单
» time_in_force: 默认GTC,支持类型枚举,GTC,IOC,FOK,POC GTC: GoodTillCancelled
IOC: ImmediateOrCancelled
FOK: FillOrKill
POC: PendingOrCancelled or PostOnly
» position_side: 仓位方向:NONE, LONG, SHORT
不传默认单向持仓NONE
| 参数 | 值 |
|---|---|
| » side | BUY |
| » side | SELL |
| » type | LIMIT |
| » type | MARKET |
| » time_in_force | GTC |
| » time_in_force | IOC |
| » time_in_force | FOK |
| » time_in_force | POC |
| » reduce_only | true |
| » reduce_only | false |
| » position_side | LONG |
| » position_side | SHORT |
| » position_side | NONE |
返回示例
200 返回
{
"order_id": 123456,
"text": "cross-test-1"
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | Inline |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » order_id | string | 订单号 |
| » text | string | 用户自定义订单号 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/orders/string'
query_param = ''
body='{}'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('DELETE', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url, headers=headers, data=body)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="DELETE"
url="/orders/string"
query_param=""
body_param='{}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
DELETE /orders/{order_id}
撤单
限频:每10秒100次请求
请求体示例
{}
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| order_id | URL | string | 是 | 支持订单id或text撤单 |
| body | body | object | 否 |
返回示例
200 返回
{
"order_id": 123456,
"text": "crossex-test-1"
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | Inline |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/orders/string'
query_param = ''
body='{"qty":"20","price":"0.65"}'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('PUT', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('PUT', host + prefix + url, headers=headers, data=body)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="PUT"
url="/orders/string"
query_param=""
body_param='{"qty":"20","price":"0.65"}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
PUT /orders/{order_id}
改单
限频:每10秒100次请求
请求体示例
{
"qty": "20",
"price": "0.65"
}
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| order_id | URL | string | 是 | 支持订单id或text改单 |
| body | body | object | 否 | |
| » qty | body | string | 否 | 修改数量 |
| » price | body | string | 否 | 修改价格 |
返回示例
200 返回
{
"order_id": 123,
"text": "crossx-test-1"
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | Inline |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » order_id | number | |
| » text | string |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/orders/2048522992198912'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/orders/2048522992198912"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /orders/{order_id}
查询订单详情
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| order_id | URL | string | 是 | 1. 支持查询创建订单时返回的订单 ID |
order_id: 1. 支持查询创建订单时返回的订单 ID 2. 支持用户创建时指定的自定义 ID(即 text 字段)
返回示例
200 返回
{
"user_id": "10001004",
"order_id": "2048522992198912",
"text": "2048522992198912",
"state": "FILLED",
"symbol": "BINANCE_SPOT_ADA_USDT",
"side": "BUY",
"type": "MARKET",
"attribute": "COMMON",
"exchange_type": "BINANCE",
"business_type": "SPOT",
"qty": "0",
"quote_qty": "7",
"price": "0",
"tif": "GTC",
"executed_qty": "12.9",
"executed_amount": "6.96471",
"executed_avg_price": "0.5399",
"fee_currency": "ADA",
"fee": "0.0129",
"reduce_only": "false",
"leverage": "1",
"reason": "",
"last_executed_qty": "12.9",
"last_executed_price": "0.5399",
"last_executed_amount": "6.96471",
"position_side": "NONE",
"create_time": "1750681141933",
"update_time": "1750681142379"
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | Inline |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » user_id | string | 用户id |
| » order_id | string | 订单号 |
| » text | string | 客户订单号 |
| » state | string | 订单状态 |
| » symbol | string | 交易对 |
| » side | string | 方向 |
| » type | string | 类型 |
| » attribute | string | 属性COMMON: 普通单 LIQ: 强平接管单 REDUCE: 强平减仓单 ADL:自动减仓 |
| » exchange_type | string | 交易所 |
| » business_type | string | 业务类型 |
| » qty | string | 基础货币数量 |
| » quote_qty | string | 报价币种数量 |
| » price | string | 价格 |
| » time_in_force | string | Time in force 策略 |
| » executed_qty | string | 已成交数量 |
| » executed_amount | string | 已成交金额 |
| » executed_avg_price | string | 已成交均价 |
| » fee_coin | string | 手续费币种 |
| » fee | string | 手续费 |
| » reduce_only | string | 只减仓 |
| » leverage | string | 杠杆 |
| » reason | string | 原因 |
| » last_executed_qty | string | 最新已成交量 |
| » last_executed_price | string | 最新已成交价 |
| » last_executed_amount | string | 最新已成交金额 |
| » position_side | string | 仓位方向 |
| » create_time | string | 创建时间 |
| » update_time | string | 更新时间 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/convert/quote'
query_param = ''
body='{"exchange_type":"GATE","from_coin":"BTC","to_coin":"USDT","from_amount":"0.00008"}'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="POST"
url="/convert/quote"
query_param=""
body_param='{"exchange_type":"GATE","from_coin":"BTC","to_coin":"USDT","from_amount":"0.00008"}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
POST /convert/quote
闪兑询价
限频:每天100次请求
请求体示例
{
"exchange_type": "GATE",
"from_coin": "BTC",
"to_coin": "USDT",
"from_amount": "0.00008"
}
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| body | body | object | 否 | |
| » exchange_type | body | string | 是 | 交易所类型 |
| » from_coin | body | string | 是 | 卖出的资产 |
| » to_coin | body | string | 是 | 买入的资产名称(OKX, GATE 只允许买入BTC, ETH, USDT, BN 只允许买入USDT) |
| » from_amount | body | string | 是 | 卖出的资产数量 |
返回示例
200 返回
{
"quote_id": "2074460878500352",
"valid_ms": "5000",
"from_coin": "USDT",
"to_coin": "BTC",
"from_amount": "3",
"to_amount": "0.000027",
"price": "0.000009"
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | Inline |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » quote_id | string | 报价id |
| » valid_ms | string | 有效时间(毫秒时间戳) |
| » from_coin | string | 卖出的资产 |
| » to_coin | string | 买入的资产 |
| » from_amount | string | 卖出的资产数量 |
| » to_amount | string | 买入的资产数量 |
| » price | string | 价格 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/convert/orders'
query_param = ''
body='{"quote_id":"232321331"}'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="POST"
url="/convert/orders"
query_param=""
body_param='{"quote_id":"232321331"}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
POST /convert/orders
闪兑交易
限频:每10秒10次请求
请求体示例
{
"quote_id": "232321331"
}
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| body | body | object | 否 | |
| » quote_id | body | string | 是 | 询价ID |
返回示例
200 返回
{}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | Inline |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/accounts'
query_param = ''
body='{"position_mode":"string","account_mode":"string","exchange_type":"string"}'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('PUT', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('PUT', host + prefix + url, headers=headers, data=body)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="PUT"
url="/accounts"
query_param=""
body_param='{"position_mode":"string","account_mode":"string","exchange_type":"string"}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
PUT /accounts
更改账户合约仓位模式或账户模式
限频:每60秒100次请求,position_mode+exchange_type更改合约仓位模式(当前用户的账户模式为分所时,exchange_type必传);account_mode更改用户的账户模式。
请求体示例
{
"position_mode": "string",
"account_mode": "string",
"exchange_type": "string"
}
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| body | body | object | 否 | |
| » position_mode | body | string | 否 | 合约仓位模式(SINGLE/DUAL) |
| » account_mode | body | string | 否 | 账户模式(CROSS_EXCHANGE/ISOLATED_EXCHANGE,默认:CROSS_EXCHANGE) |
| » exchange_type | body | string | 否 | 交易所(BINANCE/OKX/GATE/CROSSEX,当账户模式为ISOLATED_EXCHANGE时,修改合约仓位模式必须指定交易所) |
返回示例
202 返回
{
"position_mode": "string",
"account_mode": "string",
"exchange_type": "string"
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 202 | Accepted (opens new window) | none | Inline |
状态码 202
| 名称 | 类型 | 描述 |
|---|---|---|
| » position_mode | string | 请求修改的合约仓位模式(SINGLE/DUAL) |
| » account_mode | string | 请求修改的账户模式(CROSS_EXCHANGE/ISOLATED_EXCHANGE,默认:CROSS_EXCHANGE) |
| » exchange_type | string | 请求修改的交易所(BINANCE/OKX/GATE/CROSSEX,当账户模式为ISOLATED_EXCHANGE时,修改合约仓位模式必须指定交易所) |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/accounts'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/accounts"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /accounts
查询账户资产
限频:每10秒200次请求 100% <= initial_margin_rate < 110%,禁止划出保证金币种。 initial_margin_rate < 100%,系统自动撤单,只能平仓不能开仓 maintenance_margin_rate <= 100%,系统强制平仓
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| exchange_type | 请求参数 | string | 否 | 交易所。当跨所模式下不用传,当分所模式下必传(BINANCE/OKX/GATE) |
返回示例
200 返回
{
"user_id": "123456789",
"available_margin": "1200",
"margin_balance": "1200",
"initial_margin": "500",
"maintenance_margin": "250",
"initial_margin_rate": "2.4",
"maintenance_margin_rate": "4.8",
"position_mode": "SINGLE",
"account_limit": "5000",
"create_time": "1687573845000",
"update_time": "1687588938000",
"account_mode": "CROSS_EXCHANGE",
"exchange_type": "CROSSEX",
"assets": [
{
"user_id": "123456789",
"coin": "USDT",
"exchange_type": "BINANCE",
"balance": "1000",
"upnl": "200",
"equity": "1200",
"futures_initial_margin": "400",
"futures_maintenance_margin": "130",
"borrowing_initial_margin": "100",
"borrowing_maintenance_margin": "120",
"available_balance": "1000.0",
"liability": "0"
}
]
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | Inline |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » user_id | string | 用户id |
| » available_margin | string | 可用保证金 |
| » margin_balance | string | 保证金余额 |
| » initial_margin | string | 初始保证金 |
| » maintenance_margin | string | 维持保证金 |
| » initial_margin_rate | string | 初始保证金率 |
| » maintenance_margin_rate | string | 维持保证金率 |
| » position_mode | string | 合约仓位模式 |
| » account_limit | string | 账户限额 |
| » create_time | string | 创建时间 |
| » update_time | string | 更新时间 |
| » account_mode | string | 账户模式。CROSS_EXCHANGE:跨所模式。ISOLATED_EXCHANGE:分所模式 |
| » exchange_type | string | 交易所类型。当account_mode为CROSS_EXCHANGE时,必为CROSSEX。否则则为其他交易所 |
| » assets | array | |
| »» user_id | string | 用户id |
| »» coin | string | 币种 |
| »» exchange_type | string | 交易所 |
| »» balance | string | 余额 |
| »» upnl | string | 未结盈亏 |
| »» equity | string | 权益(只有USDT才有值,其他资产为0) |
| »» futures_initial_margin | string | 合约初始保证金(只有USDT才有值,其他资产为0) |
| »» futures_maintenance_margin | string | 合约维持保证金(只有USDT才有值,其他资产为0) |
| »» borrowing_initial_margin | string | 杠杆交易初始保证金(只有USDT才有值,其他资产为0) |
| »» borrowing_maintenance_margin | string | 杠杆交易维持保证金(只有USDT才有值,其他资产为0) |
| »» available_balance | string | 可用余额 |
| »» liability | string | 负债(仅分所模式下才有意义。跨所模式下始终为0) |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/positions/leverage'
query_param = ''
body='{"symbol":"OKX_FUTURE_ADA_USDT","leverage":"1"}'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="POST"
url="/positions/leverage"
query_param=""
body_param='{"symbol":"OKX_FUTURE_ADA_USDT","leverage":"1"}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
POST /positions/leverage
更改合约交易币对的杠杆倍数
限频:每10秒100次请求
请求体示例
{
"symbol": "OKX_FUTURE_ADA_USDT",
"leverage": "1"
}
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| body | body | object | 否 | |
| » symbol | body | string | 是 | 交易对 |
| » leverage | body | string | 是 | 杠杆 |
返回示例
202 返回
{
"symbol": "string",
"leverage": "string"
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 202 | Accepted (opens new window) | none | Inline |
状态码 202
| 名称 | 类型 | 描述 |
|---|---|---|
| » symbol | string | 交易对 |
| » leverage | string | 请求修改的杠杆倍数 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/positions/leverage'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/positions/leverage"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /positions/leverage
查询合约交易对的杠杆倍数
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| symbols | 请求参数 | string | 否 | 币对列表,多个以逗号分隔 |
返回示例
200 返回
[
{
"symbol": "BINANCE_FUTURE_ADA_USDT",
"leverage": 10
},
{
"symbol": "OKX_FUTURE_ADA_USDT",
"leverage": 5
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » symbol | string | 交易对 |
| » leverage | string | 杠杆 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/margin_positions/leverage'
query_param = ''
body='{"symbol":"OKX_MARGIN_ADA_USDT","leverage":"1"}'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="POST"
url="/margin_positions/leverage"
query_param=""
body_param='{"symbol":"OKX_MARGIN_ADA_USDT","leverage":"1"}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
POST /margin_positions/leverage
更改杠杆交易币对的杠杆倍数
限频:每10秒100次请求
请求体示例
{
"symbol": "OKX_MARGIN_ADA_USDT",
"leverage": "1"
}
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| body | body | object | 否 | |
| » symbol | body | string | 是 | 交易对 |
| » leverage | body | string | 是 | 杠杆 |
返回示例
202 返回
{
"symbol": "string",
"leverage": "string"
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 202 | Accepted (opens new window) | none | Inline |
状态码 202
| 名称 | 类型 | 描述 |
|---|---|---|
| » symbol | string | 交易对 |
| » leverage | string | 请求修改的杠杆倍数 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/margin_positions/leverage'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/margin_positions/leverage"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /margin_positions/leverage
查询杠杆交易对的杠杆倍数
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| symbols | 请求参数 | string | 否 | 币对列表,多个以逗号分隔 |
返回示例
200 返回
[
{
"symbol": "BINANCE_MARGIN_ADA_USDT",
"leverage": "10"
},
{
"symbol": "OKX_MARGIN_ADA_USDT",
"leverage": "5"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » symbol | string | 交易对 |
| » leverage | string | 杠杆 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/position'
query_param = ''
body='{"symbol":"BINANCE_FUTURE_SOL_USDT","position_side":"LONG"}'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('DELETE', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url, headers=headers, data=body)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="DELETE"
url="/position"
query_param=""
body_param='{"symbol":"BINANCE_FUTURE_SOL_USDT","position_side":"LONG"}'
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
DELETE /position
完全平仓
限频:每天100次请求。自动平仓规则。支持平仓FUTURE仓位或者MARGIN仓位
使用本接口前,需要满足以下前置条件:
满足条件后,系统将自动生成一笔平仓委托,并对该仓位进行立即的完全平仓处理。 该接口用于避免因订单规模过小而触发无法在交易所下单的问题,确保小额仓位在达到阈值时能够顺利被平掉。
请求体示例
{
"symbol": "BINANCE_FUTURE_SOL_USDT",
"position_side": "LONG"
}
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| body | body | object | 否 | |
| » symbol | body | string | 是 | 交易币对 |
| » position_side | body | string | 否 | 仓位方向 |
» symbol: 交易币对
» position_side: 仓位方向
返回示例
202 返回
{
"order_id": "123456",
"text": "123456"
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 202 | Accepted (opens new window) | none | Inline |
状态码 202
| 名称 | 类型 | 描述 |
|---|---|---|
| » order_id | string | 订单号 |
| » text | string | 用户自定义订单号 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/interest_rate'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/interest_rate"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /interest_rate
查询杠杆币种利率
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| coin | 请求参数 | string | 否 | 币种 |
| exchange_type | 请求参数 | string | 否 | 交易所 |
返回示例
200 返回
[
{
"coin": "BCH",
"exchange_type": "GATE",
"hour_interest_rate": "0.00000485",
"time": "1763971200000"
},
{
"coin": "ADA",
"exchange_type": "BINANCE",
"hour_interest_rate": "0.0000036558334",
"time": "1763971200000"
},
{
"coin": "BCH",
"exchange_type": "OKX",
"hour_interest_rate": "0.00000115",
"time": "1763971200000"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » coin | string | 币种 |
| » exchange_type | string | 交易所 |
| » hour_interest_rate | string | 小时利率 |
| » time | string | 毫秒时间戳 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/fee'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/fee"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /fee
查询用户手续费率
限频:每10秒200次请求
返回示例
200 返回
{
"spot_maker_fee": "0.00019",
"spot_taker_fee": "0.0003",
"future_maker_fee": "0.00004",
"future_taker_fee": "0.00022",
"special_fee_list": [
{
"symbol": "OKX_SPOT_WIF_USDT",
"taker_fee_rate": "0.0004",
"maker_fee_rate": "0.00019"
},
{
"symbol": "OKX_SPOT_UNI_USDT",
"taker_fee_rate": "0.0004",
"maker_fee_rate": "0.00019"
},
{
"symbol": "OKX_MARGIN_BCH_USDT",
"taker_fee_rate": "0.0004",
"maker_fee_rate": "0.00019"
},
{
"symbol": "OKX_MARGIN_LTC_USDT",
"taker_fee_rate": "0.0004",
"maker_fee_rate": "0.00019"
}
]
}
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | Inline |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » spot_maker_fee | string | 现货Maker费率 |
| » spot_taker_fee | string | 现货Taker费率 |
| » future_maker_fee | string | 合约Maker费率 |
| » future_taker_fee | string | 合约Taker费率 |
| » special_fee_list | array | |
| »» symbol | string | 交易对 |
| »» taker_fee_rate | string | Taker费率 |
| »» maker_fee_rate | string | Maker费率 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/positions'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/positions"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /positions
查询合约仓位
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| symbol | 请求参数 | string | 否 | 币对 |
| exchange_type | 请求参数 | string | 否 | 交易所 |
返回示例
200 返回
[
{
"user_id": "10001004",
"position_id": "20062926505289216",
"symbol": "OKX_FUTURE_ADA_USDT",
"position_side": "LONG",
"initial_margin": "5.79934625",
"maintenance_margin": "0.06229625",
"position_qty": "10",
"position_value": "5.795",
"upnl": "0.369",
"upnl_rate": "0.068005897530409141",
"avg_price": "0.5426",
"mark_price": "0.5795",
"leverage": "1",
"max_leverage": "18",
"risk_limit": "1",
"fee": "0.002713",
"funding_fee": "0",
"funding_time": "0",
"create_time": "1750682334273",
"update_time": "1750730699867",
"closed_pnl": "12"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » user_id | string | 用户id |
| » position_id | string | 仓位id |
| » symbol | string | 交易对 |
| » position_side | string | 仓位方向 |
| » initial_margin | string | 初始保证金 |
| » maintenance_margin | string | 维持保证金 |
| » position_qty | string | 仓位数量 |
| » position_value | string | 仓位价值 |
| » upnl | string | 未结盈亏 |
| » upnl_rate | string | 未结盈亏比 |
| » entry_price | string | 仓位入场均价 |
| » mark_price | string | 标记价格 |
| » leverage | string | 仓位杠杆 |
| » max_leverage | string | 最大杠杆 |
| » risk_limit | string | 风险限额 |
| » fee | string | 仓位手续费 |
| » funding_fee | string | 仓位资金费 |
| » funding_time | string | 仓位资金费收取时间(0代表还未收取过) |
| » create_time | string | 仓位创建时间 |
| » update_time | string | 仓位更新时间 |
| » closed_pnl | string | 已结盈亏 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/margin_positions'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/margin_positions"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /margin_positions
查询杠杆仓位
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| symbol | 请求参数 | string | 否 | 交易对 |
| exchange_type | 请求参数 | string | 否 | 交易所 |
返回示例
200 返回
[
{
"user_id": "12345",
"position_id": "20126312530221056",
"symbol": "BINANCE_MARGIN_ADA_USDT",
"position_side": "LONG",
"initial_margin": "0",
"maintenance_margin": "0",
"asset_qty": "0",
"asset_coin": "ADA",
"position_value": "0",
"liability": "0.0001708920658",
"liability_coin": "USDT",
"interest": "0.0001708920658",
"max_position_qty": "0",
"entry_price": "0",
"index_price": "0.35466844",
"upnl": "-0.0001708920658",
"upnl_rate": "-3",
"leverage": "3",
"max_leverage": "5",
"create_time": "1765794740152",
"update_time": "1766716075010"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » user_id | string | 用户id |
| » position_id | string | 杠杆仓位Id |
| » symbol | string | 币对 |
| » position_side | string | 仓位方向 |
| » initial_margin | string | 仓位初始保证金 |
| » maintenance_margin | string | 仓位维持保证金 |
| » asset_qty | string | 仓位资产数量 |
| » asset_coin | string | 仓位资产币种 |
| » position_value | string | 仓位价值 |
| » liability | string | 负债数量 |
| » liability_coin | string | 负债币种 |
| » interest | string | 已扣利息 |
| » max_position_qty | string | 最大持仓量 |
| » entry_price | string | 持仓成本价(开仓均价) |
| » index_price | string | 指数价格 |
| » upnl | string | 未结盈亏 |
| » upnl_rate | string | 未结盈亏比 |
| » leverage | string | 开仓杠杆 |
| » max_leverage | string | 最大杠杆 |
| » create_time | string | 创建时间 |
| » update_time | string | 更新时间 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/adl_rank'
query_param = 'symbol=BINANCE_FUTURE_ADA_USDT'
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/adl_rank"
query_param="symbol=BINANCE_FUTURE_ADA_USDT"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /adl_rank
查询ADL减仓灯
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| symbol | 请求参数 | string | 是 | 币对 |
返回示例
200 返回
[
{
"user_id": "111",
"symbol": "BINANCE_FUTURE_ADA_USDT",
"crossex_adl_rank": "1",
"exchange_adl_rank": "1"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » user_id | string | 用户id |
| » symbol | string | 交易对 |
| » crossex_adl_rank | string | crossex减仓灯排名(1-5,数字越大排名越前) |
| » exchange_adl_rank | string | 交易所原始信息(币安:0-4,数字越大越靠前,OKX:0-5,数字越大越靠前,Gate:1-5,数字越小越靠前) |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/open_orders'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/open_orders"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /open_orders
查询当前所有挂单
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| symbol | 请求参数 | string | 否 | 币对 |
| exchange_type | 请求参数 | string | 否 | 交易所 |
| business_type | 请求参数 | string | 否 | 业务类型 |
返回示例
200 返回
[
{
"user_id": "10001004",
"order_id": "2048529119934720",
"client_order_id": "2048529119934720",
"state": "PARTIALLY_FILLED",
"symbol": "OKX_SPOT_ADA_USDT",
"side": "BUY",
"type": "MARKET",
"attribute": "COMMON",
"exchange_type": "OKX",
"business_type": "SPOT",
"qty": "6",
"quote_qty": "6",
"price": "0",
"time_in_force": "GTC",
"executed_qty": "11.0354",
"executed_amount": "5.99994698",
"executed_avg_price": "0.5437",
"fee_coin": "ADA",
"fee": "0.0110354",
"reduce_only": "false",
"leverage": "1",
"reason": "",
"last_executed_qty": "11.0354",
"last_executed_price": "0.5437",
"last_executed_amount": "5.99994698",
"position_side": "NONE",
"create_time": "1750682602377",
"update_time": "1750682602413"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » user_id | string | 用户id |
| » order_id | string | 订单号 |
| » text | string | 客户订单号 |
| » state | string | 订单状态 |
| » symbol | string | 交易对 |
| » side | string | 方向 |
| » type | string | 类型 |
| » attribute | string | 属性COMMON: 普通单 LIQ: 强平接管单 REDUCE: 强平减仓单 ADL:自动减仓 |
| » exchange_type | string | 交易所 |
| » business_type | string | 业务类型 |
| » qty | string | 基础货币数量 |
| » quote_qty | string | 报价币种数量 |
| » price | string | 价格 |
| » time_in_force | string | Time in force 策略 |
| » executed_qty | string | 已成交数量 |
| » executed_amount | string | 已成交金额 |
| » executed_avg_price | string | 已成交均价 |
| » fee_coin | string | 手续费币种 |
| » fee | string | 手续费 |
| » reduce_only | string | 只减仓 |
| » leverage | string | 杠杆 |
| » reason | string | 原因 |
| » last_executed_qty | string | 最新已成交量 |
| » last_executed_price | string | 最新已成交价 |
| » last_executed_amount | string | 最新已成交金额 |
| » position_side | string | 仓位方向 |
| » create_time | string | 创建时间 |
| » update_time | string | 更新时间 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/history_orders'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/history_orders"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /history_orders
查询订单历史
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| page | 请求参数 | integer | 否 | 列表页数 |
| limit | 请求参数 | integer | 否 | 列表返回的最大数量 |
| symbol | 请求参数 | string | 否 | |
| from | 请求参数 | integer | 否 | 起始毫秒时间戳 |
| to | 请求参数 | integer | 否 | 终止毫秒时间戳 |
返回示例
200 返回
[
{
"user_id": "10001004",
"order_id": "2048522992198912",
"text": "2048522992198912",
"state": "FILLED",
"symbol": "BINANCE_SPOT_ADA_USDT",
"side": "BUY",
"type": "MARKET",
"attribute": "COMMON",
"exchange_type": "BINANCE",
"business_type": "SPOT",
"qty": "0",
"quote_qty": "7",
"price": "0",
"tif": "GTC",
"executed_qty": "12.9",
"executed_amount": "6.96471",
"executed_avg_price": "0.5399",
"fee_currency": "ADA",
"fee": "0.0129",
"reduce_only": "false",
"leverage": "1",
"reason": "",
"last_executed_qty": "12.9",
"last_executed_price": "0.5399",
"last_executed_amount": "6.96471",
"position_side": "NONE",
"create_time": "1750681141933",
"update_time": "1750681142379"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » user_id | string | 用户id |
| » order_id | string | 订单号 |
| » text | string | 客户订单号 |
| » state | string | 订单状态 |
| » symbol | string | 交易对 |
| » attribute | string | 属性COMMON: 普通单 LIQ: 强平接管单 REDUCE: 强平减仓单 ADL:自动减仓 |
| » exchange_type | string | 交易所 |
| » business_type | string | 业务类型 |
| » qty | string | 基础货币数量 |
| » quote_qty | string | 报价币种数量 |
| » price | string | 价格 |
| » time_in_force | string | Time in force 策略 |
| » executed_qty | string | 已成交数量 |
| » executed_amount | string | 已成交金额 |
| » executed_avg_price | string | 已成交均价 |
| » fee_coin | string | 手续费币种 |
| » fee | string | 手续费 |
| » reduce_only | string | 只减仓 |
| » leverage | string | 杠杆 |
| » reason | string | 原因 |
| » last_executed_qty | string | 最新已成交量 |
| » last_executed_price | string | 最新已成交价 |
| » last_executed_amount | string | 最新已成交金额 |
| » position_side | string | 仓位方向 |
| » create_time | string | 创建时间 |
| » update_time | string | 更新时间 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/history_positions'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/history_positions"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /history_positions
查询合约仓位历史
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| page | 请求参数 | integer | 否 | 列表页数 |
| limit | 请求参数 | integer | 否 | 列表返回的最大数量,最大1000 |
| symbol | 请求参数 | string | 否 | |
| from | 请求参数 | integer | 否 | 起始毫秒时间戳 |
| to | 请求参数 | integer | 否 | 终止毫秒时间戳 |
返回示例
200 返回
[
{
"position_id": "20064013106942976",
"user_id": "12345678",
"symbol": "BINANCE_FUTURE_ADA_USDT",
"closed_type": "COMPLETE_CLOSED",
"closed_pnl": "-0.001",
"closed_pnl_rate": "-0.001",
"open_avg_price": "0.5598",
"closed_avg_price": "0.5597",
"max_position_qty": "10",
"closed_qty": "10",
"closed_value": "5.597",
"fee": "0.0055975",
"liq_fee": "0",
"funding_fee": "0",
"position_side": "LONG",
"position_mode": "DUAL",
"leverage": 1,
"create_time": "1750941400632",
"update_time": "1750941402661"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » position_id | string | 仓位id |
| » user_id | string | 用户id |
| » symbol | string | 交易对 |
| » closed_type | string | 平仓类型(PARTIAL_CLOSED 部分成交,COMPLETE_CLOSED 完全成交) |
| » closed_pnl | string | 平仓盈亏 |
| » closed_pnl_rate | string | 平仓盈亏率 |
| » open_avg_price | string | 开仓均价 |
| » closed_avg_price | string | 平仓均价 |
| » max_position_qty | string | 最大持仓量 |
| » closed_qty | string | 平仓量 |
| » closed_value | string | 平仓价值 |
| » fee | string | 仓位累计手续费 |
| » liq_fee | string | 强平费 |
| » funding_fee | string | 资金费 |
| » position_side | string | 平仓前仓位方向 |
| » position_mode | string | 平仓时的仓位模式 |
| » leverage | string | 平仓时的杠杆 |
| » business_type | string | 业务类型 |
| » create_time | string | 创建时间 |
| » update_time | string | 更新时间 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/history_margin_positions'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/history_margin_positions"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /history_margin_positions
查询杠杆仓位历史
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| page | 请求参数 | integer | 否 | 列表页数 |
| limit | 请求参数 | integer | 否 | 列表返回的最大数量,最大1000 |
| symbol | 请求参数 | string | 否 | |
| from | 请求参数 | integer | 否 | 起始毫秒时间戳 |
| to | 请求参数 | integer | 否 | 终止毫秒时间戳 |
返回示例
200 返回
[
{
"position_id": "20064013106942976",
"user_id": "12345678",
"symbol": "BINANCE_FUTURE_ADA_USDT",
"closed_type": "COMPLETE_CLOSED",
"closed_pnl": "-0.001",
"closed_pnl_rate": "-0.001",
"open_avg_price": "0.5598",
"closed_avg_price": "0.5597",
"max_position_qty": "10",
"closed_qty": "10",
"closed_value": "5.597",
"liq_fee": "0",
"position_side": "LONG",
"leverage": "1",
"interest": "0.2",
"bussiness_type": "MARGIN",
"create_time": "1750941400632",
"update_time": "1750941402661"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » position_id | string | 仓位id |
| » user_id | string | 用户id |
| » symbol | string | 交易对 |
| » closed_type | string | 平仓类型(PARTIAL_CLOSED 部分成交,COMPLETE_CLOSED 完全成交) |
| » closed_pnl | string | 平仓盈亏 |
| » closed_pnl_rate | string | 平仓盈亏率 |
| » open_avg_price | string | 开仓均价 |
| » closed_avg_price | string | 平仓均价 |
| » max_position_qty | string | 最大持仓量 |
| » closed_qty | string | 平仓量 |
| » closed_value | string | 平仓价值 |
| » liq_fee | string | 强平费 |
| » position_side | string | 平仓前仓位方向 |
| » leverage | string | 平仓时的杠杆 |
| » interest | string | 已扣总利息 |
| » business_type | string | 仓位业务类型 |
| » create_time | string | 创建时间 |
| » update_time | string | 更新时间 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/history_margin_interests'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/history_margin_interests"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /history_margin_interests
查询杠杆扣息历史
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| symbol | 请求参数 | string | 否 | |
| from | 请求参数 | integer | 否 | |
| to | 请求参数 | integer | 否 | |
| page | 请求参数 | integer | 否 | |
| limit | 请求参数 | integer | 否 | |
| exchange_type | 请求参数 | string | 否 |
返回示例
200 返回
[
{
"user_id": "2124575357",
"symbol": "OKX_MARGIN_WLD_USDT",
"interest_id": "2115944013038336",
"liability_id": "2115944013038080",
"liability": "2",
"liability_coin": "USDT",
"interest": "0.00000732",
"interest_rate": "0.00000366",
"interest_type": "IMMEDIATE_OPEN_ORDER",
"create_time": "1766755565807",
"exchange_type": "OKX"
},
{
"user_id": "2124575357",
"symbol": "OKX_MARGIN_WLD_USDT",
"interest_id": "2114666587422976",
"liability_id": "2114666587422720",
"liability": "2",
"liability_coin": "USDT",
"interest": "0.00000732",
"interest_rate": "0.00000366",
"interest_type": "IMMEDIATE_OPEN_ORDER",
"create_time": "1766451003780",
"exchange_type": ""
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » userId | string | 用户Id |
| » symbol | string | 币对 |
| » interest_id | string | 扣息Id |
| » liability_id | string | 负债源Id,可以是挂单Id 或者仓位Id |
| » liability | string | 负债数量 |
| » liability_coin | string | 负债币种 |
| » interest | string | 利息 |
| » interest_rate | string | 利率 |
| » interest_type | string | 扣息类型(PERIODIC_POSITION 整点仓位收息,PERIODIC_OPEN_ORDER 整点挂单收息,IMMEDIATE_OPEN_ORDER 开单收息) |
| » create_time | string | 创建时间 |
| » exchange_type | string | 交易所 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/history_trades'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/history_trades"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /history_trades
查询成交历史
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| page | 请求参数 | integer | 否 | 列表页数 |
| limit | 请求参数 | integer | 否 | 列表返回的最大数量,最大1000 |
| symbol | 请求参数 | string | 否 | |
| from | 请求参数 | integer | 否 | 起始毫秒时间戳 |
| to | 请求参数 | integer | 否 | 终止毫秒时间戳 |
返回示例
200 返回
[
{
"user_id": "3511316454450547",
"transaction_id": "2049614605858560",
"order_id": "2049614605857536",
"text": "2049614605857536",
"symbol": "BINANCE_FUTURE_ADA_USDT",
"exchange_type": "BINANCE",
"business_type": "FUTURE",
"side": "SELL",
"qty": "10",
"price": "0.5597",
"fee": "0.002798500000000000",
"fee_coin": "USDT",
"fee_rate": "0.0005",
"match_role": "MAKER",
"rpnl": "-0.001",
"position_mode": "BOTH",
"position_side": "LONG",
"create_time": "1750941402661"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » user_id | string | 用户ID |
| » transaction_id | string | 成交记录ID |
| » order_id | string | 订单ID |
| » text | string | 用户订单号 |
| » symbol | string | 交易对 |
| » exchange_type | string | 交易所 |
| » business_type | string | 业务类型 |
| » side | string | 买卖方向 |
| » qty | string | 成交数量 |
| » price | string | 成交价格 |
| » fee | string | 手续费 |
| » fee_coin | string | 手续费币种 |
| » fee_rate | string | 手续费率 |
| » match_role | string | 成交角色 |
| » rpnl | string | 实现盈亏 |
| » position_mode | string | 仓位模式 |
| » position_side | string | 仓位方向 |
| » create_time | string | 创建时间 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/account_book'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/account_book"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /account_book
查询账户资产变更历史
限频:每10秒200次请求
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| page | 请求参数 | integer | 否 | 列表页数 |
| limit | 请求参数 | integer | 否 | 列表返回的最大数量,最大1000 |
| coin | 请求参数 | string | 否 | |
| from | 请求参数 | integer | 否 | 起始毫秒时间戳 |
| to | 请求参数 | integer | 否 | 终止毫秒时间戳 |
返回示例
200 返回
[
{
"id": "121",
"user_id": "12345678",
"business_id": "20818182821",
"type": "TRADING_FEE",
"exchange_type": "BINANCE",
"coin": "USDT",
"change": "-0.002",
"balance": "81",
"create_time": "1750941402661"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » id | string | 账户变更记录ID |
| » user_id | string | 用户ID |
| » business_id | string | 业务ID |
| » type | string | 变更类型 |
| » exchange_type | string | 交易所 |
| » coin | string | 币种 |
| » change | string | 变更金额(正数表示转入,负数表示转出) |
| » balance | string | 变更后账户余额 |
| » create_time | string | 创建时间 |
WARNING
该请求需要 API key 和 secret 认证
示例代码
# coding: utf-8
import requests
import time
import hashlib
import hmac
host = "//"
prefix = "//"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = '/coin_discount_rate'
query_param = ''
# `gen_sign` 的实现参考认证一章
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())
key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="//"
prefix="//"
method="GET"
url="/coin_discount_rate"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{print $NF}')
full_url="$host$prefix$url"
curl -X $method $full_url \
-H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"
GET /coin_discount_rate
查询币种折扣率(分所模式下,保证金币种的折扣率)
Rate Limit: 200 requests per 10 seconds
| 名称 | 位置 | 类型 | 必选 | 描述 |
|---|---|---|---|---|
| coin | 请求参数 | string | 否 | |
| exchange_type | 请求参数 | string | 否 | OKX/GATE/BINANCE |
返回示例
200 返回
[
{
"coin": "SOL",
"exchange_type": "GATE",
"tier": "1",
"min_value": "0",
"max_value": "10000",
"discount_rate": "0.95"
},
{
"coin": "SOL",
"exchange_type": "GATE",
"tier": "2",
"min_value": "10000",
"max_value": "20000",
"discount_rate": "0.93"
},
{
"coin": "SOL",
"exchange_type": "GATE",
"tier": "3",
"min_value": "20000",
"max_value": "30000",
"discount_rate": "0.2"
}
]
| 状态码 | 含义 | 描述 | 格式 |
|---|---|---|---|
| 200 | OK (opens new window) | none | [Inline] |
状态码 200
| 名称 | 类型 | 描述 |
|---|---|---|
| » coin | string | 币种 |
| » exchange_type | string | 交易所 |
| » tier | string | 等级 |
| » min_value | string | 价值最小值 |
| » max_value | string | 价值最大值 |
| » discount_rate | string | 折扣率 |
WARNING
该请求需要 API key 和 secret 认证
{
"symbol": "string",
"exchange_type": "string",
"business_type": "string",
"state": "string",
"min_size": "string",
"min_notional": "string",
"lot_size": "string",
"tick_size": "string",
"max_num_orders": "string",
"max_market_size": "string",
"max_limit_size": "string",
"contract_size": "string",
"liquidation_fee": "string",
"default_leverage": "string",
"delist_time": "string"
}
| 名称 | 类型 | 必选 | 限制 | 描述 |
|---|---|---|---|---|
| symbol | string | true | none | ExchangeType_BusinessType_Base_Counter |
| exchange_type | string | true | none | BINANCE,OKX,GATE,CROSSEX |
| business_type | string | true | none | SPOT, FUTURE, MARGIN |
| state | string | true | none | live/suspend |
| min_size | string | true | none | Minimum order quantity |
| min_notional | string | true | none | Minimum order value |
| lot_size | string | true | none | Quantity step size |
| tick_size | string | true | none | Price step size |
| max_num_orders | string | true | none | Maximum number of pending orders |
| max_market_size | string | true | none | Maximum order quantity at market price |
| max_limit_size | string | true | none | Maximum order quantity at limit price |
| contract_size | string | true | none | contract multiplier |
| liquidation_fee | string | true | none | Liquidation rate |
| default_leverage | string | false | none | Default leverage |
| delist_time | string | true | none | Millisecond timestamp,0 is normal |
{
"user_id": "string",
"order_id": "string",
"text": "string",
"state": "string",
"symbol": "string",
"side": "string",
"type": "string",
"attribute": "string",
"exchange_type": "string",
"business_type": "string",
"qty": "string",
"quote_qty": "string",
"price": "string",
"time_in_force": "string",
"executed_qty": "string",
"executed_amount": "string",
"executed_avg_price": "string",
"fee_coin": "string",
"fee": "string",
"reduce_only": "string",
"leverage": "string",
"reason": "string",
"last_executed_qty": "string",
"last_executed_price": "string",
"last_executed_amount": "string",
"position_side": "string",
"create_time": "string",
"update_time": "string"
}
| 名称 | 类型 | 必选 | 限制 | 描述 |
|---|---|---|---|---|
| user_id | string | true | none | none |
| order_id | string | true | none | Order ID |
| text | string | true | none | Customer-defined order ID |
| state | string | true | none | Order State: NEW: The order is legal and waiting to be sent to the exchange OPEN: The order has been placed on the orderbook of the exchange PARTIALLY_FILLED: The order has been partially completed FILLED: The order has been fully executed FAIL: The order verification in CrossEx did not pass. Please check the order reason REJECT:The order was rejected by the exchange. Please check the order reason |
| symbol | string | true | none | Trading pair unique identifier ,example: BINANCE_SPOT_BTC_USDT, BINANCE_FUTURE_BTC_USDT |
| side | string | true | none | Side(BUY,SELL) |
| type | string | true | none | Type(LIMIT, MARKET) |
| attribute | string | true | none | COMMON, LIQ, REDUCE, ADL |
| exchange_type | string | true | none | Exchange type(BINANCE,OKX,GATE) |
| business_type | string | true | none | Business type(SPOT,FUTURE,MARGIN) |
| qty | string | true | none | Order base quantity |
| quote_qty | string | true | none | Order quote quantity |
| price | string | true | none | Order price |
| time_in_force | string | true | none | Timeinforce (default GTC, enums:GTC,IOC,FOK,POC) |
| executed_qty | string | true | none | Executed quantity |
| executed_amount | string | true | none | Executed quote quantity |
| executed_avg_price | string | true | none | Average transaction price |
| fee_coin | string | true | none | Transaction fee coin |
| fee | string | true | none | Transaction fee amount |
| reduce_only | string | true | none | Reduce position orders only, "true" or "false" |
| leverage | string | true | none | Order leverage |
| reason | string | true | none | Fail message |
| last_executed_qty | string | true | none | Last transaction quantity |
| last_executed_price | string | true | none | Last transaction price |
| last_executed_amount | string | true | none | Last transaction amount |
| position_side | string | true | none | Position side(NONE/LONG/SHORT) |
| create_time | string | true | none | Create time |
| update_time | string | true | none | Update time |