Restful API description for contract
View Kline
- 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
- Request parameter
Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
pair | true | string | pair | 4BTC_USDT, 4ETH_USDT, ... | |
period | true | string | Kline period | '1min', '3min', '5min', '15min', '30min', '1hour', '2hour', '4hour', '6hour', '12hour', 'day', 'week' | |
size | false | integer | how many | 1000 | 1-1000 |
- example
// 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, // Timestamp
"open":"7196.33000000", // Opening Price
"high":"7196.33000000", // The highest price
"low":"7188.90000000", // The lowest price
"close":"7188.90000000", // Closing Price
"vol":"337.00000000" // Trading Volume
},
{
"time":1575450240000,
"open":"7188.88000000",
"high":"7188.96000000",
"low":"7185.67000000",
"close":"7187.18000000",
"vol":"844.00000000"
},
],
"cmd":"api/kline"
}
View the contract depth of the market
- GET https://api.bibox.com/v1/mdata?cmd=depth&pair=4BTC_USDT&size=10
- POST https://api.bibox.com/v1/mdata
- cmd: api/depth
- Request parameter
Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
pair | true | string | pair | 4BTC_USDT, 4ETH_USDT, ... | |
size | false | integer | c | 200 | 1-200 |
- example
// 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":[ //The depth of sellers
{
"price":"0.008654", //The price of pending order
"volume":"200.9123" //The price of pending orders
}
],
"bids":[ //The depth of buyers
{
"price":"0.008596", //The price of pending order
"volume":"18.54306495" //The price of pending orders
},
{
"price":"0.00859289",
"volume":"40.13567123"
}
]
},
"cmd":"api/depth"
}
contract account information
cmd:query/assets
example
Request parameter
// Request
[
{
"cmd":"query/assets",
"body":{}
}
]
{
"url":"https://api.bibox365.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/assets\",\"body\":{}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"85190bfcb83357b9fa5aa2e79f0d7826"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":{
"balance":"97.2378", // available balance
"freeze":"1.7326", // frozen amount
"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"
}
]
}
check single information of contract position
cmd: query/order
Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
pair | true | string | contract symbol | 4BTC_USDT,4ETH_USDT, ... |
- example
Request parameter
// Request
{
"cmd":"query/order",
"body":{
"pair":"4BTC_USDT" // contract symbol:BTCUSDT Perpetual Contract symbol is 4BTC_USDT,ETHUSDT Perpetual Contract symbol is 4ETH_USDT 。。。
}
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/order\",\"body\":{\"pair\":\"4BTC_USDT\"}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"e533359a43984510ef4dbcb0941bac6b"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":{
"coin_symbol":"USDT",
"pair":"4BTC_USDT", // contract symbol
"contract":2, // position size
"margin":"1.5612", // margin
"profit":"-2.4995",
"price":"3903.0450", // average price of opening position
"order_side":2, // side: 1long, 2short
"price_force":"3961.5907", // forced liquidation price
"floatProfit":"-0.1376",
"leverage":50, // 0:cross-margin, others: fixed leverage
"icontract_up":2, // uncompleted orders in long position
"icontract_down":0 // uncompleted orders in short position
},
"cmd":"query/order"
}
]
}
Check all information of contract position
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderAll
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
pair | true | string | Contract symbol | 4BTC_USDT,4ETH_USDT, ... |
- example
Request parameter
// Request
{
"cmd":"query/orderAll",
"body":{
}
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/orderAll\",\"body\":{}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"1a9be520fb658c677b86f99769634e5b"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":[
{
"coin_symbol":"USDT",
"pair":"4BTC_USDT", // Contract symbol
"contract":2, // position size
"margin":"1.5612", // margin
"profit":"-2.4995",
"price":"3903.0450", // average price of opening position
"order_side":2, // position side: 1long, 2short
"price_force":"3961.5907", // forced liquidation price
"floatProfit":"-0.1376",
"leverage":50, // 0:cross-margin, others: fixed leverage
"icontract_up":2, // uncompleted Cont of limit order in long position
"icontract_down":0 // uncompleted Cont of limit order in short position
},
{
"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"
}
]
}
Check uncompleted contract orders
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderPending
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
page | true | integer | page | 1,2, ... | |
size | true | integer | number | 10,20, ... | |
pair | false | string | Contract symbol | 4BTC_USDT,4ETH_USDT, ... |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":{
"count":3,
"page":1,
"items":[
{
"id":491168, // order number
"coin_symbol":"USDT",
"pair":"4ETH_USDT", // contract symbol
"order_side":1, // position side: 1long, 2short
"order_type":2,
"contract":3, // number of orders
"order_from":1,
"status":1, // 0,1:uncompleted; 2:partly completed; 3:completed; 4: partly cancel; 5 cancel completed; 6,7 system cancel; >=100 order fail
"price":"136.0000", // order price
"price_deal":"0.0000", // average transaction price
"deal_count":0,
"contract_deal":0, // number of completed orders
"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"
}
]
}
make contract order
- POST https://api.bibox.com/v1/ctrade
- cmd: order/open
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
order_type | true | integer | order type | 1:market price 2:limited price | |
leverage | true | integer | leverage | cross margin:0, fixed margin:1,2,... | |
cross_leverage | false | integer | cross leverage | 25 | when leverage=0 and cross_leverage=1,2,...50 |
order_side | true | integer | position side | 1:long, 2:short | |
price | true | string | order price | The numbers greater than 0 | |
contract | true | string | Cont | 1,2, ... | |
pair | true | string | contract symbol | 4BTC_USDT,4ETH_USDT, ... | |
order_from | true | integer | 6 | 6 | |
client_oid | false | Long | client order id | > 0 |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
result: '17592186044786', // order id
client_oid: '123456789', // client order id
cmd: 'order/open',
}
]
}
make bulk contract orders
- POST https://api.bibox.com/v1/ctrade
- cmd: order/openBatch
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
leverage | true | integer | leverage | cross margin:0, fixed margin:1,2,... | |
cross_leverage | false | integer | cross leverage | 25 | when leverage=0 and cross_leverage=1,2,...50 |
order_side | true | integer | position side | 1:long, 2:short | |
price | true | string | order price | The numbers greater than 0 | |
contract | true | string | Cont | 1,2, ... | |
pair | true | string | Contract symbol | 4BTC_USDT,4ETH_USDT, ... | |
client_oid | false | Long | client order id | > 0 |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":[
{
code: 0, // 0 means success;non-zero means failure, code is error code
id: '17592186044787', // order id
msg: '',
client_oid: '123456787'
},
{
code: 0,
id: '17592186044790',
msg: '',
client_oid: '123456788'
}
],
"cmd":"order/openBatch"
}
]
}
cancel contract order
- POST https://api.bibox.com/v1/ctrade
- cmd: order/close
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
order_id | true | string | order id |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":"success",
"cmd":"order/close"
}
]
}
cancel multiple orders
- POST https://api.bibox.com/v1/ctrade
- cmd: order/closeBatch
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
order_ids | true | string | order id array |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":"success",
"cmd":"order/closeBatch",
"index":13
}
]
}
cancel 1000 orders
- POST https://api.bibox.com/v1/ctrade
cmd: order/closeAll
example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":"success",
"cmd":"order/closeAll",
"index":13
}
]
}
cancel multiple orders through client order id
- POST https://api.bibox.com/v1/ctrade
- cmd: order/closeBatchClientOid
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
clientIds | true | string array | client oid | limit 50 |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":"success",
"cmd":"order/closeBatchClientOid"
}
]
}
adjust contract leverage
- POST https://api.bibox.com/v1/ctrade
- cmd: order/changeLeverage
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
pair | true | string | Contract symbol | 4BTC_USDT,4ETH_USDT, ... | |
leverage | true | integer | leverage | cross margin:0, fixed margin:1,2,... | |
cross | true | integer | cross flag | cross: 1, fixed: 0 |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":"success",
"cmd":"order/changeLeverage",
"index":13
}
]
}
adjust contract margin
- POST https://api.bibox.com/v1/ctrade
- cmd: order/changeMargin
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
pair | true | string | Contract symbol | 4BTC_USDT,4ETH_USDT, ... | |
margin | true | integer | increase or reduce margin | increase: margin>=0.5; reduce: margin <=-0.5 |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":"success",
"cmd":"order/changeMargin",
"index":13
}
]
}
transfer funds from master account to contract account
- POST https://api.bibox.com/v1/ctrade
- cmd: transfer/in
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
amount | true | integer | amount |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":"success",
"cmd":"transfer/in"
}
]
}
check transaction records in the market
GET https://api.bibox.com/v1/cquery?cmd=deals&&pair=4ETH_USDT&&size=10
Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
pair | true | String | Contract symbol | 4BTC_USDT,4ETH_USDT,... | |
size | true | integer | number | 1,2,... |
- The description of return result
{
"result":{
"result":[
{
"pair":"4BTC_USDT", // contract symbol
"order_side":1, // 1long, 2short
"contract":52, // number of orders
"price":"3601.1600", // transaction price
"createdAt":1550977541000 // transaction time
},
...
],
"cmd":"deals"
}
}
check orders through order id
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderPendingByIDs
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
ids | true | string array | order id | limit 50 |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":[
{
"id":491168, // order id
"coin_symbol":"USDT",
"pair":"4ETH_USDT", // Contract symbol
"order_side":1, // 1long, 2short
"order_type":2,
"contract":3, // contract
"order_from":1,
"status":1, // 0,1:uncompleted; 2:partly completed; 3:completed; 4: partly cancel; 5 cancel completed; 6,7 system cancel; >=100 order fail
"price":"136.0000", // order price
"price_deal":"0.0000", // average transaction price
"deal_count":0,
"contract_deal":0, // number of completed orders
"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
}
]
}
check uncompleted orders through client order id
- POST https://api.bibox.com/v1/cquery
- cmd: query/ordersDetailByClientIds
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
clientIds | true | string array | client_oid | limit 50 |
示例
- cmd: query/ordersDetailByClientIds
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
clientIds | true | string array | client oid | limit 50 |
- example
Request parameter
// 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"
}
}
example code
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
// 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
}
]
}
check orders through client order id
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderPendingByClientIds
- 请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
clientIds | true | string array | client_oid | limit 50 |
示例
- cmd: query/orderPendingByClientIds
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
clientIds | true | string array | client oid | limit 50 |
- example
Request parameter
// 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"
}
}
example code
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
// 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
}
]
}
check personal position changed record
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderList
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
pair | true | String | contract symbol | 1,2,... | |
page | true | integer | page | 1,2,... | |
size | true | integer | number | 1,2,... | |
begin_time | false | integer | starting time | ||
end_time | false | integer | ending time | ||
type | false | integer | transaction type | 1open position, 2liquidation, 3forced liquidation, 4cover position |
- example
Request parameter
// 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"
}
}
example code
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), //format param
"apikey": apikey,
"sign": ""
};
let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign 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
// Response
{
"result":[
{
"result":{
"count":101,
"page":1,
"items":[
{
"id":236343,
"coin_symbol":"USDT",
"pair":"4BTC_USDT", // contract symbol
"type":2, // 1open position, 2liquidation, 3forced liquidation, 4cover position
"order_side":2, // 1long, 2short
"price_open":"3999.0000", // order pirce
"price":"3964.5800", // average price of opening position
"price_deal":"3999.0000", // transaction price
"contract":2, // number of Cont
"profit":"0.6884", // profits and losses
"fee":"0.0000", // transaction fee
"createdAt":"2019-02-23T17:07:31.000Z"
},
...
]
},
"cmd":"query/orderList"
}
]
}
query order detail
- POST https://api.bibox.com/v1/cquery
- cmd: query/orderDetailByID
- Request parameter
Parameter Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
id | true | String | order id |
- example
Request parameter
// Request
{
"cmd":"query/orderDetailByID",
"body":{
"id":"58", // order id
}
}
{
"url":"https://api.bibox.com/v1/cquery",
"form":{
"cmds":"[{\"cmd\":\"query/orderDetailByID\",\"body\":{\"id\":\"58\"}}]",
"apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
"sign":"2a5c0bdaea46ddf4efa809bd92e0181a"
}
}
example code
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", // order id
}
}
];
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({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
// Response
{
"result":[
{
"result":{
"items":[
{
"id":42, // order detail id
"coin_symbol":"USDT", //
"pair":"4BTC_USDT", // Contract symbol
"order_side":1, // 1 long, 2short
"contract":1, // contract
"order_from":1, // 1web,2android,3ios, 6 apikey,
"createdAt":"2019-08-13T08:22:25.000Z", // create time
"updatedAt":"2019-08-13T08:22:26.000Z",
"price":"7029.9700", // price
"price_deal":"0.0000", // deal price
"fee":"0.0000", // fee
"is_cancel":1, // 0 normal 1: canceld order
"is_maker":1, // 0: taker; 1: maker;
"order_type":2 // 1:market price 2:limited price
}
],
"count":9,
"page":1
},
"cmd":"query/orderDetailByID"
}
]
}
query contract value (apikey not required)
- GET https://api.bibox.com/v1/cquery?cmd=contractValue
- The description of return result
{
"result":{
"result":[
{
"pair":"4BTC_USDT",
"value":"0.0100000000",
"coin_symbol":"BTC"
},
],
"cmd":"contractValue"
}
}
query contract leverage info (apikey not required)
- GET https://api.bibox.com/v1/cquery?cmd=contractConfig
- The description of return result
{
"result":{
"result":{
"cross_leverage":25, // cross leverage
"leverage_max":50, // max leverage
"margin_rate_force":"0.01", // margin rate force
"night_fee_rate":"0.0006", // night fee rate
"hold_limit":{ // hold limit amount
"BTC":5000,
"ETH":150000,
"EOS":50000,
"LTC":35000,
"BCH":100000
}
},
"cmd":"contractConfig"
}
}
query contract open limit once (apikey not required)
- GET https://api.bibox.com/v1/cquery?cmd=openLimit
- The description of return result
{
"result":{
"result":{
"BTC":5000,
"ETH":75000,
"EOS":75000,
"LTC":15000,
"BCH":15000
},
"cmd":"openLimit"
}
}
query current funding rate (apikey not required)
- GET https://api.bibox.com/v1/cquery?cmd=lastPremiumIndex
- The description of return result
{
"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"
}
}