Restful API 币本位合约V1.1
描述
- v1.1 对 v1的返回结果进行了精简。要求:参数中cmds只包含一个cmd。
查询持仓变化记录
cmd:bc/dealLog
请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 合约符号 | 5BTC_USD,5ETH_USD, ... | |
page | true | integer | 第几页 | 1,2, ... | |
size | true | integer | 条数 | 10,20, ... |
- 示例
请求参数
// Request
[
{
"cmd":"bc/dealLog",
"body":{
"pair":"5BTC_USD",
"page":1,
"size":10
},
"index":1
}
]
{
"url":"http://tapi.bibox365aa.com:33050/v1.1/cquery",
"form":{
"cmds":"[{\"cmd\":\"bc/dealLog\",\"body\":{\"pair\":\"5BTC_USD\",\"page\":1,\"size\":10},\"index\":1}]",
"apikey":"900625568558820892a8c833c33ebc8fd2701efe",
"sign":"4429dee1480d6b046a087b10b751143b"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "http://tapi.bibox365aa.com:33050/v1.1/cquery";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = [
{
"cmd":"bc/dealLog",
"body":{
"pair": "5BTC_USD",
"page": 1,
"size": 10,
},
"index":1
}
];
let form = {
"cmds": JSON.stringify(param), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign cmds
form.sign = sign;
console.log(JSON.stringify(param))
console.log(JSON.stringify({url, form}))
request.post({url, form }, (error, response, body) => {
if (!error && response && response.statusCode === 200) {
try {
console.log(body)
} catch (error) {
console.log(error)
}
} else {
console.log(error, response, body);
}
});
返回结果
// Response
{
"result":{
"count":3,
"page":1,
"items":[
{
"id":"1125899906842635654", // 仓位变化id
"user_id":100006, // 用户id
"coin_symbol":"BTC",// 币种
"pair":"5BTC_USD",// 交易对
"side":1,// 仓位方向 1多仓,2空仓
"model":1,// 仓位模式,1全仓,2逐仓
"log_type":1,// 变化类型 1开仓,2平仓,3减仓降低风险等级, 4爆仓清空仓位, 5ADL
"hold_coin_dx":"1.0000000000",// 仓位持仓变化量
"hold_coin":"1.0000000000",// 仓位持仓
"price_log":"11692.0000000000",// 参考价格
"price_open":"11692.0000000000",// 开仓均价
"profit":"0.0000000000",// 收益
"fee":"0.0000000599",// 手续费
"fee_bix":"0.0000000000",// bix抵扣
"fee_bix0":"0.0000000000", // 优惠券抵扣
"createdAt":"2020-10-14T03:00:08.000Z",// 变化时间
"updatedAt":"2020-10-14T03:00:08.000Z"
},
...
]
},
"cmd":"bc/dealLog",
"index":1
}
查询订单成交明细
cmd:bc/orderDetail
请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
orderId | true | long | 订单id | ||
page | true | integer | 第几页 | 1,2, ... | |
size | true | integer | 条数 | 10,20, ... |
- 示例
请求参数
// Request
[
{
"cmd":"bc/orderDetail",
"body":{
"orderId":"421112953438213",
"page":1,
"size":10
},
"index":1
}
]
{
"url":"http://tapi.bibox365aa.com:33050/v1.1/cquery",
"form":{
"cmds":"[{\"cmd\":\"bc/orderDetail\",\"body\":{\"orderId\":\"421112953438213\",\"page\":1,\"size\":10},\"index\":1}]",
"apikey":"900625568558820892a8c833c33ebc8fd2701efe",
"sign":"a8741a05515df4be5ce75a2776790a0c"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "http://tapi.bibox365aa.com:33050/v1.1/cquery";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = [
{
"cmd":"bc/orderDetail",
"body":{
"orderId": "421112953438213",
"page": 1,
"size": 10,
},
"index":1
}
];
let form = {
"cmds": JSON.stringify(param), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign cmds
form.sign = sign;
console.log(JSON.stringify(param))
console.log(JSON.stringify({url, form}))
request.post({url, form }, (error, response, body) => {
if (!error && response && response.statusCode === 200) {
try {
console.log(body)
} catch (error) {
console.log(error)
}
} else {
console.log(error, response, body);
}
});
返回结果
// Response
{
"result":{
"count":1,
"page":1,
"items":[
{
"id":"1125899906842635651",// 明细id
"coin_symbol":"BTC",// 币种
"pair":"5BTC_USD",// 交易对
"side":2,// 挂单方向 1开多,2开空,3平多,4平空
"order_from":4,// 订单来源
"price":"10692.0000000000",// 挂单价格
"deal_price":"11510.0000000000",// 成交价格
"deal_coin":"1.0000000000",// 成交价值
"fee":"0.0000000608",// 手续费
"fee_bix":"0.0000000000",// bix抵扣
"fee_bix0":"0.0000000000",// 优惠券抵扣
"is_maker":0,// 是否是maker
"createdAt":"2020-10-14T02:58:59.000Z"// 成交时间
}
]
},
"cmd":"bc/orderDetail",
"index":1
}
查询历史委托
cmd:bc/orderHistory
请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | false | string | 合约符号 | 5BTC_USD,5ETH_USD, ... | |
page | true | integer | 第几页 | 1,2, ... | |
size | true | integer | 条数 | 10,20, ... | |
side | false | integer | 1开多 2开空 3平多 4平空 | ||
status | false | 数组 | 状态,3:全部成交,4:部分撤单, 5:全部撤单, 100:下单失败 |
- 示例
请求参数
// Request
[
{
"cmd":"bc/orderHistory",
"body":{
"page":1,
"size":10,
"pair":"5BTC_USD",
"side":1,
"status":[
3,
4,
5,
100
]
},
"index":1
}
]
{
"url":"http://tapi.bibox365aa.com:33050/v1.1/cquery",
"form":{
"cmds":"[{\"cmd\":\"bc/orderHistory\",\"body\":{\"page\":1,\"size\":10,\"pair\":\"5BTC_USD\",\"side\":1,\"status\":[3,4,5,100]},\"index\":1}]",
"apikey":"900625568558820892a8c833c33ebc8fd2701efe",
"sign":"e5da11a7b038b1ad546243706aa75ecc"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "http://tapi.bibox365aa.com:33050/v1.1/cquery";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = [
{
"cmd":"bc/orderHistory",
"body":{
"page": 1,
"size": 10,
"pair": "5BTC_USD",
"side": 1,
"status": [3, 4, 5, 100],
},
"index":1
}
];
let form = {
"cmds": JSON.stringify(param), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign cmds
form.sign = sign;
console.log(JSON.stringify(param))
console.log(JSON.stringify({url, form}))
request.post({url, form }, (error, response, body) => {
if (!error && response && response.statusCode === 200) {
try {
console.log(body)
} catch (error) {
console.log(error)
}
} else {
console.log(error, response, body);
}
});
返回结果
// Response
{
"result":{
"count":1,
"page":1,
"items":[
{
"id":421112953438215,// 订单id
"user_id":100006,// 用户id
"coin_symbol":"BTC",// 币种
"pair":"5BTC_USD",// 交易对
"side":1,// 挂单方向
"order_type":2,// 挂单类型 1市价,2限价
"price":"11692.0000000000",// 挂单价格
"amount_coin":"1.0000000000",// 挂单数量
"freeze":"0.0000000000",// 冻结资金
"price_deal":"11692.0000000000",// 成交均价
"deal_coin":"1.0000000000",// 成交价值
"deal_num":1,// 成交笔数
"fee":"0.0000000599",// 手续费
"fee_bix":"0.0000000000",// bix抵扣
"fee_bix0":"0.0000000000",// 优惠券抵扣
"status":3,// 订单状态,1未成交,2部分成交,3完全成交,4部分撤销,5全部撤销,100下单失败
"reason":0,// 失败原因
"fee_rate_maker":"0.0007000000",// maker手续费费率
"fee_rate_taker":"0.0007000000",// taker手续费费率
"client_oid":1602644402806,// 自定义id
"order_from":4, // 忽略
"createdAt":"2020-10-14T03:00:08.000Z",// 挂单时间
"updatedAt":"2020-10-14T03:00:08.000Z"// 最新变化时间
}
]
},
"cmd":"bc/orderHistory",
"index":1
}
查询订单
cmd:bc/orderById
请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
orderIds | true | 数组 | 订单id数组 | ||
clientOids | true | 数组 | 订单自定义di数组 |
- 示例
请求参数
// Request
[
{
"cmd":"bc/orderById",
"body":{
"orderIds":[
"421112953438213",
"421112953438214"
],
"clientOids":[
"1602644402806",
"1602644402811"
]
},
"index":1
}
]
{
"url":"http://tapi.bibox365aa.com:33050/v1.1/cquery",
"form":{
"cmds":"[{\"cmd\":\"bc/orderById\",\"body\":{\"orderIds\":[\"421112953438213\",\"421112953438214\"],\"clientOids\":[\"1602644402806\",\"1602644402811\"]},\"index\":1}]",
"apikey":"900625568558820892a8c833c33ebc8fd2701efe",
"sign":"8a83452af336b6cf14a0c0090da96912"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "http://tapi.bibox365aa.com:33050/v1.1/cquery";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = [
{
"cmd":"bc/orderById",
"body":{
"orderIds": ["421112953438213", "421112953438214"],
"clientOids": ["1602644402806", "1602644402811"],
},
"index":1
}
];
let form = {
"cmds": JSON.stringify(param), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign cmds
form.sign = sign;
console.log(JSON.stringify(param))
console.log(JSON.stringify({url, form}))
request.post({url, form }, (error, response, body) => {
if (!error && response && response.statusCode === 200) {
try {
console.log(body)
} catch (error) {
console.log(error)
}
} else {
console.log(error, response, body);
}
});
返回结果
// Response
{
"result":[
{
"id":421112953438214,// 订单id
"user_id":100006,// 用户id
"coin_symbol":"BTC",// 币种
"pair":"5BTC_USD",// 交易对
"side":1,// 挂单方向
"order_type":2,// 挂单类型 1市价,2限价
"price":"11692.0000000000",// 挂单价格
"amount_coin":"1.0000000000",// 挂单数量
"freeze":"0.0000000000",// 冻结资金
"price_deal":"11692.0000000000",// 成交均价
"deal_coin":"1.0000000000",// 成交价值
"deal_num":1,// 成交笔数
"fee":"0.0000000599",// 手续费
"fee_bix":"0.0000000000",// bix抵扣
"fee_bix0":"0.0000000000",// 优惠券抵扣
"status":3,// 订单状态,1未成交,2部分成交,3完全成交,4部分撤销,5全部撤销,100下单失败
"reason":0,// 失败原因
"fee_rate_maker":"0.0007000000",// maker手续费费率
"fee_rate_taker":"0.0007000000",// taker手续费费率
"client_oid":1602644402806,// 自定义id
"order_from":4, // 忽略
"createdAt":"2020-10-14T03:00:08.000Z",// 挂单时间
"updatedAt":"2020-10-14T03:00:08.000Z"// 最新变化时间
},
...
],
"cmd":"bc/orderById",
"index":1
}
查询资金费率
{
"result":{
"5BTC_USD":{
"pair":"5BTC_USD",
"close":"0.0000000000",
"fund_rate":"0.0001000000",
"createdAt":"2020-10-14T00:00:00.000Z"
},
"5ETH_USD":{
"pair":"5ETH_USD",
"close":"0.0000000000",
"fund_rate":"0.0001000000",
"createdAt":"2020-10-14T00:00:00.000Z"
}
},
"cmd":"bcFundRate"
}
查询标记价格
{
"result":{
"5BTC_USD":{//交易对
"close":"11453.7224909000",// 指数价格
"priceTag":"11454.2951770245",// 标记价格
"createdAt":"2020-10-14T03:41:08.000Z" // 时间
},
"5ETH_USD":{
"close":"383.1999999600",
"priceTag":"383.2191599600",
"createdAt":"2020-10-14T03:41:08.000Z"
}
},
"cmd":"bcTagPrice"
}
查询合约基本信息
{
"result":[
{
"id":465, // 忽略
"pair":"5BTC_USD",//交易对
"coin_symbol":"BTC", // 忽略
"leverage_init":"10.0000000000", // 忽略
"leverage_min":"0.0100000000",//最小杠杆倍数
"leverage_max":"100.0000000000",//最大杠杆倍数
"value":"1.0000000000",//合约面值
"risk_level_base":"1000000.0000000000",//忽略
"risk_level_dx":"50000.0000000000",//忽略
"maker_fee":"0.0006000000",//默认maker手续费费率
"taker_fee":"0.0006000000",//默认taker手续费费率
"open_max_per":"10000000.0000000000",//单笔挂单最大数量
"pending_max":100,//最大挂单个数
"hold_max":"100000000.0000000000",//最大持仓价值
"price_precision":1 // 忽略
},
{
"id":466,
"pair":"5ETH_USD",
"coin_symbol":"ETH",
"leverage_init":"10.0000000000",
"leverage_min":"0.0100000000",
"leverage_max":"100.0000000000",
"value":"1.0000000000",
"risk_level_base":"10000.0000000000",
"risk_level_dx":"5000.0000000000",
"maker_fee":"0.0006000000",
"taker_fee":"0.0006000000",
"open_max_per":"10000000.0000000000",
"pending_max":100,
"hold_max":"100000000.0000000000",
"price_precision":2
}
],
"cmd":"bcValue"
}
查询精度配置
- GET https://api.bibox.com/v1.1/cquery?cmd=bcUnit
- 返回结果说明
{
"result":[
{
"pair":"5BTC_USD",//交易对
"price_unit":1,//下单小数点数
"vol_unit":6, // 忽略
"value_unit":0 // 忽略
},
{
"pair":"5ETH_USD",
"price_unit":1,
"vol_unit":6,
"value_unit":0
}
],
"cmd":"bcUnit"
}