API 文档
简体中文
简体中文English

接入说明

接口请求基础地址:

--

请求说明:

  • ● POST 请求都是需要进行签名认证的,有关签名认证请仔细阅读签名认证。

  • ● 发送请求时请求头中 Host 必须为 域名xxx

  • ● POST 请求头中 Content-Type 必须为 application/json;charset=UTF-8。

  • ● POST 请求参数必须为JSON,其他参数服务器不会接收。

  • ● 所有请求中,参数accessKey为必须,如果不传此值,服务直接返回错误,如果请求方式为GET,此值需要url进行编码,POST 则不需要。

  • ● 所有需要签名验证的方法都需要传入timestamp参数,用于时间判断,单位为毫秒。超过当前时间5秒会拒绝链接。

  • ● 所有请求参数请按照 API 说明进行参数封装。

  • ● 将封装好参数的 API 请求通过 POST 或 GET 的方式提交到服务器。

  • ● 网站处理请求,并返回相应的 JSON 格式结果。

  • ● 请求出现的错误信息,请参考 错误代码。

  • ● 请使用 https 请求。

  • ● 限制频率(行情接口1秒1次,交易接口1秒30次)。

  • ● 请求示例中的接口调用方法,请将Code中demo下的  apiUtils-1.0-SNAPSHOT.jar  下载,进行使用。

响应参数说明:

参数名称 类型 说明
status string 返回状态码 (success,failure) success为请求成功,failure为请求失败
message string 返回错误码(参考错误代码)
data Object 具体接口返回数据

symbol 规则: 基础币种+计价币种。如BTC/USDT,symbol 为 btcusdt;ETH/BTC, symbol 为 ethbtc。请知晓!

以下所有有关请求参数、响应示例中涉及的数据都是测试用的,仅供参考!

签名认证

安全认证

目前关于apikey申请和修改,请在“个人中心 - API管理”页面进行相关操作。其中AccessKey为API 访问密钥,SecretKey为用户对请求进行签名的密钥(仅申请时可见)。

● 重要提示:这两个密钥与账号安全紧密相关,无论何时都请勿向其他人透露

合法请求结构

基于安全考虑,交易有关的 API 请求都必须进行签名运算。一个合法的请求由以下几部分组成:

● 方法请求地址 即访问服务器地址:https://xxx/v1 后面跟上方法名,比如https://xxx/v1/order/saveEntrust 。

● API 访问密钥(accessKey) 您申请的 APIKEY 中的AccessKey,每个api接口中都必须添加此参数。

● 必选和可选参数 每个方法都有一组用于定义 API 调用的必需参数和可选参数。可以在每个方法的说明中查看这些参数及其含义。

● 签名机密时,统一使用基于哈希的协议,使用 HmacSHA256 算法进行计算验签。

● 签名 (signature)签名计算得出的值,用于确保签名有效和未被篡改。

签名运算

API 请求在通过 Internet 发送的过程中极有可能被篡改。为了确保请求未被更改,我们会要求用户在方法请求中加入签名(每个方法中都有是否需要签名的备注)来校验参数或参数值在传输途中是否发生了更改。

签名计算:

注意: 进行签名计算时,默认使用HMACSHA256进行签名加密,如果使用其他加密算法,api无法解读出请求数据。所以在进行签名计算前,请先对请求进行规范化处理。

示例:

POST  /v1/order/saveEntrust 下单

● 注意:在https请求路径中原请求参数传值不需要排序过后传值,只需要将加密的参数排序,请知晓。

1.路径地址为  --/order/saveEntrust,参数为count、matchType、payPwd、price、symbol、type、timestamp、accessKey 其中accessKey为必须,每个api接口中必须添加此参数。如参数不需要验签,可不传signature参数。

2.POST请求的接口,参数以json方式传入。举栗子:如下单需要进行验签

https://xxx/v1/order/saveEntrust

JSONObject jsonObject = new JSONObject();

jsonObject.put("count",count);

...

jsonObject.put("accessKey",accessKey);

3.按照ASCII码的顺序对要加密的参数名进行排序 原参数格式为:

{"symbol":"ETHBTC","accessKey":*******,"matchType":"MARKET","price":1,"count":1,"payPwd":****,"type":"BUY","timestamp":"1566963399019"}

4.排序后的顺序为:

String signString = Sign.jsonToString(jsonObject.toJSONString());

signString = accessKey=*****&count=1&matchType=MARKET&payPwd=****&price=1&symbol=ETHBTC×tamp=1566963399019&type=BUY

5.把排序后参数进行计算加密得到signature,使用sha256_HMAC进行加密签名,将加密过的字节数组进行base64进行编码转换为string,将signature添加到json中:

String signature = Sign.sha256_HMAC(signString, SECRET_KEY);

jsonObject.put("signature",signature);

6.最终的参数 json 为:

{"symbol":"ETHBTC","accessKey":*****,"signature":*****,"matchType":"MARKET","price":1,"count":1,"payPwd":****,"type":"BUY","timestamp":"1566963399019"}

/POST 请求时参数必须为json,其他参数API不会接收,json中参数加密与GET加密方式相同,加密完成之后,json中添加signature:加密过后的密文 参数即可!

基础

币种信息

GET  /coin/enabled

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY

● 响应参数:

data:[币种名称]

请求示例

const axios = require('axios');

axios.get('/coin/enabled', {

params: {

accessKey: 'accessKey'

}

}).then(function (response) {

console.log(response);

});

String method = "/coin/enabled";

String param = "accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/coin/enabled'

params = {}

params['accessKey'] = 'ACCESSKEY'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

汇率折算

GET  /coin/exchange

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
shortName true string CNY USD:美元 KRW:韩元 JPY:日元 VND:越南盾
accessKey true string API管理中申请的ACCESS_KEY

● 响应参数:

'BTC':'68191.28' 表示BTC的价格为68191.28

请求示例

const axios = require('axios');

axios.get('/coin/exchange', {

params: {

accessKey: 'accessKey',

shortName: 'CNY'

}

}).then(function (response) {

console.log(response);

});

String method = "/coin/exchange";

String param = "shortName=" + shortName + "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/coin/exchange'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['shortName'] = 'shortName'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

公告列表

GET  /cms/bulletin

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
language true string 语言类型 中文简体:zh_cn 英文:en_US
accessKey true string API管理中申请的ACCESS_KEY
pageNum true number 当前页数
pageSize true number 当前页条数

● 响应参数:

参数名称 类型 描述
pageNum number 当前页
pageSize number 当前页面条数
total number 总条数
pages number 总页数
id number 主键
title string 标题
keyword string 关键字
showClientId number
isRoll string
newsTypeId number
content string 内容
createTime string 创建时间
updateTime string 修改时间
creator string
modifier string
version number
language string 语言
templateId number

请求示例

const axios = require('axios');

axios.get('/cms/bulletin', {

params: {

accessKey: 'accessKey',

language: 'zh_cn',

pageNum: '1',

pageSize: '10'

}

}).then(function (response) {

console.log(response);

});

String method = "/cms/bulletin";

String param = "accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY) + "&language=" + request.getLanguage() +"&pageNum=" + request.getPageNum() + "&pageSize=" + request.getPageSize();

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/cms/bulletin'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['language'] = 'language'

params['pageNum'] = 'pageNum'

params['pageSize'] = 'pageSize'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

行情

所有交易对计价单位和小数位

GET  /market/tradeInfo

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY

● 响应参数:

参数名称 类型 描述
symbol string 交易对名称
baseCurrency string 基础币种
quoteCurrency string 计价币种
pricePrecision number 价格小数位
countPrescision number 数量小数位

请求示例

const axios = require('axios');

axios.get('/market/tradeInfo', {

params: {

accessKey: 'accessKey'

}

}).then(function (response) {

console.log(response);

});

String method = "/market/tradeInfo";

String param = "accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/market/tradeInfo'

params = {}

params['accessKey'] = 'ACCESSKEY'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

所有交易对的信息

GET  /market/tickers

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY

● 响应参数:

参数名称 类型 描述
tradeName string 交易对名称
buy number 买一价格
sell number 卖一价格
high number 最高价
low number 最低价
last number 最新价
open number 开盘价
chg number 涨跌
vol24hour number 24小时成交量

请求示例

const axios = require('axios');

axios.get('/market/tickers', {

params: {

accessKey: 'accessKey'

}

}).then(function (response) {

console.log(response);

});

String method = "/market/tickers";

String param = "accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/market/tickers'

params = {}

params['accessKey'] = 'ACCESSKEY'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

指定交易对的信息

GET  /market/ticker

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
symbol true string 交易对名称(BTCUSDT,ETHUSDT)
accessKey true string API管理中申请的ACCESS_KEY

● 响应参数:

参数名称 类型 描述
tradeName string 交易对名称
buy number 买一价格
sell number 卖一价格
high number 最高价
low number 最低价
last number 最新价
open number 开盘价
chg number 涨跌
vol24hour number 24小时成交量

请求示例

const axios = require('axios');

axios.get('/market/ticker', {

params: {

accessKey: 'accessKey',

symbol: 'BTCUSDT'

}

}).then(function (response) {

console.log(response);

});

String method = "/market/ticker";

String param = "symbol=" + symbol + "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/market/ticker'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

指定交易对深度数据

GET  /market/depth

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
symbol true string 交易对标识(BTCUSDT,ETHUSDT...)
step true string 深度档数(STEP0=0-99,STEP1=0-19,STEP2=20-39,STEP3=40-59,STEP4=60-79,STEP5=80-99)

● 响应参数:

参数名称 类型 描述
buy array[object] 买-深度数据集合
price number 买-价格
amount number 买-数量
sell array[object] 卖-深度数据集合
price number 卖-价格
amount number 卖-数量

请求示例

const axios = require('axios');

