Restful API 合约交易详细描述
查询k线
- GET https://api.bibox.com/v1/mdata?cmd=kline&pair=4BTC_USDT&period=1min&size=10
- POST https://api.bibox.com/v1/mdata
- cmd: api/kline
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | 4BTC_USDT, 4ETH_USDT, ... | |
period | true | string | k线周期 | '1min', '3min', '5min', '15min', '30min', '1hour', '2hour', '4hour', '6hour', '12hour', 'day', 'week' | |
size | false | integer | 数量 | 1000 | 1-1000 |
- 示例
// Request
{
"cmd": "api/kline",
"body": {
"pair": "4BTC_USDT",
"period": "1min",
"size": 10
}
}
{
"url":"https://api.bibox.com/v1/mdata",
"form":{
"cmds":"[{\"cmd\":\"api/kline\",\"body\":{\"pair\":\"4BTC_USDT\",\"period\":\"1min\",\"size\":10}}]",
}
}
// Response
{
"result":[
{
"time":1575450180000, // 时间戳
"open":"7196.33000000", // 开盘价
"high":"7196.33000000", // 最高价
"low":"7188.90000000", // 最低价
"close":"7188.90000000", // 收盘价
"vol":"337.00000000" // 成交量
},
{
"time":1575450240000,
"open":"7188.88000000",
"high":"7188.96000000",
"low":"7185.67000000",
"close":"7187.18000000",
"vol":"844.00000000"
},
],
"cmd":"api/kline"
}
查询合约市场深度
- GET https://api.bibox.com/v1/mdata?cmd=depth&pair=4BTC_USDT&size=10
- POST https://api.bibox.com/v1/mdata
- cmd: api/depth
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | 4BTC_USDT, 4ETH_USDT, ... | |
size | false | integer | 数量 | 200 | 1-200 |
- 示例
// Request
{
"cmd": "api/depth",
"body": {
"pair": "4BTC_USDT"
}
}
{
"url":"https://api.bibox.com/v1/mdata",
"form":{
"cmds":"[{\"cmd\":\"api/depth\",\"body\":{\"pair\":\"4BTC_USDT\"}}]",
}
}
// Response
{
"result":{
"pair":"4BTC_USDT",
"update_time":1510983122681,
"asks":[ //卖方深度
{
"price":"0.008654", //挂单价格
"volume":"200.9123" //挂单数量
}
],
"bids":[ //买方深度
{
"price":"0.008596", //挂单价格
"volume":"18.54306495" //挂单数量
},
{
"price":"0.00859289",
"volume":"40.13567123"
}
]
},
"cmd":"api/depth"
}
查询合约资产
cmd:query/assets
示例
请求参数
// Request
[
{
"cmd":"query/assets",
"body":{}
}
]
{
"url":"https://api.bibox365.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/assets\",\"body\":{}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"85190bfcb83357b9fa5aa2e79f0d7826"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/cquery";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd": "query/assets",
"body": {}
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":{
"balance":"97.2378", // 可用余额
"freeze":"1.7326", // 冻结金额
"profit":"-2.4327",
"margin":"1.7326",
"imargin":"0.0000",
"total_balance":"98.8397",
"BTCValue":"0.02528321",
"CNYValue":"664.61",
"USDValue":"98.84",
"floatProfitBTC":"-0.00003344",
"floatProfit":"-0.1308",
"profitBTC":"-0.00062226",
"freezeBTC":"0.00044322"
},
"cmd":"query/assets"
}
]
}
查询单个合约持仓信息
cmd: query/order
请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 合约符号 | 4BTC_USDT,4ETH_USDT, ... |
- 示例
请求参数
// Request
{
"cmd":"query/order",
"body":{
"pair":"4BTC_USDT" // 合约符号:BTCUSDT永续合约符号为4BTC_USDT,ETHUSDT永续合约符号为4ETH_USDT 。。。
}
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/order\",\"body\":{\"pair\":\"4BTC_USDT\"}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"e533359a43984510ef4dbcb0941bac6b"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/cquery";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd": "query/order",
"body": {
"pair":"4BTC_USDT"
}
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":{
"coin_symbol":"USDT",
"pair":"4BTC_USDT", // 合约符号
"contract":2, // 持仓张数
"margin":"1.5612", // 持仓保证金
"profit":"-2.4995",
"price":"3903.0450", // 开仓均价
"order_side":2, // 开仓方向:1开多,2开空
"price_force":"3961.5907", // 强平价格
"floatProfit":"-0.1376",
"leverage":50, // 0:全仓,其它:逐仓杠杆倍数
"icontract_up":2, // 开多未成交订单张数
"icontract_down":0 // 开空未成交订单张数
},
"cmd":"query/order"
}
]
}
查询所有合约持仓信息
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderAll
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 合约符号 | 4BTC_USDT,4ETH_USDT, ... |
- 示例
请求参数
// Request
{
"cmd":"query/orderAll",
"body":{
}
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/orderAll\",\"body\":{}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"1a9be520fb658c677b86f99769634e5b"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/cquery";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd": "query/orderAll",
"body": {
}
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":[
{
"coin_symbol":"USDT",
"pair":"4BTC_USDT", // 合约符号
"contract":2, // 持仓张数
"margin":"1.5612", // 持仓保证金
"profit":"-2.4995",
"price":"3903.0450", // 开仓均价
"order_side":2, // 开仓方向:1开多,2开空
"price_force":"3961.5907", // 强平价格
"floatProfit":"-0.1376",
"leverage":50, // 0:全仓,其它:逐仓杠杆倍数
"icontract_up":2, // 开多未成交订单张数
"icontract_down":0 // 开空未成交订单张数
},
{
"coin_symbol":"USDT",
"pair":"4ETH_USDT",
"contract":6,
"margin":"0.1714",
"profit":"0.0668",
"price":"142.8816",
"order_side":2,
"price_force":"145.0248",
"floatProfit":"0.0063",
"leverage":50,
"icontract_up":6,
"icontract_down":0
}
],
"cmd":"query/orderAll"
}
]
}
查询合约未成交订单
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderPending
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
page | true | integer | 第几页 | 1,2, ... | |
size | true | integer | 条数 | 10,20, ... | |
pair | false | string | 合约符号 | 4BTC_USDT,4ETH_USDT, ... |
- 示例
请求参数
// Request
{
"cmd":"query/orderPending",
"body":{
"page":1,
"size":20,
"pair":""
}
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/orderPending\",\"body\":{\"page\":1,\"size\":20,\"pair\":\"\"}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"caef8a751a35660e073ea07014b3b8d8"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/cquery";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"query/orderPending",
"body":{
"page":1,
"size":20,
"pair":""
}
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":{
"count":3,
"page":1,
"items":[
{
"id":491168, // 订单号
"coin_symbol":"USDT",
"pair":"4ETH_USDT", // 合约符号
"order_side":1, // 挂单方向:1开多,2开空
"order_type":2,
"contract":3, // 委托合约张数
"order_from":1,
"status":1, // 0,1未成交 2部分成交 3完全成交 4部分取消 5完全取消 6,7 系统取消, >=100 下单失败
"price":"136.0000", // 委托价格
"price_deal":"0.0000", // 成交均价
"deal_count":0,
"contract_deal":0, // 已成交合约张数
"createdAt":"2019-02-20T02:01:46.000Z",
"updatedAt":"2019-02-20T02:01:46.000Z"
},
{
"id":489453,
"coin_symbol":"USDT",
"pair":"4BTC_USDT",
"order_side":1,
"order_type":2,
"contract":2,
"order_from":1,
"status":1,
"price":"3850.0000",
"price_deal":"0.0000",
"deal_count":0,
"contract_deal":0,
"createdAt":"2019-02-20T01:51:41.000Z",
"updatedAt":"2019-02-20T01:51:42.000Z"
}
]
},
"cmd":"query/orderPending"
}
]
}
合约下单
- POST https://api.bibox.com/v1/ctrade
- cmd: order/open
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
order_type | true | integer | 订单类型 | 1:市价,2:限价 | |
leverage | true | integer | 杠杆倍数 | 全仓:0,逐仓:1,2,... | |
cross_leverage | false | integer | 全仓杠杆 | 25 | leverage=0时且全仓:1,2,...50 |
order_side | true | integer | 挂单方向 | 1:开多,2:开空 | |
price | true | string | 委托价格 | 大于0的数 | |
contract | true | string | 合约张数 | 1,2, ... | |
pair | true | string | 合约符号 | 4BTC_USDT,4ETH_USDT, ... | |
order_from | true | integer | 6 | 6 | |
client_oid | false | Long | 自定义标识 | > 0 |
- 示例
请求参数
// Request
{
"cmd":"order/open",
"body":{
"pair":"4BTC_USDT",
"order_type":2,
"price":"3929.97",
"contract":"1",
"order_from":1,
"leverage":50,
"cross_leverage":25,
"order_side":1,
"client_oid": '123456789',
}
}
{
"url":"https://api.bibox.com/v1/ctrade",
"form":{
"cmds":"[{\"cmd\":\"order/open\",\"body\":{\"pair\":\"4BTC_USDT\",\"order_type\":2,\"price\":\"3929.97\",\"contract\":\"1\",\"order_from\":1,\"leverage\":50,\"cross_leverage\":25,\"order_side\":1,\"client_oid\":\"123456789\"}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"d298bb71db50f31c9fc923595e942fcd"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/cquery";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"order/open",
"body":{
"pair":"4BTC_USDT",
"order_type":2,
"price":"3929.97",
"contract":"1",
"order_from":1,
"leverage":50,
"cross_leverage":25,
"order_side":1,
"client_oid": '123456789',
}
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
result: '17592186044786', // 订单号
client_oid: '123456789', // 自定义标识
cmd: 'order/open',
}
]
}
合约批量下单
- POST https://api.bibox.com/v1/ctrade
- cmd: order/openBatch
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
leverage | true | integer | 杠杆倍数 | 全仓:0,逐仓:1,2,... | |
cross_leverage | false | integer | 全仓杠杆 | 25 | leverage=0时全仓1,2,...50 |
order_side | true | integer | 挂单方向 | 1:开多,2:开空 | |
price | true | string | 委托价格 | 大于0的数 | |
contract | true | string | 合约张数 | 1,2, ... | |
pair | true | string | 合约符号 | 4BTC_USDT,4ETH_USDT, ... | |
client_oid | false | Long | 自定义标识 | > 0 |
- 示例
请求参数
// Request
{
"cmd":"order/openBatch",
"body":{
"pair":"4ETH_USDT",
"leverage":50,
"cross_leverage": 25,
"arr":[
{
"order_side":1,
"price":140,
"contract":1,
"client_oid": '123456787'
},
{
"order_side":1,
"price":140.5,
"contract":1,
"client_oid": '123456788'
}
]
}
}
{
"url":"https://api.bibox.com/v1/ctrade",
"form":{
"cmds":"[{\"cmd\":\"order/openBatch\",\"body\":{\"pair\":\"4ETH_USDT\",\"leverage\":50,\"cross_leverage\":25,\"arr\":[{\"order_side\":1,\"price\":140,\"contract\":1,\"client_oid\":\"123456787\"},{\"order_side\":1,\"price\":140.5,\"contract\":1,\"client_oid\":\"123456788\"}]}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"cb3eee178b4f6442026d324760f9b9cd"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/ctrade";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"order/openBatch",
"body":{
"pair":"4ETH_USDT",
"leverage":50,
"cross_leverage": 25,
"arr":[
{
"order_side":1,
"price":140,
"contract":1,
"client_oid": '123456787'
},
{
"order_side":1,
"price":140.5,
"contract":1,
"client_oid": '123456788'
}
]
}
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":[
{
code: 0, // 0代表成功;非0代表失败,code是错误码
id: '17592186044787', // 挂单id号
msg: '',
client_oid: '123456787'
},
{
code: 0,
id: '17592186044790',
msg: '',
client_oid: '123456788'
}
],
"cmd":"order/openBatch"
}
]
}
合约撤单
- POST https://api.bibox.com/v1/ctrade
- cmd: order/close
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
order_id | true | string | 订单号 |
- 示例
请求参数
// Request
{
"cmd":"order/close",
"body":{
"order_id":"574954"
}
}
{
"url":"https://api.bibox.com/v1/ctrade",
"form":{
"cmds":"[{\"cmd\":\"order/close\",\"body\":{\"order_id\":\"574954\"}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"9a9286632189e3c2d6581cb81e38349b"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/ctrade";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"order/close",
"body":{
"order_id":"574954"
}
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":"success",
"cmd":"order/close"
}
]
}
合约撤多单
- POST https://api.bibox.com/v1/ctrade
- cmd: order/closeBatch
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
order_ids | true | string | 订单号数组 |
- 示例
请求参数
// Request
{
"cmd":"order/closeBatch",
"body":{
"order_ids":[
"574953",
"574954"
]
},
"index":13
}
{
"url":"https://api.bibox.com/v1/ctrade",
"form":{
"cmds":"[{\"cmd\":\"order/closeBatch\",\"body\":{\"order_ids\":[\"574953\",\"574954\"]},\"index\":13}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"64449ef8dc5016a6230ce4a8f0f18eb1"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/ctrade";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"order/closeBatch",
"body":{
"order_ids":[
"574953",
"574954"
]
},
"index":13
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":"success",
"cmd":"order/closeBatch",
"index":13
}
]
}
合约撤1000单
- POST https://api.bibox.com/v1/ctrade
cmd: order/closeAll
示例
请求参数
// Request
{
"cmd":"order/closeAll",
"body":{
},
"index":13
}
{
"url":"https://api.bibox.com/v1/ctrade",
"form":{
"cmds":"[{\"cmd\":\"order/closeAll\",\"body\":{},\"index\":13}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"d0ab49a6de0aa0254baa8445582b42c2"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/ctrade";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"order/closeAll",
"body":{
},
"index":13
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":"success",
"cmd":"order/closeAll",
"index":13
}
]
}
通过client_oid撤单
- POST https://api.bibox.com/v1/ctrade
- cmd: order/closeBatchClientOid
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
clientIds | true | string array | 用户client_oid单号 | 最大长度限制50单 |
- 示例
请求参数
// Request
{
"cmd":"order/closeBatchClientOid",
"body":{
"clientIds":[
"1588819328619"
]
},
"index":13
}
{
"url":"https://api.bibox.com/v1/ctrade",
"form":{
"cmds":"[{\"cmd\":\"order/closeBatchClientOid\",\"body\":{\"clientIds\":[\"1588819328619\"]},\"index\":13}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"3172e38a62698ffc4f73223c6a0b22d3"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/ctrade";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"order/closeBatchClientOid",
"body":{
"clientIds":[
"1588819328619"
]
},
"index":13
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":"success",
"cmd":"order/closeBatchClientOid"
}
]
}
合约调整杠杆倍数
- POST https://api.bibox.com/v1/ctrade
- cmd: order/changeLeverage
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 合约符号 | 4BTC_USDT,4ETH_USDT, ... | |
leverage | true | integer | 杠杆倍数 | 全仓:0,逐仓:1,2,... | |
cross | true | integer | 是否全仓 | 0逐仓,1全仓 |
- 示例
请求参数
// Request
{
"cmd":"order/changeLeverage",
"body":{
"pair":"4BTC_USDT",
"leverage":40,
"cross": 0
},
"index":13
}
{
"url":"https://api.bibox.com/v1/ctrade",
"form":{
"cmds":"[{\"cmd\":\"order/changeLeverage\",\"body\":{\"pair\":\"4BTC_USDT\",\"leverage\":40,\"cross\":0},\"index\":13}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"1abd620b3cc04be7e181309d5c83670e"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/ctrade";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"order/changeLeverage",
"body":{
"pair":"4BTC_USDT",
"leverage":40,
"cross": 0
},
"index":13
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":"success",
"cmd":"order/changeLeverage",
"index":13
}
]
}
合约调整保证金
- POST https://api.bibox.com/v1/ctrade
- cmd: order/changeMargin
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 合约符号 | 4BTC_USDT,4ETH_USDT, ... | |
margin | true | integer | 增减保证金 | 增加margin>=0.5;减少margin<=-0.5 |
- 示例
请求参数
// Request
{
"cmd":"order/changeMargin",
"body":{
"pair": "4ETH_USDT",
"margin": 4
},
"index":13
}
{
"url":"https://api.bibox.com/v1/ctrade",
"form":{
"cmds":"[{\"cmd\":\"order/changeMargin\",\"body\":{\"pair\":\"4ETH_USDT\",\"margin\":4},\"index\":13}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"f6ef54d12ccadaef85782a7a238413f6"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/ctrade";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"order/changeMargin",
"body":{
"pair": "4ETH_USDT",
"margin": 4
},
"index":13
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":"success",
"cmd":"order/changeMargin",
"index":13
}
]
}
主账户资金转入合约账户
- POST https://api.bibox.com/v1/ctrade
- cmd: transfer/in
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
amount | true | integer | 金额 |
- 示例
请求参数
// Request
{
"cmd":"transfer/in",
"body":{
"amount":"100"
}
}
{
"url":"https://api.bibox.com/v1/ctrade",
"form":{
"cmds":"[{\"cmd\":\"transfer/in\",\"body\":{\"amount\":\"100\"}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"16c40525ae36ae0f55fe5237c91336cd"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/ctrade";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"transfer/in",
"body":{
"amount":"100"
}
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":"success",
"cmd":"transfer/in"
}
]
}
查询市场成交记录
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | String | 合约符号 | 4BTC_USDT,4ETH_USDT,... | |
size | true | integer | 返回数量 | 1,2,... |
- 返回结果说明
{ "result":{ "result":[ { "pair":"4ETH_USDT", // 合约符号 "order_side":1, // 1看涨 2 看空 "contract":75, // 张数 "price":"182.7500", // 价格 "createdAt":1565861520000 // 时间 }, ... ], "cmd":"deals" } }
通过订单号查询订单
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderPendingByIDs
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
ids | true | string array | 订单号 | 最大长度限制50单 |
- 示例
请求参数
// Request
{
"cmd":"query/orderPendingByIDs",
"body":{
"ids":[
"491168",
"2"
]
},
"index":13
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/orderPendingByIDs\",\"body\":{\"ids\":[\"491168\",\"2\"]},\"index\":13}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"3172e38a62698ffc4f73223c6a0b22d3"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/cquery";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"query/orderPendingByIDs",
"body":{
"ids":[
"491168",
"2"
]
},
"index":13
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":[
{
"id":491168, // 订单号
"coin_symbol":"USDT",
"pair":"4ETH_USDT", // 合约符号
"order_side":1, // 挂单方向:1开多,2开空
"order_type":2,
"contract":3, // 委托合约张数
"order_from":1,
"status":1, // 0,1未成交 2部分成交 3完全成交 4部分取消 5完全取消 6,7 系统取消, >=100 下单失败
"price":"136.0000", // 委托价格
"price_deal":"0.0000", // 成交均价
"deal_count":0,
"contract_deal":0, // 已成交合约张数
"createdAt":"2019-02-20T02:01:46.000Z",
"updatedAt":"2019-02-20T02:01:46.000Z"
},
{
"id":2,
"coin_symbol":"USDT",
"pair":"4BTC_USDT",
"order_side":1,
"order_type":2,
"contract":1,
"order_from":1,
"status":3,
"price":"3622.0000",
"price_deal":"3622.0000",
"deal_count":1,
"contract_deal":1,
"createdAt":"2019-02-15T13:10:27.000Z",
"updatedAt":"2019-02-15T13:10:45.000Z"
}
],
"cmd":"query/orderPendingByIDs",
"index":13
}
]
}
通过client_oid查询未成交订单
- POST https://api.bibox.com/v1/cquery
- cmd: query/ordersDetailByClientIds
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
clientIds | true | string array | 用户client_oid单号 | 最大长度限制50单 |
- 示例
请求参数
// Request
{
"cmd":"query/ordersDetailByClientIds",
"body":{
"clientIds":[
"1588819328619"
]
},
"index":13
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/ordersDetailByClientIds\",\"body\":{\"clientIds\":[\"1588819328619\"]},\"index\":13}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"3172e38a62698ffc4f73223c6a0b22d3"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/cquery";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"query/ordersDetailByClientIds",
"body":{
"clientIds":[
"1588819328619"
]
},
"index":13
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":[
{
"id": "71468256443234",
"user_id": 101051,
"client_oid": "1588819328619",
"pair": "4BTC_USDT",
"coin_symbol": "4BTC",
"price": "9486.0000",
"price_deal": "9485.9900",
"contract": "15",
"contract_deal": "4",
"deal_count": "1",
"order_side": 1,
"order_type": 2,
"order_from": 6,
"status": 2,
"reason": 0,
"createdAt": 1588819336186,
"updatedAt": 1588819336186
},
],
"cmd":"query/ordersDetailByClientIds",
"index":13
}
]
}
通过client_oid查询委托单
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderPendingByClientIds
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
clientIds | true | string array | 用户client_oid单号 | 最大长度限制50单 |
- 示例
请求参数
// Request
{
"cmd":"query/orderPendingByClientIds",
"body":{
"clientIds":[
"1588819328619"
]
},
"index":13
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/orderPendingByClientIds\",\"body\":{\"clientIds\":[\"1588819328619\"]},\"index\":13}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"3172e38a62698ffc4f73223c6a0b22d3"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/cquery";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"query/orderPendingByClientIds",
"body":{
"clientIds":[
"1588819328619"
]
},
"index":13
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":[
{
"id": 71468256443234,
"client_oid": "1588819328619",
"coin_symbol": "USDT",
"pair": "4BTC_USDT",
"order_side": 1,
"order_type": 2,
"contract": 15,
"order_from": 6,
"status": 3,
"price": "9486.0000",
"price_deal": "9485.9973",
"deal_count": 2,
"contract_deal": 15,
"createdAt": "2020-05-07T02:42:16.000Z",
"updatedAt": "2020-05-07T03:02:24.000Z"
}
],
"cmd":"query/orderPendingByClientIds",
"index":13
}
]
}
查询个人仓位变化记录
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderList
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | String | 合约符号 | 4BTC_USDT,4ETH_USDT,... | |
page | true | integer | 第几页 | 1,2,... | |
size | true | integer | 多少条 | 1,2,... | |
begin_time | false | integer | 开始时间 | ||
end_time | false | integer | 结束时间 | ||
type | false | integer | 成交类型 | 1开仓, 2平仓, 3爆仓, 4减仓 |
- 示例
请求参数
// Request
{
"cmd":"query/orderList",
"body":{
"pair":"4BTC_USDT",
"page":1,
"size":100,
"begin_time":1550971541000,
"end_time":1550977541000,
type: 2,
}
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/orderList\",\"body\":{\"pair\":\"4BTC_USDT\",\"page\":1,\"size\":100,\"begin_time\":1550971541000,\"end_time\":1550977541000,\"type\":2}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"2517280ee4d332c3b63d4ee34fa5bb06"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/cquery";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"query/orderList",
"body":{
"pair":"4BTC_USDT",
"page":1,
"size":100,
"begin_time":1550971541000,
"end_time":1550977541000,
type: 2,
}
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":{
"count":101,
"page":1,
"items":[
{
"id":236343,
"coin_symbol":"USDT",
"pair":"4BTC_USDT", // 合约符号
"type":2, // 1开仓, 2平仓, 3爆仓, 4减仓
"order_side":2, // 1开多,2开空
"price_open":"3999.0000", // 委托价格
"price":"3964.5800", // 开仓均价
"price_deal":"3999.0000", // 成交价格
"contract":2, // 合约张数
"profit":"0.6884", // 盈亏
"fee":"0.0000", // 手续费
"createdAt":"2019-02-23T17:07:31.000Z"
},
...
]
},
"cmd":"query/orderList"
}
]
}
查询订单详情
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderDetailByID
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
id | true | String | 订单号 |
- 示例
请求参数
// Request
{
"cmd":"query/orderDetailByID",
"body":{
"id":"58", // 订单号
}
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/orderDetailByID\",\"body\":{\"id\":\"58\"}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"2a5c0bdaea46ddf4efa809bd92e0181a"
}
}
示例代码
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v1/cquery";
let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret
let param = [
{
"cmd":"query/orderDetailByID",
"body":{
"id":"58", // 订单号
}
}
];
let form = {
"cmds": JSON.stringify(param), //格式化param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//签名cmds
form.sign = sign;
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":[
{
"result":{
"items":[
{
"id":42, // 成交记录ID
"coin_symbol":"USDT", //计价单位
"pair":"4BTC_USDT", // 合约符号
"order_side":1, // 1 买,看涨; 2 卖,看空;
"contract":1, // 合约张数
"order_from":1, // 1网页,2安卓,3ios, 6 apikey,
"createdAt":"2019-08-13T08:22:25.000Z", // 创建时间
"updatedAt":"2019-08-13T08:22:26.000Z",
"price":"7029.9700", // 价格
"price_deal":"0.0000", // 成交价
"fee":"0.0000", // 手续费
"is_cancel":1, // 0 正常单; 1: 已撤销
"is_maker":1, // 0: taker; 1: maker;
"order_type":2 // 1 市价单; 2 限价单
}
],
"count":9,
"page":1
},
"cmd":"query/orderDetailByID"
}
]
}
查询合约面值(不需要apikey)
{
"result":{
"result":[
{
"pair":"4BTC_USDT",
"value":"0.0100000000",
"coin_symbol":"BTC"
},
],
"cmd":"contractValue"
}
}
查询合约杠杆信息(不需要apikey)
{
"result":{
"result":{
"cross_leverage":25, // 全仓默认杠杆数
"leverage_max":50, // 最大杠杆数
"margin_rate_force":"0.01", // 爆仓率
"night_fee_rate":"0.0006", // 隔夜费
"hold_limit":{ // 最大持仓数量
"BTC":5000,
"ETH":150000,
"EOS":50000,
"LTC":35000,
"BCH":100000
}
},
"cmd":"contractConfig"
}
}
查询合约单笔下单限制(不需要apikey)
{
"result":{
"result":{
"BTC":5000,
"ETH":75000,
"EOS":75000,
"LTC":15000,
"BCH":15000
},
"cmd":"openLimit"
}
}
查询当期资金费率(不需要apikey)
{
"result":{
"result":{
"4BTC_USDT":{
"id":164391,
"pair":"4BTC_USDT",
"close":"0.0007000000",
"fund_rate_up":"0.0005000000",
"fund_rate_down":"-0.0005000000",
"createdAt":"2020-02-27T00:00:00.000Z",
"updatedAt":"2020-02-27T00:00:00.000Z"
},
...
},
"cmd":"lastPremiumIndex"
}
}