axios.get('/market/depth', {

params: {

accessKey: 'accessKey',

symbol: 'BTCUSDT',

step: 'STEP1'

}

}).then(function (response) {

console.log(response);

});

String method = "/market/depth";

String param = "symbol=" + symbol + "&step=" + step + "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/market/depth'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['step'] = 'step'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

指定交易对的历史成交数据

GET  /market/trade

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
symbol true string 交易对名称(BTCUSDT,ETHUSDT)

● 响应参数:

参数名称 类型 描述
price number 成交价格
amount number 成交数量
direction string 成交方向(BUY,SELL)
time number 时间戳

请求示例

const axios = require('axios');

axios.get('/market/trade', {

params: {

accessKey: 'accessKey',

symbol: 'BTCUSDT'

}

}).then(function (response) {

console.log(response);

});

String method = "/market/trade";

String param = "symbol=" + symbol + "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/market/trade'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

指定交易对的K线数据

GET  /market/kline

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
symbol true string 交易对标识(BTCUSDT,ETHUSDT...)
klineType true string 周期标识(min,min5,min15,min30,hour1,hour4,day,week)
klineStep true string 长度 (step0 50条, STEP1 100条, STEP2 150条, STEP3 200条, STEP4 250条, STEP5 300条)

● 响应参数:

data:[ [最高价,开盘价,最低价,收盘价,成交量,时间戳] ]

请求示例

const axios = require('axios');

axios.get('/market/kline', {

params: {

accessKey: 'accessKey',

symbol: 'BTCUSDT',

klineType: 'min15',

klineStep: 'STEP1'

}

}).then(function (response) {

console.log(response);

});

String method = "/market/kline";

String param = "symbol=" + klineRequest.getSymbol() + "&klineType=" + klineRequest.getKlineType() + "&klineStep=" + klineRequest.getKlineStep()+ "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/market/kline'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['klineStep'] = 'klineStep'

params['klineType'] = 'klineType'

params['symbol'] = 'symbol'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

交易

查询未成交订单

GET  /order/current

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
currentPage false number 1 当前页数
pageSize false number 100 最大200条,可在200条内自定义条数
symbol false string 交易对symbol
type false string BUY:买单 SELL:卖单

● 响应参数:

参数名称 类型 描述
id string 委单ID
status string 状态(NO-TRADE:未成交 SOME-TRADE:部分成交 COMPLE-TRADE:完全成交 WITHDRAWN:已撤销)
type string 委单类型(BUY:买单 SELL:卖单)
matchType string LIMIT:限价单 MARKET:市价单
price number 委单单价
count number 委单数量
amount number 委单总价
leftCount number 剩余数量
completeCount number 完成数量
completePrice number 已成交均价
completeAmount number 成交总额
symbol string 交易对symbol

请求示例

const axios = require('axios');

axios.get('/order/current', {

params: {

accessKey: 'accessKey',

symbol: 'BTCUSDT',

type: 'BUY',

currentPage: 1,

pageSize: 100

}

}).then(function (response) {

console.log(response);

});

String method = "/order/current";

StringBuffer stringBuffer = new StringBuffer();

stringBuffer.append("accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY.trim()));

if (null != symbol && !"".equals(symbol)) {

stringBuffer.append("&symbol=" + symbol);

}

if (null != type && !"".equals(type)) {

stringBuffer.append("&type=" + type);

}

if(null != currentPage && !"".equals(currentPage)) {

stringBuffer.append("&currentPage=" + currentPage);

}

if (null != pageSize && !"".equals(pageSize)) {

stringBuffer.append("&pageSize=" + pageSize);

}

String returnJson = ExchApiUtil.sendGet(method, stringBuffer.toString());

method = '/order/current'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['type'] = 'type'

params['currentPage'] = 1

params['pageSize'] = 100

params['timestamp'] = 'timestamp'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

用户资产查询

GET  /personal/getUserFinanceList

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
selectType true string all all:查询用户所有资产 noall:查询用户非0资产

● 响应参数:

参数名称 类型 描述
coinName string 币种名称
total string 可用余额
frozen string 冻结余额
financing string 理财余额

请求示例

const axios = require('axios');

axios.get('/personal/getUserFinanceList', {

params: {

accessKey: 'accessKey',

selectType: 'all'

}

}).then(function (response) {

console.log(response);

});

String method = "/personal/getUserFinanceList";

String param = "selectType=" + selectType + "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/personal/getUserFinanceList'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['selectType'] = 'selectType'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

下单

POST  /order/saveEntrust

● 是否需要验签:Y

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
count true number 委托数量
matchType true string LIMIT:限价单 MARKET:市价单
payPwd true string 交易密码
price false number 委托价格(市价单可为空)
source false string 来源 API
symbol true string 交易对symbol
type true string BUY:买单 SELL:卖单
clientOrderId false string 客户端请求订单id

● 响应参数:

参数名称 类型 描述
data number 委单ID

请求示例

const axios = require('axios');

axios.post('/order/saveEntrust', {

accessKey: 'accessKey',

count: 2,

matchType: 'LIMIT',

payPwd: '666666',

price: 16,

source: 'web',

symbol: 'BTCUSDT',

type: 'BUY'

clientOrderId: '88888888'

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/order/saveEntrust";

jsonObject.put("count", entrustRequest.getCount());

jsonObject.put("matchType", entrustRequest.getMatchType());

jsonObject.put("payPwd", entrustRequest.getPayPwd());

if (null != entrustRequest.getPrice() && !"".equals(entrustRequest.getPrice())) {

jsonObject.put("price", entrustRequest.getPrice());

}

jsonObject.put("symbol", entrustRequest.getSymbol());

jsonObject.put("type", entrustRequest.getType());

jsonObject.put("clientOrderId", entrustRequest.getClientOrderId());

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY);

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/order/saveEntrust'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['count'] = 'count'

params['matchType'] = 'matchType'

params['payPwd'] = 'payPwd'

params['price'] = 'price'

params['symbol'] = 'symbol'

params['type'] = 'type'

params['clientOrderId'] = 'clientOrderId'

params['timestamp'] = 'timestamp'

headers = {"content-type": "application/json;charset=UTF-8"}

params["signature"] = self.get_sign(params).decode("utf-8")

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

根据委单id撤销一个订单

POST  /order/cancelEntrust

● 是否需要验签:Y

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
id true number 委单ID

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/order/cancelEntrust', {

accessKey: 'accessKey',

id: '6666666666666666'

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/order/cancelEntrust";

jsonObject.put("id", id);

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/order/cancelEntrust'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['id'] = 'id'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method, data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

按委单ID批量撤单

POST  /order/batchCancel

● 是否需要验签:Y

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
ids true List 单次不超过50个委单id

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/order/batchCancel', {

accessKey: 'accessKey',

ids: ids

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/order/batchCancel";

jsonObject.put("ids", ids);

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/order/batchCancel'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['ids'] = 'ids'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

按条件批量撤单

POST  /order/batchCancelOpenOrders

● 是否需要验签:Y

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
symbol false string 交易对symbol
type false string BUY:买单 SELL:卖单

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/order/batchCancelOpenOrders', {

accessKey: 'accessKey',

symbol: 'BTCUSDT',

type: 'SELL'

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/order/batchCancelOpenOrders";

if (null != batchCancelRequest.getSymbol() && !"".equals(batchCancelRequest.getSymbol())) {

jsonObject.put("symbol", batchCancelRequest.getSymbol());

}

if (null != batchCancelRequest.getType() && !"".equals(batchCancelRequest.getType())) {

jsonObject.put("type", batchCancelRequest.getType());

}

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/order/batchCancelOpenOrders'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['type'] = 'type'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

根据ID查询委单

GET  /order/queryOrderById

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
orderId true number 委单ID

● 响应参数:

参数名称 类型 描述
id string 委单ID
userId number 用户ID
tradeId number 交易对ID
buyCoinId number 买方币种ID
sellCoinId number 卖方币种ID
status string 状态(NO-TRADE:未成交 SOME-TRADE:部分成交 COMPLE-TRADE:完全成交 WITHDRAWN:已撤销)
type string 委单类型(BUY:买单 SELL:卖单)
matchType string LIMIT:限价单 MARKET:市价单
price number 委单价格
count number 委单数量
amount number 委单金额
leftCount number 剩余数量
completeCount number 成交数量
completePrice number 成交均价
completeAmount number 成交金额
source string 来源
createTime string 创建时间
fees number 手续费
version number 版本号
symbol string 交易对symbol

请求示例

const axios = require('axios');

axios.get('/order/queryOrderById', {

params: {

accessKey: 'accessKey',

orderId: 6666666666666

}

}).then(function (response) {

console.log(response);

});

String method = "/order/queryOrderById";

String param = "orderId=" + orderId + "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/order/queryOrderById'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['orderId'] = 'orderId'

params['timestamp'] = 'timestamp'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

用户当前未成交订单查询

GET  /order/openOrders

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
symbol false string 交易对symbol
type false string BUY:买单 SELL:卖单

● 响应参数:

参数名称 类型 描述
id string 委单ID
userId number 用户ID
tradeId number 交易对ID
buyCoinId number 买方币种ID
sellCoinId number 卖方币种ID
status string 状态(NO-TRADE:未成交 SOME-TRADE:部分成交 COMPLE-TRADE:完全成交 WITHDRAWN:已撤销)
type string 委单类型(BUY:买单 SELL:卖单)
matchType string LIMIT:限价单 MARKET:市价单
price number 委单单价
count number 委单数量
amount number 委单总价
leftCount number 剩余数量
completeCount number 完成数量
completePrice number 已成交均价
completeAmount number 成交总额
source string 来源
createTime string 创建时间
fees number 手续费
version number 版本号
symbol string 交易对symbol
clientOrderId string 客户端请求id

请求示例

const axios = require('axios');

axios.get('/order/openOrders', {

params: {

accessKey: 'accessKey',

symbol: 'BTCUSDT',

type: 'BUY'

}

}).then(function (response) {

console.log(response);

});

String method = "/order/openOrders";

StringBuffer stringBuffer = new StringBuffer();

stringBuffer.append("accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY.trim()));

if (null != symbol && !"".equals(symbol)) {

stringBuffer.append("&symbol=" + symbol);

}

if (null != type && !"".equals(type)) {

stringBuffer.append("&type=" + type);

}

String returnJson = ExchApiUtil.sendGet(method, stringBuffer.toString());

method = '/order/openOrders'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['type'] = 'type'

params['timestamp'] = 'timestamp'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

我的委单查询

GET  /order/queryMyEntrust

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
symbol false string 交易对symbol
matchType false string LIMIT:限价单 MARKET:市价单
type false string BUY:买单 SELL:卖单
startTime false string 查询开始日期, 日期格式yyyy-MM-dd HH:mm:ss
endTime false string 查询结束日期, 日期格式yyyy-MM-dd HH:mm:ss
currentPage false number 1 当前页数
pageSize false number 10 每页显示多少条

● 响应参数:

参数名称 类型 描述
id string 委单ID
userId number 用户ID
tradeId number 交易对ID
buyCoinId number 买方币种ID
sellCoinId number 卖方币种ID
status string 状态(NO-TRADE:未成交 SOME-TRADE:部分成交 COMPLE-TRADE:完全成交 WITHDRAWN:已撤销)
type string 委单类型(BUY:买单 SELL:卖单)
matchType string LIMIT:限价单 MARKET:市价单
price number 委单单价
count number 委单数量
amount number 委单总价
leftCount number 剩余数量
completeCount number 完成数量
completePrice number 已成交均价
completeAmount number 成交总额
createTime string 创建时间
fees number 手续费
version number 版本号
symbol string 交易对symbol
pageNum number 当前页
pageSize number 当前页面条数
total number 总条数
pages number 总页数

请求示例

const axios = require('axios');

axios.get('/order/queryMyEntrust', {

params: {

accessKey: 'accessKey',

symbol: 'BTCUSDT',

matchType: 'LIMIT',

type: 'BUY'

}

}).then(function (response) {

console.log(response);

});

StringBuffer stringBuffer = new StringBuffer();

String method = "/order/queryMyEntrust";

stringBuffer.append("accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY.trim()));

if (myEntrustRequest.getType() != null && !"".equals(myEntrustRequest.getType())) {

stringBuffer.append("&type=" + myEntrustRequest.getType());

}

if (myEntrustRequest.getSymbol() != null && !"".equals(myEntrustRequest.getSymbol())) {

stringBuffer.append("&symbol=" + myEntrustRequest.getSymbol());

}

if (myEntrustRequest.getMatchType() != null && !"".equals(myEntrustRequest.getMatchType())) {

stringBuffer.append("&type=" + myEntrustRequest.getType());

}

if (myEntrustRequest.getStartTime() != null && !"".equals(myEntrustRequest.getStartTime())) {

stringBuffer.append("&startTime=" + myEntrustRequest.getStartTime());

}

if (myEntrustRequest.getEndTime() != null && !"".equals(myEntrustRequest.getEndTime())) {

stringBuffer.append("&endTime=" + myEntrustRequest.getEndTime());

}

if (myEntrustRequest.getCurrentPage() != null && !"".equals(myEntrustRequest.getCurrentPage())) {

stringBuffer.append("&currentPage=" + myEntrustRequest.getCurrentPage());

}

if (myEntrustRequest.getPageSize() != null && !"".equals(myEntrustRequest.getPageSize())) {

stringBuffer.append("&pageSize=" + myEntrustRequest.getPageSize());

}

String returnJson = ExchApiUtil.sendGet(method, stringBuffer.toString());

method = '/order/queryMyEntrust'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['type'] = 'type'

params['startTime'] = 'startTime'

params['endTime'] = 'endTime'

params['currentPage'] = 'currentPage'

params['pageSize'] = 'pageSize'

params['matchType'] = 'matchType'

params['timestamp'] = 'timestamp'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

我的历史订单查询

GET  /order/queryMyHisEntrust

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
symbol false string 交易对symbol
matchType false string LIMIT:限价单 MARKET:市价单
type false string BUY:买单 SELL:卖单
startTime false string 查询开始日期, 日期格式yyyy-MM-dd HH:mm:ss
endTime false string 查询结束日期, 日期格式yyyy-MM-dd HH:mm:ss
status false string COMPLE-TRADE:完全成交 WITHDRAWN:已撤销
currentPage false number 1 当前页数
pageSize false number 10 每页显示多少条

● 响应参数:

参数名称 类型 描述
id string 委单ID
userId number 用户ID
tradeId number 交易对ID
buyCoinId number 买方币种ID
sellCoinId number 卖方币种ID
status string 状态(NO-TRADE:未成交 SOME-TRADE:部分成交 COMPLE-TRADE:完全成交 WITHDRAWN:已撤销)
type string 委单类型(BUY:买单 SELL:卖单)
matchType string LIMIT:限价单 MARKET:市价单
price number 委单单价
count number 委单数量
amount number 委单总价
leftCount number 剩余数量
completeCount number 完成数量
completePrice number 已成交均价
completeAmount number 成交总额
createTime string 创建时间
fees number 手续费
version number 版本号
symbol string 交易对symbol
pageNum number 当前页
pageSize number 当前页面条数
total number 总条数
pages number 总页数

请求示例

const axios = require('axios');

axios.get('/order/queryMyHisEntrust', {

params: {

accessKey: 'accessKey',

symbol: 'BTCUSDT',

matchType: 'LIMIT',

type: 'BUY'

}

}).then(function (response) {

console.log(response);

});

StringBuffer stringBuffer = new StringBuffer();

String method = "/order/queryMyHisEntrust";

stringBuffer.append("accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY.trim()));

if (myHisEntrustRequest.getType() != null && !"".equals(myHisEntrustRequest.getType())) {

stringBuffer.append("&type=" + myHisEntrustRequest.getType());

}

if (myHisEntrustRequest.getSymbol() != null && !"".equals(myHisEntrustRequest.getSymbol())) {

stringBuffer.append("&symbol=" + myHisEntrustRequest.getSymbol());

}

if (myHisEntrustRequest.getMatchType() != null && !"".equals(myHisEntrustRequest.getMatchType())) {

stringBuffer.append("&type=" + myHisEntrustRequest.getType());

}

if (myHisEntrustRequest.getStartTime() != null && !"".equals(myHisEntrustRequest.getStartTime())) {

stringBuffer.append("&startTime=" + myHisEntrustRequest.getStartTime());

}

if (myHisEntrustRequest.getEndTime() != null && !"".equals(myHisEntrustRequest.getEndTime())) {

stringBuffer.append("&endTime=" + myHisEntrustRequest.getEndTime());

}

if (myHisEntrustRequest.getCurrentPage() != null && !"".equals(myHisEntrustRequest.getCurrentPage())) {

stringBuffer.append("&currentPage=" + myHisEntrustRequest.getCurrentPage());

}

if (myHisEntrustRequest.getPageSize() != null && !"".equals(myHisEntrustRequest.getPageSize())) {

stringBuffer.append("&pageSize=" + myHisEntrustRequest.getPageSize());

}

if (myHisEntrustRequest.getStatus() != null && !"".equals(myHisEntrustRequest.getStatus())) {

stringBuffer.append("&status=" + myHisEntrustRequest.getStatus());

}

String returnJson = ExchApiUtil.sendGet(method, stringBuffer.toString());

method = '/order/queryMyHisEntrust'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['type'] = 'type'

params['startTime'] = 'startTime'

params['endTime'] = 'endTime'

params['currentPage'] = 'currentPage'

params['pageSize'] = 'pageSize'

params['status'] = 'status'

params['timestamp'] = 'timestamp'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

成交明细

GET  /order/queryMyEntrustOrder

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
symbol false string 交易对symbol
matchType false string LIMIT:限价单 MARKET:市价单
type false string BUY:买单 SELL:卖单
startTime false string 查询开始日期, 日期格式yyyy-MM-dd HH:mm:ss
endTime false string 查询结束日期, 日期格式yyyy-MM-dd HH:mm:ss
currentPage false number 1 当前页数
pageSize false number 10 每页显示多少条

● 响应参数:

参数名称 类型 描述
id number 成交明细ID
entrustId string 委单ID
type string 委单类型(BUY:买单 SELL:卖单)
tradeId number 交易对ID
buyCoinId number 买方币种ID
sellCoinId number 卖方币种ID
symbol string 交易对symbol
matchType string LIMIT:限价单 MARKET:市价单
price number 成交单价
count number 成交数量
amount number 成交总额
createTime string 成交时间
fees number 手续费
pageNum number 当前页
pageSize number 当前页面条数
total number 总条数
pages number 总页数

请求示例

const axios = require('axios');

axios.get('/order/queryMyEntrustOrder', {

params: {

accessKey: 'accessKey',

symbol: 'BTCUSDT',

matchType: 'LIMIT',

type: 'BUY'

}

}).then(function (response) {

console.log(response);

});

StringBuffer stringBuffer = new StringBuffer();

String method = "/order/queryMyEntrustOrder";

stringBuffer.append("accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY.trim()));

if (myEntrustRequest.getType() != null && !"".equals(myEntrustRequest.getType())) {

stringBuffer.append("&type=" + myEntrustRequest.getType());

}

if (myEntrustRequest.getSymbol() != null && !"".equals(myEntrustRequest.getSymbol())) {

stringBuffer.append("&symbol=" + myEntrustRequest.getSymbol());

}

if (myEntrustRequest.getMatchType() != null && !"".equals(myEntrustRequest.getMatchType())) {

stringBuffer.append("&type=" + myEntrustRequest.getType());

}

if (myEntrustRequest.getStartTime() != null && !"".equals(myEntrustRequest.getStartTime())) {

stringBuffer.append("&startTime=" + myEntrustRequest.getStartTime());

}

if (myEntrustRequest.getEndTime() != null && !"".equals(myEntrustRequest.getEndTime())) {

stringBuffer.append("&endTime=" + myEntrustRequest.getEndTime());

}

if (myEntrustRequest.getCurrentPage() != null && !"".equals(myEntrustRequest.getCurrentPage())) {

stringBuffer.append("&currentPage=" + myEntrustRequest.getCurrentPage());

}

if (myEntrustRequest.getPageSize() != null && !"".equals(myEntrustRequest.getPageSize())) {

stringBuffer.append("&pageSize=" + myEntrustRequest.getPageSize());

}

String returnJson = ExchApiUtil.sendGet(method, stringBuffer.toString());

method = '/order/queryMyEntrustOrder'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['type'] = 'type'

params['startTime'] = 'startTime'

params['endTime'] = 'endTime'

params['currentPage'] = 'currentPage'

params['pageSize'] = 'pageSize'

params['timestamp'] = 'timestamp'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

根据客户端请求id撤销一个订单

POST  /order/cancelEntrustByClientOrderId

● 是否需要验签:Y

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
secretKey true string API管理中申请的SECRET_KEY
clientOrderId true string 请求订单ID

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/order/cancelEntrustByClientOrderId', {

accessKey: 'accessKey',

secretKey: 'secretKey',

clientOrderId: '88888888',

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/order/cancelEntrustByClientOrderId";

jsonObject.put("clientOrderId", clientOrderId);

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/order/cancelEntrustByClientOrderId'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['secretKey'] = 'secretKey'

params['clientOrderId'] = 'clientOrderId'

params['timestamp'] = 'timestamp'

rsp = requests.post(method,params)

响应示例

JSON

//返回结果


                            

根据客户端请求id批量撤单

POST  /order/batchCancelByClientOrderIds

● 是否需要验签:Y

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
secretKey true string API管理中申请的SECRET_KEY
clientOrderIds true List 请求订单IDs

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/order/batchCancelByClientOrderIds', {

accessKey: 'accessKey',

secretKey: 'secretKey',

clientOrderIds: 'clientOrderIds',

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/order/batchCancelByClientOrderIds";

jsonObject.put("clientOrderIds", clientOrderIds);

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/order/batchCancelByClientOrderIds'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['secretKey'] = 'secretKey'

params['clientOrderIds'] = 'clientOrderIds'

params['timestamp'] = 'timestamp'

rsp = requests.post(method,params)

响应示例

JSON

//返回结果


                            

Socket 成交推送

WebSocket  wss://gctapp.com

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY

● 响应参数:

参数名称 类型 描述
count number 成交数量
dealTime number 成交时间
entrustId string 委单ID
oneselfDeal boolean 是否自成交
price number 成交价格
symbol string 交易对名称
type string 类型:BUY:买单 SELL:卖单
userId number 用户ID

请求示例

ws = new WebSocket("wss://gctapp.com");

ws.send(JSON.stringify({

"accessKey": "**"

}));

public class EntrustClient extends WebSocketClient {

public EntrustClient(URI serverUri) {

super(serverUri);}

}

EntrustClient entrustClient = new EntrustClient(URI.create("wss://gctapp.com"));

entrustClient.connect();

# -*- coding: utf-8 -*-

import json

import websocket

def on_message(self, message):

print(message)

def on_error(self, error):

print(error)

def on_close(self):

print("### closed ###")

def on_open(self):

ws.send(json.dumps({"accessKey": "fu7FOfjHnwJmURiP6LrhJpGxVjgcxR9YcGeKTPm8JT8="}))

if __name__ == "__main__":

try:

websocket.enableTrace(True)

ws = websocket.WebSocketApp("ws://192.168.2.65:8001/",

on_open=on_open,

on_message=on_message,

on_error=on_error,

on_close=on_close)

ws.run_forever()

except Exception as e:

print("ws 断开 或者psycopg2.OperationalError, {}: {}".format(type(e), e))

响应示例

JSON

//返回结果


                            

充提

新增申请提币

POST  /dw/addWithdraw

● 是否需要验签:Y

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
coinName true string 币种名称(btc...)
withdrawAddress true string 提币地址
payCode true string 交易密码
amount true string 提币数量
networkFees true string 手续费
remark false string 提币标签

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/dw/addWithdraw', {

accessKey: 'accessKey',

coinName: 'btc',

withdrawAddress: 'aaaaaaaaaaaaaaaaaaaaaa',

payCode: '666666',

amount: '168',

networkFees: '10',

remark: '提币标签'

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/dw/addWithdraw";

jsonObject.put("coinName", withdrawRequest.getCoinName());

jsonObject.put("withdrawAddress", withdrawRequest.getWithdrawAddress());

jsonObject.put("payCode", withdrawRequest.getPayCode());

jsonObject.put("amount", withdrawRequest.getAmount());

jsonObject.put("networkFees", withdrawRequest.getNetworkFees());

jsonObject.put("remark", withdrawRequest.getRemark());

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/dw/addWithdraw'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['coinName'] = 'coinName'

params['withdrawAddress'] = 'withdrawAddress'

params['payCode'] = 'payCode'

params['amount'] = 'amount'

params['networkFees'] = 'networkFees'

params['remark'] = 'remark'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

撤销提币

POST  /dw/cancelWithdraw

● 是否需要验签:Y

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
id true number 用户提币ID

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/dw/cancelWithdraw', {

accessKey: 'accessKey',

id: 168168168

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/dw/cancelWithdraw";

jsonObject.put("id",id);

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey",ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/dw/cancelWithdraw'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['id'] = 'id'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

用户充提记录查询

GET  /dw/queryWithdrawRecording

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 描述
accessKey true string API管理中申请的ACCESS_KEY
coinName false string 交易对symbol
type false string 交易类型 RECHARGE:充值 WITHDRAW:提现
startTime false string 查询开始日期, 日期格式yyyy-MM-dd HH:mm:ss
endTime false string 查询结束日期, 日期格式yyyy-MM-dd HH:mm:ss
currentPage false number 1 当前页数
pageSize false number 10 每页显示多少条

● 响应参数:

参数名称 类型 描述
id number 充提记录ID
userId number 用户ID
coinId number 币种ID
type string 交易类型 RECHARGE:充值 WITHDRAW:提现
status string 状态 WAIT-WITHDRAW:等待提现 LOCK:锁定 WITHDRAW-SUCCESS:提现成功 CANCEL:取消 RECHARGING:确认中 RECHARGE-SUCCESS:充值成功 AUDITED:已审核
amount string 数量
networkFees string 手续费
withdrawAddress string 提币地址
rechargeAddress string 充值地址
source string 来源
hash string 交易哈希
successCount string 成功确认数
confirmationCount string 确认数
createTime string 创建时间
updateTime string 最后修改时间
coinName string 币种名称

请求示例

const axios = require('axios');

axios.get('/dw/queryWithdrawRecording', {

params: {

accessKey: 'accessKey',

coinName: 'BTCUSDT',

type: 'RECHARGE'

}

}).then(function (response) {

console.log(response);

});

StringBuffer stringBuffer = new StringBuffer();

String method = "/dw/queryWithdrawRecording";

stringBuffer.append("accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY.trim()));

if (request.getType() != null && !"".equals(request.getType())) {

stringBuffer.append("&type=" + request.getType());

}

if (request.getCoinName() != null && !"".equals(request.getCoinName())) {

stringBuffer.append("&coinName=" + request.getCoinName());

}

if (request.getStartTime() != null && !"".equals(request.getStartTime())) {

stringBuffer.append("&startTime=" + request.getStartTime());

}

if (request.getEndTime() != null && !"".equals(request.getEndTime())) {

stringBuffer.append("&endTime=" + request.getEndTime());

}

if (request.getCurrentPage() != null && !"".equals(request.getCurrentPage())) {

stringBuffer.append("&currentPage=" + request.getCurrentPage());

}

if (request.getPageSize() != null && !"".equals(request.getPageSize())) {

stringBuffer.append("&pageSize=" + request.getPageSize());

}

String returnJson = ExchApiUtil.sendGet(method, stringBuffer.toString());

method = '/dw/queryWithdrawRecording'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['coinName'] = 'coinName'

params['type'] = 'type'

params['startTime'] = 'startTime'

params['endTime'] = 'endTime'

params['currentPage'] = 'currentPage'

params['pageSize'] = 'pageSize'

params['timestamp'] = 'timestamp'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

合约

获取全部合约的交易行情

GET  /contract/market/tickers

● 是否需要验签:N

● 请求参数

● 响应参数:

参数名称 是否必须 类型 默认值 描述
tradeName true string 交易对名称
high true number
chg true number 涨跌幅
last true number 上次成交价
low true number
buy true number 买1
sell true number 卖1
vol24hour true number 24小时成交量
open true number 开盘价

请求示例

const axios = require('axios');

axios.get('/contract/market/tickers', {

symbol: 'btc_usdt_sustainable',

}).then(function (response) {

console.log(response);

});

String method = "/contract/market/tickers";

String param = "accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/contract/market/tickers'

params = {}

params['accessKey'] = 'ACCESSKEY'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

获取单个symbol的交易行情

GET  /contract/market/ticker

● 是否需要验签:N

● 请求参数

参数名称 是否必须 示例 默认值 描述
symbol true btc_usdt_sustainable 合约交易对名称(tradeName)

● 响应参数:

参数名称 是否必须 类型 默认值 描述
tradeName true string 交易对名称
high true number
chg true number 涨跌幅
last true number 上次成交价
low true number
buy true number 买1
sell true number 卖1
vol24hour true number 24小时成交量
open true number 开盘价

请求示例

const axios = require('axios');

axios.get('/contract/market/ticker', {

symbol: 'btc_usdt_sustainable',

}).then(function (response) {

console.log(response);

});

String method = "/contract/market/ticker";

String param = "symbol=" + symbol + "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/dw/addWithdraw'

method = '/contract/market/ticker'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

获取单个交易对的历史成交

GET  /contract/market/trade

● 是否需要验签:N

● 请求参数

参数名称 是否必须 示例 默认值 描述
symbol true btc_usdt_sustainable 合约交易对

● 响应参数:

参数名称 是否必须 类型 默认值 描述
amount true number 数量
price true number 价格
time true number 时间
direction true string 买卖方向

请求示例

const axios = require('axios');

axios.get('/contract/market/trade', {

symbol: 'btc_usdt_sustainable',

}).then(function (response) {

console.log(response);

});

String method = "/contract/market/trade";

String param = "symbol=" + symbol + "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/contract/market/trade'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

获取单个交易对的深度

GET  /contract/market/depth

● 是否需要验签:N

● 请求参数

参数名称 是否必须 示例 默认值 描述
symbol true btc_usdt_sustainable 合约交易对
step true STEP (0-4档) STEP0 (0-99档), STEP1 (0-19档), STEP2 (20-39档), STEP3 (40-59档), STEP4 (60-79档), STEP5 (80-99档); 查询档数

● 响应参数:

参数名称 是否必须 类型 默认值 描述
buy false object 买深度
amount true number 数量
price true number 价格
sell false object 卖深度
amount true number 数量
price true number 价格

请求示例

const axios = require('axios');

axios.get('/contract/market/depth', {

symbol: 'btc_usdt_sustainable',

step: 'STEP',

}).then(function (response) {

console.log(response);

});

String method = "/contract/market/depth";

String param = "symbol=" + symbol + "&step=" + step + "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/contract/market/depth'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['step'] = 'step'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

新增合约委单

POST  /contract/entrust/saveEntrust

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 备注 参数值
symbol true string 交易对标识
positionsType true string 仓位类型(BY=逐仓, TOTAL=全仓)
entrustMode true string 类型(ONE_WAY=单向, TWO_WAY=双向)
tradeMode true string 交易模式(OPEN_UP=开多 OPEN_DOWN=开空,CLOSE_UP=平多 CLOSE_DOWN=平空 )
matchType true string 撮合类型(LIMIT_DEFAULT=默认限价,MARKET_DEFAULT=默认市价,POST_ONLY=只做maker, FOK=全部成交或立即取消, IOC=立即成交并取消剩余)
price true number 价格
count true number 数量

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/contract/entrust/saveEntrust', {

Content-Type: 'application/json',

symbol: 'btc_usdt_sustainable',

positionsType: 'BY',

entrustMode: 'ONE_WAY',

tradeMode: 'OPEN_UP',

matchType: 'LIMIT_DEFAULT',

price: 1888,

count: 18,

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/contract/entrust/saveEntrust";

jsonObject.put("symbol", entrustRequest.getSymbol());

jsonObject.put("positionsType", entrustRequest.getPositionsType());

jsonObject.put("entrustMode", entrustRequest.getEntrustMode());

jsonObject.put("tradeMode", entrustRequest.getTradeMode());

jsonObject.put("matchType", entrustRequest.getMatchType());

jsonObject.put("price", entrustRequest.getPrice());

jsonObject.put("count", entrustRequest.getCount());

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY);

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/contract/entrust/saveEntrust'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['positionsType'] = 'positionsType'

params['entrustMode'] = 'entrustMode'

params['tradeMode'] = 'tradeMode'

params['matchType'] = 'matchType'

params['price'] = 'price'

params['count'] = 'count'

params['timestamp'] = 'timestamp'

headers = {"content-type": "application/json;charset=UTF-8"}

params["signature"] = self.get_sign(params).decode("utf-8")

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

撤销合约委单

POST  /contract/entrust/cancelEntrust

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 默认值 备注 参数值
entrustId true string 委单id

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/contract/entrust/cancelEntrust', {

Content-Type: 'application/json',

entrustId: '1',

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/contract/entrust/cancelEntrust";

jsonObject.put("entrustId", entrustId);

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/contract/entrust/cancelEntrust'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['entrustId'] = 'entrustId'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method, data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

根据委单id集合撤销委托单

POST  /contract/entrust/batchCancelEntrustByIds

● 是否需要验签:N

● 请求参数

参数名称 是否必须 类型 示例 备注 参数值
entrustIds true string "[\"891003182082445312622078536970145793\",\"891003248616689664622078536970145793\"]" 委单id

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/contract/entrust/batchCancelEntrustByIds', {

Content-Type: 'application/json',

entrustId: "[\"891003182082445312622078536970145793\",\"891003248616689664622078536970145793\"]",

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/contract/entrust/batchCancelEntrustByIds";

jsonObject.put("entrustIds", entrustIds);

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/contract/entrust/batchCancelEntrustByIdsl'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['entrustIds'] = 'entrustIds'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

条件批量撤销委托单

POST  /contract/entrust/batchCancelEntrust

● 是否需要验签:N

● 请求参数

参数名称 类型 是否必须 示例 默认值 备注
symbol string true 合约加一堆标识
positionsType string true 仓位类型(BY=逐仓, TOTAL=全仓)
tradeMode string true 交易模式(OPEN_UP=开多 OPEN_DOWN=开空,CLOSE_UP=平多 CLOSE_DOWN=平空 )
entrustType string true LIMIT 限价 MARKET 市价
matchType string true 撮合类型(LIMIT_DEFAULT=限价, MARKET_DEFAULT=市价,POST_ONLY=只做maker, FOK=全部成交或立即取消, IOC=立即成交并取消剩余)

● 响应参数:

status :success 为成功,其他为失败

请求示例

const axios = require('axios');

axios.post('/contract/entrust/batchCancelEntrust', {

Content-Type: 'application/json',

symbol: "btc_usdt_sustainable",

positionsType: "BY",

tradeMode: "OPEN_UP",

entrustType: "LIMIT",

matchType: "LIMIT_DEFAULT",

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/contract/entrust/batchCancelEntrust";

jsonObject.put("symbol", batchCancelRequest.getSymbol());

jsonObject.put("positionsType", batchCancelRequest.getPositionsType());

jsonObject.put("tradeMode", batchCancelRequest.getTradeMode());

jsonObject.put("entrustType", batchCancelRequest.getEntrustType());

jsonObject.put("matchType", batchCancelRequest.getMatchType());

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/contract/entrust/batchCancelEntrust'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['positionsType'] = 'positionsType'

params['tradeMode'] = 'tradeMode'

params['entrustType'] = 'entrustType'

params['matchType'] = 'matchType'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

查询用户当前委托单

POST  /contract/entrust/currentEntrust

● 是否需要验签:N

● 请求参数

参数名称 类型 是否必须 示例 默认值 备注
ids string false 委单id集合
symbol string true 交易对标识
positionsType string false 仓位类型(BY=逐仓, TOTAL=全仓)
tradeMode string false 交易模式(OPEN_UP=开多 OPEN_DOWN=开空,CLOSE_UP=平多 CLOSE_DOWN=平空 )
entrustTypes string [] false 委托类型(LIMIT=限价, MARKET=市价,FULL_STOP=止盈止损,PLAN_FULL_STOP=计划委托)
matchTypes string [] false 撮合类型(LIMIT_DEFAULT=默认,MATCH_ONE_WAY=单向止盈止损,MATCH_TWO_WAY=双向止盈止损,POST_ONLY=只做maker, FOK=全部成交或立即取消, IOC=立即成交并取消剩余)
requestMatchType string false 请求撮合类型(DEFAULT=限价/市价, ADVANCED_PRICE_LIMIT=高级限价)
status string false 状态
startCreateTime string false 开始创建时间
endCreateTime string false 结束创建时间

● 响应参数:

参数名称 是否必须 类型 默认值 备注
status false string
message false null
pageNum false number 当前页数
pageSize false number 每页条数
total false number 总数
pages false number 总页数
id true string 主键id
userId true number 用户id
partnerId true number 商户id
tradeId true number 合约id
buyCoinId true number 买币种id
buyCoinName true string 买币种名称
sellCoinId true number 卖币种id
sellCoinName true string 卖币种名称
tradeName true string 交易对名称
symbol true string 交易对标识
contractType true string 类型(USDT_SUSTAINABLE=usdt永续, USDT_DELIVERY=usdt交割, USD_SUSTAINABLE=usd永续, USD_DELIVERY=usd交割)
positionsType true string 仓位类型(BY=逐仓, TOTAL=全仓)
lever true number 杠杆倍数
entrustMode true string 类型(ONE_WAY=单向, TWO_WAY=双向)
tradeMode true string 类型(OPEN_UP=开多 OPEN_DOWN=开空,CLOSE_UP=平多 CLOSE_DOWN=平空 )
entrustType true string 委托类型(LIMIT=限价, MARKET=市价,FULL_STOP=止盈止损,PLAN_FULL_STOP=计划委托)
matchType true string 撮合类型(LIMIT_DEFAULT=默认,MATCH_ONE_WAY=单向止盈止损,MATCH_TWO_WAY=双向止盈止损,POST_ONLY=只做maker, FOK=全部成交或立即取消, IOC=立即成交并取消剩余)
direction true nullstring 类型(MAKER=挂单, TAKER=吃单)
status true string 状态(NO-ENTRUST 未委托 NO-TRADE 未成交 SOME-TRADE 部分成交 COMPLE-TRADE 完全成交 WITHDRAWN 已撤销)
price true number 委托价
count true number 委托量
amount true number 委托总额
leftCount true number 未成交数量
completePrice true number 成交均价
completeCount true number 成交数量
completeAmount true number 成交总额
incomeAmount true number 平仓收益额
incomeRate true number 平仓收益率
usedFees true number 总手续费
source true string 委单来源
createTime true string 创建时间
entrustTime true string 委托时间
updateTime true string 修改时间
completeTime true null 成交时间(最后成交时间)

请求示例

const axios = require('axios');

axios.post('/contract/entrust/currentEntrust', {

Content-Type: 'application/json',

ids: "[1,2,3]",

symbol: "btc_usdt_sustainable",

positionsType: "BY",

tradeMode: "OPEN_UP",

entrustTypes: "LIMIT",

matchType: "LIMIT_DEFAULT",

requestMatchType: "DEFAULT",

status: " ",

startCreateTime: "2022-01-19",

endCreateTime: "2022-01-19",

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/contract/entrust/currentEntrust";

jsonObject.put("symbol", batchCancelRequest.getSymbol());

if (null != batchCancelRequest.getIds() && !"".equals(batchCancelRequest.getIds())) {

jsonObject.put("ids", batchCancelRequest.getIds());

}

if (null != batchCancelRequest.getPositionsType() && !"".equals(batchCancelRequest.getPositionsType())) {

jsonObject.put("positionsType", batchCancelRequest.getPositionsType());

}

if (null != batchCancelRequest.getTradeMode() && !"".equals(batchCancelRequest.getTradeMode())) {

jsonObject.put("tradeMode", batchCancelRequest.getTradeMode());

}

if (null != batchCancelRequest.getEntrustTypes() && !"".equals(batchCancelRequest.getEntrustTypes())) {

jsonObject.put("entrustTypes", batchCancelRequest.getEntrustTypes());

}

if (null != batchCancelRequest.getMatchTypes() && !"".equals(batchCancelRequest.getMatchTypes())) {

jsonObject.put("matchTypes", batchCancelRequest.getMatchTypes());

}

if (null != batchCancelRequest.getRequestMatchType() && !"".equals(batchCancelRequest.getRequestMatchType())) {

jsonObject.put("requestMatchType", batchCancelRequest.getRequestMatchType());

}

if (null != batchCancelRequest.getStatus() && !"".equals(batchCancelRequest.getStatus())) {

jsonObject.put("status", batchCancelRequest.getStatus());

}

if (null != batchCancelRequest.getStartCreateTime() && !"".equals(batchCancelRequest.getStartCreateTime())) {

jsonObject.put("startCreateTime", batchCancelRequest.getStartCreateTime());

}

if (null != batchCancelRequest.getEndCreateTime() && !"".equals(batchCancelRequest.getEndCreateTime())) {

jsonObject.put("endCreateTime", batchCancelRequest.getEndCreateTime());

}

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/contract/entrust/currentEntrust'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['ids'] = 'ids'

params['symbol'] = 'symbol'

params['positionsType'] = 'positionsType'

params['tradeMode'] = 'tradeMode'

params['entrustTypes'] = 'entrustTypes'

params['matchTypes'] = 'matchTypes'

params['requestMatchType'] = 'requestMatchType'

params['status'] = 'status'

params['startCreateTime'] = 'startCreateTime'

params['endCreateTime'] = 'endCreateTime'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

查询用户历史委托单

POST  /contract/entrust/historyEntrust

● 是否需要验签:Y

● 请求参数

参数名称 类型 是否必须 示例 默认值 备注
ids string false 委单id集合
symbol string true 交易对标识
positionsType string false 仓位类型(BY=逐仓, TOTAL=全仓)
tradeMode string false 交易模式(OPEN_UP=开多 OPEN_DOWN=开空,CLOSE_UP=平多 CLOSE_DOWN=平空 )
entrustTypes string [] false 委托类型(LIMIT=限价, MARKET=市价,FULL_STOP=止盈止损,PLAN_FULL_STOP=计划委托)
matchTypes string [] false 撮合类型(LIMIT_DEFAULT=默认,MATCH_ONE_WAY=单向止盈止损,MATCH_TWO_WAY=双向止盈止损,POST_ONLY=只做maker, FOK=全部成交或立即取消, IOC=立即成交并取消剩余)
requestMatchType string false 请求撮合类型(DEFAULT=限价/市价, ADVANCED_PRICE_LIMIT=高级限价)
status string false 状态(WITHDRAWN)
startCreateTime string false 开始创建时间 (2022-01-13 00:00:00)
endCreateTime string false 结束创建时间 (2022-01-14 00:00:00)

● 响应参数:

参数名称 是否必须 类型 默认值 备注
status false string
message false null
pageNum false number 当前页数
pageSize false number 每页条数
total false number 总数
pages false number 总页数
id true string 主键id
userId true number 用户id
partnerId true number 商户id
tradeId true number 合约id
buyCoinId true number 买币种id
buyCoinName true string 买币种名称
sellCoinId true number 卖币种id
sellCoinName true string 卖币种名称
tradeName true string 交易对名称
symbol true string 交易对标识
contractType true string 类型(USDT_SUSTAINABLE=usdt永续, USDT_DELIVERY=usdt交割, USD_SUSTAINABLE=usd永续, USD_DELIVERY=usd交割)
positionsType true string 仓位类型(BY=逐仓, TOTAL=全仓)
lever true number 杠杆倍数
entrustMode true string 类型(ONE_WAY=单向, TWO_WAY=双向)
tradeMode true string 类型(OPEN_UP=开多 OPEN_DOWN=开空,CLOSE_UP=平多 CLOSE_DOWN=平空 )
entrustType true string 委托类型(LIMIT=限价, MARKET=市价,FULL_STOP=止盈止损,PLAN_FULL_STOP=计划委托)
matchType true string 撮合类型(LIMIT_DEFAULT=默认,MATCH_ONE_WAY=单向止盈止损,MATCH_TWO_WAY=双向止盈止损,POST_ONLY=只做maker, FOK=全部成交或立即取消, IOC=立即成交并取消剩余)
direction true nullstring 类型(MAKER=挂单, TAKER=吃单)
status true string 状态(NO-ENTRUST 未委托 NO-TRADE 未成交 SOME-TRADE 部分成交 COMPLE-TRADE 完全成交 WITHDRAWN 已撤销)
price true number 委托价
count true number 委托量
amount true number 委托总额
leftCount true number 未成交数量
completePrice true number 成交均价
completeCount true number 成交数量
completeAmount true number 成交总额
incomeAmount true number 平仓收益额
incomeRate true number 平仓收益率
usedFees true number 总手续费
source true string 委单来源
createTime true string 创建时间
entrustTime true string 委托时间
updateTime true string 修改时间
completeTime true null 成交时间(最后成交时间)

请求示例

const axios = require('axios');

axios.post('/contract/entrust/batchCancelEntrustByIds', {

Content-Type: 'application/json',

ids: "[1,2,3]",

symbol: "btc_usdt_sustainable",

positionsType: "BY",

tradeMode: "OPEN_UP",

entrustTypes: "LIMIT",

matchType: "LIMIT_DEFAULT",

requestMatchType: "DEFAULT",

status: "WITHDRAWN",

startCreateTime: "2022-01-13 00:00:00",

endCreateTime: "2022-01-14 00:00:00",

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/contract/entrust/historyEntrust";

jsonObject.put("symbol", batchCancelRequest.getSymbol());

if (null != batchCancelRequest.getIds() && !"".equals(batchCancelRequest.getIds())) {

jsonObject.put("ids", batchCancelRequest.getIds());

}

if (null != batchCancelRequest.getPositionsType() && !"".equals(batchCancelRequest.getPositionsType())) {

jsonObject.put("positionsType", batchCancelRequest.getPositionsType());

}

if (null != batchCancelRequest.getTradeMode() && !"".equals(batchCancelRequest.getTradeMode())) {

jsonObject.put("tradeMode", batchCancelRequest.getTradeMode());

}

if (null != batchCancelRequest.getEntrustTypes() && !"".equals(batchCancelRequest.getEntrustTypes())) {

jsonObject.put("entrustTypes", batchCancelRequest.getEntrustTypes());

}

if (null != batchCancelRequest.getMatchTypes() && !"".equals(batchCancelRequest.getMatchTypes())) {

jsonObject.put("matchTypes", batchCancelRequest.getMatchTypes());

}

if (null != batchCancelRequest.getRequestMatchType() && !"".equals(batchCancelRequest.getRequestMatchType())) {

jsonObject.put("requestMatchType", batchCancelRequest.getRequestMatchType());

}

if (null != batchCancelRequest.getStatus() && !"".equals(batchCancelRequest.getStatus())) {

jsonObject.put("status", batchCancelRequest.getStatus());

}

if (null != batchCancelRequest.getStartCreateTime() && !"".equals(batchCancelRequest.getStartCreateTime())) {

jsonObject.put("startCreateTime", batchCancelRequest.getStartCreateTime());

}

if (null != batchCancelRequest.getEndCreateTime() && !"".equals(batchCancelRequest.getEndCreateTime())) {

jsonObject.put("endCreateTime", batchCancelRequest.getEndCreateTime());

}

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/contract/entrust/historyEntrust'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['ids'] = 'ids'

params['symbol'] = 'symbol'

params['positionsType'] = 'positionsType'

params['tradeMode'] = 'tradeMode'

params['entrustTypes'] = 'entrustTypes'

params['matchTypes'] = 'matchTypes'

params['requestMatchType'] = 'requestMatchType'

params['status'] = 'status'

params['startCreateTime'] = 'startCreateTime'

params['endCreateTime'] = 'endCreateTime'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

查询用户成交明细

POST  /contract/entrust/entrustOrder

● 是否需要验签:Y

● 请求参数

参数名称 类型 是否必须 示例 默认值 备注
ids string false 委单id集合
symbol string true 交易对标识
positionsType string false 仓位类型(BY=逐仓, TOTAL=全仓)
tradeMode string false 交易模式(OPEN_UP=开多 OPEN_DOWN=开空,CLOSE_UP=平多 CLOSE_DOWN=平空 )
entrustType string [] false 委托类型(LIMIT=限价, MARKET=市价,FULL_STOP=止盈止损,PLAN_FULL_STOP=计划委托)
matchType string [] false 撮合类型(LIMIT_DEFAULT=默认,MATCH_ONE_WAY=单向止盈止损,MATCH_TWO_WAY=双向止盈止损,POST_ONLY=只做maker, FOK=全部成交或立即取消, IOC=立即成交并取消剩余)
startCreateTime string false 开始创建时间
endCreateTime string false 结束创建时间

● 响应参数:

参数名称 是否必须 类型 默认值 备注
status false string
message false null
pageNum false number 当前页数
pageSize false number 每页条数
total false number 总数
pages false number 总页数
id true string 主键id
userId true number 用户ID
parentId true number 委单ID
partnerId true number 商户ID
tradeId true number 商合约交易对ID
buyCoinId true number 买币种id
buyCoinName true string 买币种名称
sellCoinId true number 卖币种id
sellCoinName true string 卖币种名称
tradeName true string 交易对名称
symbol true string 交易对标识
contractType true string 类型(USDT_SUSTAINABLE=usdt永续, USDT_DELIVERY=usdt交割, USD_SUSTAINABLE=usd永续, USD_DELIVERY=usd交割)
positionsType true string 仓位类型(BY=逐仓, TOTAL=全仓)
lever true string 杠杆倍数
tradeMode true string 类型( OPEN_UP=开多 OPEN_DOWN=开空,CLOSE_UP=平多 CLOSE_DOWN=平空 )
entrustType true string 委托类型(LIMIT=限价, MARKET=市价,FULL_STOP=止盈止损,PLAN_FULL_STOP=计划委托)
matchType true string 撮合类型(LIMIT_DEFAULT=默认,MATCH_ONE_WAY=单向止盈止损,MATCH_TWO_WAY=双向止盈止损,POST_ONLY=只做maker, FOK=全部成交或立即取消, IOC=立即成交并取消剩余)
direction true string 类型(MAKER=挂单, TAKER=吃单)
price true number 下单单价
count true number 下单数量
amount true number 下单总价
fees true number 手续费
createTime true string 创建时间

请求示例

const axios = require('axios');

axios.post('/contract/entrust/entrustOrder', {

Content-Type: 'application/json',

ids: "[1,2,3]",

symbol: "btc_usdt_sustainable",

positionsType: "BY",

tradeMode: "OPEN_UP",

entrustType: "LIMIT",

matchType: "LIMIT_DEFAULT",

startCreateTime: "2022-01-13 00:00:00",

endCreateTime: "2022-01-19 00:00:00",

}).then(function (response) {

console.log(response);

});

JSONObject jsonObject = new JSONObject();

String method = "/contract/entrust/entrustOrder";

jsonObject.put("symbol", batchCancelRequest.getSymbol());

if (null != batchCancelRequest.getIds() && !"".equals(batchCancelRequest.getIds())) {

jsonObject.put("ids", batchCancelRequest.getIds());

}

if (null != batchCancelRequest.getPositionsType() && !"".equals(batchCancelRequest.getPositionsType())) {

jsonObject.put("positionsType", batchCancelRequest.getPositionsType());

}

if (null != batchCancelRequest.getTradeMode() && !"".equals(batchCancelRequest.getTradeMode())) {

jsonObject.put("tradeMode", batchCancelRequest.getTradeMode());

}

if (null != batchCancelRequest.getEntrustType() && !"".equals(batchCancelRequest.getEntrustType())) {

jsonObject.put("entrustTypes", batchCancelRequest.getEntrustType());

}

if (null != batchCancelRequest.getMatchType() && !"".equals(batchCancelRequest.getMatchType())) {

jsonObject.put("matchTypes", batchCancelRequest.getMatchType());

}

if (null != batchCancelRequest.getStartCreateTime() && !"".equals(batchCancelRequest.getStartCreateTime())) {

jsonObject.put("startCreateTime", batchCancelRequest.getStartCreateTime());

}

if (null != batchCancelRequest.getEndCreateTime() && !"".equals(batchCancelRequest.getEndCreateTime())) {

jsonObject.put("endCreateTime", batchCancelRequest.getEndCreateTime());

}

jsonObject.put("timestamp", System.currentTimeMillis() + "");

jsonObject.put("accessKey", ConstantKey.ACCESS_KEY.trim());

String json = ExchApiUtil.getJsonPost(jsonObject, method, ConstantKey.SECRET_KEY);

method = '/contract/entrust/entrustOrder'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['ids'] = 'ids'

params['symbol'] = 'symbol'

params['positionsType'] = 'positionsType'

params['tradeMode'] = 'tradeMode'

params['entrustType'] = 'entrustType'

params['matchType'] = 'matchType'

params['startCreateTime'] = 'startCreateTime'

params['endCreateTime'] = 'endCreateTime'

params['timestamp'] = 'timestamp'

params['signature'] = self.get_sign(params).decode('utf-8')

headers = {"content-type": "application/json;charset=UTF-8"}

rsp = requests.post(method,data=json.dumps(params),headers=headers)

响应示例

JSON

//返回结果


                            

合约账户动态数据

GET  /personal/getActualAccount

● 是否需要验签:N

● 请求参数

参数名称 类型 是否必须 示例 默认值 备注
coinName string true
positionsType string true

● 响应参数:

参数名称 是否必须 类型 默认值 备注
usePosition false number 已用保证金
frozenPosition false number 冻结保证金
realizationIncome false number 已实现收益
accountRights false number 账户权益
frozen false number 账户冻结
updateTime false number 修改时间
unRealizationIncome false number 未实现收益
userId false number 用户ID
positionRate false number 保证金率
coinId false number 币种id
total false number 账户余额
minPositionRate false number 维持保证金率
partnerId false number 商户ID
enablePosition false number 可用保证金

请求示例

const axios = require('axios');

axios.get('/contract/entrust/entrustOrder', {

Content-Type: 'application/json',

coinName: "btc",

positionsType: "BY",

}).then(function (response) {

console.log(response);

});

String method = "/personal/getActualAccount";

String param = "coinName=" + coinName+ "&positionsType=" + positionsType+ "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/contract/market/depth'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['coinName'] = 'coinName'

params['positionsType'] = 'positionsType'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

获取单个交易对的k线

GET  /contract/market/kline

● 是否需要验签:N

● 请求参数

参数名称 类型 是否必须 示例 默认值 备注
symbol string true btc_usdt_sustainable 交易对标识
klineType string true MIN MIN5 MIN15 MIN30 HOUR1 HOUR4 DAY WEEK K线周期
klineStep string true STEP0 50条数据 STEP1 100条数据 K线步长(k线数量)

● 响应参数:

连续6个值分别是 高 开 低 收 成交额 时间

参数名称 是否必须 类型 默认值 备注
false number 41799.30
false number 41799.20
false number 41788.70
false number 41788.70
false number 7.57 成交额
false number 1642575060000 时间

请求示例

const axios = require('axios');

axios.get('/contract/market/kline', {

Content-Type: 'application/json',

symbol: "BTCUSDT",

klineType: "MIN",

klineStep: "STEP0",

}).then(function (response) {

console.log(response);

});

String method = "/contract/market/kline";

String param = "symbol=" + symbol+ "&klineType=" + klineType+"&klineStep=" + klineStep+ "&accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY);

String returnJson = ExchApiUtil.sendGet(method, param);

method = '/contract/market/kline'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['klineType'] = 'klineType'

params['klineStep'] = 'klineStep'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

查询用户持仓汇总

GET  /contract/Storage/summaryPosition

● 是否需要验签:N

● 请求参数

参数名称 类型 是否必须 示例 默认值 备注
symbol string true BTCUSDT 交易对标识
positionsType string false 仓位类型(BY=逐仓, TOTAL=全仓)
contractType string false 类型(USDT_SUSTAINABLE=usdt永续, USDT_DELIVERY=usdt交割, USD_SUSTAINABLE=usd永续, USD_DELIVERY=usd交割)

● 响应参数:

参数名称 是否必须 类型 默认值 备注
upAllHoldMoney false number 多仓持仓总量
upAveragePrice false number 多仓均价
downAveragePrice false number 空仓均价
tradeId false number 合约交易对id
downAllHoldAmount false number 空仓持仓量
upAllHoldAmount false number 多仓持仓总量
downAllHoldMoney false number

请求示例

const axios = require('axios');

axios.get('/contract/Storage/summaryPosition', {

Content-Type: 'application/json',

accessKey: "ACCESSKEY",

symbol: "BTCUSDT",

positionsType: "BY",

contractType: "USDT_SUSTAINABLE",

}).then(function (response) {

console.log(response);

});

StringBuffer stringBuffer = new StringBuffer();

String method = "/contract/Storage/summaryPosition";

stringBuffer.append("accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY.trim()));

stringBuffer.append("symbol=" + symbol);

if (summaryPositionRequest.getPositionsType() != null && !"".equals(summaryPositionRequest.getPositionsType())) {

stringBuffer.append("&positionsType=" + summaryPositionRequest.getPositionsType());

}

if (summaryPositionRequest.getContractType() != null && !"".equals(summaryPositionRequest.getContractType())) {

stringBuffer.append("&contractType=" + summaryPositionRequest.getContractType());

}

String returnJson = ExchApiUtil.sendGet(method, stringBuffer.toString());

method = '/contract/Storage/summaryPosition'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['positionsType'] = 'positionsType'

params['contractType'] = 'contractType'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

查询用户当前持仓

GET  /contract/Storage/currentPosition

● 是否需要验签:N

● 请求参数

参数名称 类型 是否必须 示例 默认值 备注
positionsType string false BTCUSDT 持仓模式,默认传空'字符串,(BY=逐仓, TOTAL=全仓,)
symbol string false 交易对标识
contractType string false 类型(USDT_SUSTAINABLE=usdt永续, USDT_DELIVERY=usdt交割, USD_SUSTAINABLE=usd永续, USD_DELIVERY=usd交割)
pageNumber number false 当前页数
pageSize number false 每页条数

● 响应参数:

参数名称 是否必须 类型 默认值 备注
allBalanceIncome true number 已结算收益
allIncomeAmount true number 收益
allIncomeAmountRate true number 收益率
allTime true string 全部平完时间
balancePrice false number
buyCoinNickname false string 买方币种别名
coinId true string 币种id
contractCoinId true string 合约币种id
contractType true string 类型(USDT_SUSTAINABLE=usdt永续, USDT_DELIVERY=usdt交割, USD_SUSTAINABLE=usd永续, USD_DELIVERY=usd交割)
createTime true string 开仓时间
enableUnwind true number 可平量
forceAmount true number 强平量
forceMarginRate true number 强平保证金率
forcePrice true number 强平价
forceTime true string 强平时间
frozenAmount true number 平仓挂单冻结量
holdAmount true number 持仓量(持仓币数)
id true string 仓位id
incomeAmount true number 平仓收益额
incomeRate true number 平仓收益率
lastBalancePrice true number 结算基准价
lever true number 杠杆倍数
margin true number 保证金余额
marginAll true number
maxHoldAmount true number 最大持仓量
minPositionRate true number 维持保证金率
openPrice true number 开仓均价
openType true string 类型( OPEN_UP=开多 OPEN_DOWN=开空)
original true number 初始保证金
partnerId true string 商户id
positionAmount true number 保证金
positionRate true number 保证金率
positionsType true string 仓位类型(BY=逐仓, TOTAL=全仓)
preForcePrice true number 预估强平价
realForceMarginRate true number 实际强平保证金率
realizationIncome true number 已实现收益
sellCoinNickname true string 卖方币种别名
status true string 状态(NO_UNWIND=未平仓, PART_UNWIND=部分平仓,ALL_UNWIND=全部平仓,FORCE_UNWIND=强制平仓)
swiftId true string 业务id
symbol true string 币种唯一标识 例: BTC u本位永续 = BTC_USDT_SUSTAINABLE
tagPrice true number 触发标记价
type true string 类型(ONE_WAY=单向, TWO_WAY=双向)
unRealizationIncome true number 未实现收益
unwindAmount true number 平仓量
unwindPrice true number 平仓均价
updateTime true string
userId true string 用户id
version true number
hasPositionNum true string 持仓张数
hasPositionVal true string 持仓价值
tradeName true string 交易对名称
markPrice true string 市场标记价格
sellCoinId true number
faceValue true number 合约面值

请求示例

const axios = require('axios');

axios.get('/contract/Storage/currentPosition', {

positionsType: "BY",

symbol: "BTCUSDT",

contractType: "USDT_SUSTAINABLE",

pageNumber: 1,

pageSize: 10,

}).then(function (response) {

console.log(response);

});

StringBuffer stringBuffer = new StringBuffer();

String method = "/contract/Storage/currentPosition";

stringBuffer.append("accessKey=" + URLEncoder.encode(ConstantKey.ACCESS_KEY.trim()));

stringBuffer.append("symbol=" + symbol);

if (currentPositionRequest.getPositionsType() != null && !"".equals(currentPositionRequest.getPositionsType())) {

stringBuffer.append("&positionsType=" + currentPositionRequest.getPositionsType());

}

if (currentPositionRequest.getContractType() != null && !"".equals(currentPositionRequest.getContractType())) {

stringBuffer.append("&contractType=" + currentPositionRequest.getContractType());

}

if (currentPositionRequest.getPageNumber() != null && !"".equals(currentPositionRequest.getPageNumber())) {

stringBuffer.append("&pageNumber=" + currentPositionRequest.getPageNumber());

}

if (currentPositionRequest.getPageSize() != null && !"".equals(currentPositionRequest.getPageSize())) {

stringBuffer.append("&pageSize=" + currentPositionRequest.getPageSize());

}

String returnJson = ExchApiUtil.sendGet(method, stringBuffer.toString());

method = '/contract/Storage/currentPosition'

params = {}

params['accessKey'] = 'ACCESSKEY'

params['symbol'] = 'symbol'

params['positionsType'] = 'positionsType'

params['contractType'] = 'contractType'

params['pageNumber'] = 'pageNumber'

params['pageSize'] = 'pageSize'

rsp = requests.get(method,params)

响应示例

JSON

//返回结果


                            

错误代码

错误信息示例


                            

【公共区】

错误代码 描述
common_success 成功!
common_failure 失败!
common_failure_0001 网络异常
get_login_failure 获取授权者信息失败
access_key_not_found 访问秘钥不存在
inconsistent_parameters_and_signatures 参数和签名不一致
access_key_not_found_or_ip_Incorrect accessKey不存在或者ip地址不正确
json_unresolved json无法解析
signature_verification_failed 签名校验失败,签名无法解析
user_pay_is_error 交易密码错误
disable_access 已被禁止访问
ip_disable_access IP已被禁止访问
access_IP_not_found 访问的IP不存在
excessive_access 访问过快
access_failure 请求失败

【行情】

错误代码 描述
api_market_001 无效的用户信息
api_market_002 无效的交易对名称
api_market_003 无效的参数
api_market_004 暂无数据
api_market_005 获取失败

【委单国际化文件】

错误代码 描述
entrust_failure_0001 网络异常
entrust_failure_0002 查询类型错误
entrust_failure_0003 撮合类型不能为空
entrust_failure_0004 商户ID不能为空
entrust_failure_0005 用户不存在
entrust_failure_0007 交易对ID不能为空
entrust_failure_0009 交易对不存在
entrust_failure_0010 交易密码不能为空
entrust_failure_0011 交易密码错误
entrust_failure_0012 委单类型不能为空
entrust_failure_0013 委单数量不能为空
entrust_failure_0014 限价单委托单价不能为空
entrust_failure_0015 委单ID不能为空
entrust_failure_0016 委托单不存在
entrust_failure_0017 该委托单已被删除
entrust_failure_0018 该委托单不能被撤单
entrust_failure_0019 版本号不能为空
entrust_failure_0020 市价单不能被撤单
entrust_failure_0021 当前数据已更新
entrust_failure_0022 当前没有委托单,不能下市价单
entrust_failure_0023 交易对被禁用或相关币种被禁用
entrust_failure_0024 该交易对未开启交易
entrust_failure_0025 委托价格低于最低限价或高于最高限价
entrust_failure_0026 委托数量低于最低限量或高于最高限量
entrust_failure_0027 该账号已被禁止交易,请咨询客服
entrust_failure_0028 超出该交易对可购买数量
entrust_failure_0029 当前交易对无权卖出
entrust_failure_0030 超过当前交易对单日最高涨幅
entrust_failure_0031 超过当前交易对单日最高跌幅
entrust_failure_0032 委托价格高于最高限价
entrust_failure_0033 委托数量高于最高限量
entrust_failure_0034 委托交易额低于最低交易额
entrust_failure_0035 委托交易额高于最高交易额
entrust_failure_0036 撮合未准备就绪,请稍后再试
entrust_failure_0037 委单客户端请求ID不能重复
entrust_failure_0038 委单客户端请求ID不存在
entrust_failure_0039 委单客户端请求ID不能为空

【充提管理】

错误代码 描述
account_failure_0002 账户可用资产不足,无法处理
recharge_withdraw_failure_0001 网络异常
recharge_withdraw_failure_0002 交易密码不能为空
recharge_withdraw_failure_0003 验证码不能为空
recharge_withdraw_failure_0004 商户ID不能为空
recharge_withdraw_failure_0005 用户不存在
recharge_withdraw_failure_0007 币种不存在
recharge_withdraw_failure_0010 谷歌验证码不能为空
recharge_withdraw_failure_0011 交易密码错误
recharge_withdraw_failure_0012 充值类型不能为空
recharge_withdraw_failure_0013 充值数量不能为空
recharge_withdraw_failure_0014 充值备注不能为空
recharge_withdraw_failure_0015 充值单不存在
recharge_withdraw_failure_0017 只有等待充值的才能被删除
recharge_withdraw_failure_0018 只有等待充值的才能审核
recharge_withdraw_failure_0019 只有审核通过的才能发放冻结
recharge_withdraw_failure_0020 版本号不能为空
recharge_withdraw_failure_0021 参数错误
recharge_withdraw_failure_0022 当前数据已更新
recharge_withdraw_failure_0023 数据不存在
recharge_withdraw_failure_0024 只有锁定状态才能审核
recharge_withdraw_failure_0025 只有等待提现状态才能锁定
recharge_withdraw_failure_0026 只有等待提现或锁定状态时才能取消
recharge_withdraw_failure_0027 冻结数量不能为空
recharge_withdraw_failure_0028 冻结原因不能为空
recharge_withdraw_failure_0029 解冻备注不能为空
recharge_withdraw_failure_0030 提币数量不能为空
recharge_withdraw_failure_0031 提币地址不能为空
recharge_withdraw_failure_0032 手续费不能为空
recharge_withdraw_failure_0033 手续费异常
recharge_withdraw_failure_0034 数据不存在
recharge_withdraw_failure_0035 该资产单不能解冻
recharge_withdraw_failure_0036 提币地址不正确
recharge_withdraw_failure_0037 提币备注不能为空
recharge_withdraw_failure_0038 外部提币异常