Restful API Coin-based contract V1.1
Description
- v1.1 streamlines the returned results of v1. Requirements: The cmds in the parameter contains only one cmd.
Query position change records
cmd:bc/dealLog
Request parameter
Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
pair | true | string | pair | 5BTC_USD,5ETH_USD, ... | |
page | true | integer | page number | 1,2, ... | |
size | true | integer | how many | 10,20, ... |
- example
Request parameter
// 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"
}
}
example code
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
// Response
{
"result":{
"count":3,
"page":1,
"items":[
{
"id":"1125899906842635654", // Position change id
"user_id":100006, // user id
"coin_symbol":"BTC",// coin symbol
"pair":"5BTC_USD",// pair
"side":1,// position side, 1long,2short
"model":1,// position model,1cross,2fixed
"log_type":1,// change type 1 open a position, 2 close a position, 3 lighten a position to reduce the risk level, 4 liquidate a position, 5ADL
"hold_coin_dx":"1.0000000000",// position change amount
"hold_coin":"1.0000000000",// Position holding
"price_log":"11692.0000000000",// proposed price
"price_open":"11692.0000000000",// open price
"profit":"0.0000000000",// profit
"fee":"0.0000000599",// fee
"fee_bix":"0.0000000000",// bix Deduction
"fee_bix0":"0.0000000000", // Coupon deduction
"createdAt":"2020-10-14T03:00:08.000Z",// time
"updatedAt":"2020-10-14T03:00:08.000Z"
},
...
]
},
"cmd":"bc/dealLog",
"index":1
}
Query order transaction details
cmd:bc/orderDetail
Request parameter
Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
orderId | true | long | order id | ||
page | true | integer | page number | 1,2, ... | |
size | true | integer | how many | 10,20, ... |
- example
Request parameter
// 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"
}
}
example code
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
// Response
{
"result":{
"count":1,
"page":1,
"items":[
{
"id":"1125899906842635651",// details id
"coin_symbol":"BTC",// coin symbol
"pair":"5BTC_USD",// pair
"side":2,// order side 1open long,2open short,3close long,4close short
"order_from":4,// order from
"price":"10692.0000000000",// target price
"deal_price":"11510.0000000000",// deal price
"deal_coin":"1.0000000000",// deal amount
"fee":"0.0000000608",// fee
"fee_bix":"0.0000000000",// bix deduction
"fee_bix0":"0.0000000000",// Coupon deduction
"is_maker":0,// is maker
"createdAt":"2020-10-14T02:58:59.000Z"// time
}
]
},
"cmd":"bc/orderDetail",
"index":1
}
Query historical orders
cmd:bc/orderHistory
Request parameter
Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
pair | false | string | pair | 5BTC_USD,5ETH_USD, ... | |
page | true | integer | page number | 1,2, ... | |
size | true | integer | how many | 10,20, ... | |
side | false | integer | order side 1open long,2open short,3close long,4close short | ||
status | false | array | status,3: Full transaction, 4: Partial order cancellation, 5: Full order cancellation, 100: Order failed |
- example
Request parameter
// 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"
}
}
example code
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
// Response
{
"result":{
"count":1,
"page":1,
"items":[
{
"id":421112953438215,// order id
"user_id":100006,// user id
"coin_symbol":"BTC",// coin symbol
"pair":"5BTC_USD",// pair
"side":1,// order side
"order_type":2,// order type 1market order,2limit order
"price":"11692.0000000000",// target price
"amount_coin":"1.0000000000",// Number of pending orders
"freeze":"0.0000000000",// Frozen funds
"price_deal":"11692.0000000000",// Average transaction price
"deal_coin":"1.0000000000",// deal amount
"deal_num":1,// deal number
"fee":"0.0000000599",// fee
"fee_bix":"0.0000000000",// bix deduction
"fee_bix0":"0.0000000000",// Coupon deduction
"status":3,// order status,1 uncompleted, 2 partially completed, 3 completely completed, 4 partially cancelled, 5 completely cancelled, 100 failed to place an order
"reason":0,// failed reason
"fee_rate_maker":"0.0007000000",// maker fee rate
"fee_rate_taker":"0.0007000000",// taker fee rate
"client_oid":1602644402806,// client order id
"order_from":4, // ignore
"createdAt":"2020-10-14T03:00:08.000Z",// created time
"updatedAt":"2020-10-14T03:00:08.000Z"// updated time
}
]
},
"cmd":"bc/orderHistory",
"index":1
}
checking order
cmd:bc/orderById
Request parameter
Name | Necessary or not | Type | Description | Default | Value Range |
---|---|---|---|---|---|
orderIds | true | array | array of order id | ||
clientOids | true | array | array of client order id |
- example
Request parameter
// 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"
}
}
example code
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
// Response
{
"result":[
{
"id":421112953438214,// order id
"user_id":100006,// user id
"coin_symbol":"BTC",// coin symbol
"pair":"5BTC_USD",// pair
"side":1,// order side 1open long,2open short,3close long,4close short
"order_type":2,// order type 1market order,2limit order
"price":"11692.0000000000",// target price
"amount_coin":"1.0000000000",// Number of pending orders
"freeze":"0.0000000000",// Frozen funds
"price_deal":"11692.0000000000",// Average transaction price
"deal_coin":"1.0000000000",// deal amount
"deal_num":1,// deal number
"fee":"0.0000000599",// fee
"fee_bix":"0.0000000000",// bix deduction
"fee_bix0":"0.0000000000",// Coupon deduction
"status":3,// order status,1 uncompleted, 2 partially completed, 3 completely completed, 4 partially cancelled, 5 completely cancelled, 100 failed to place an order
"reason":0,// failed reason
"fee_rate_maker":"0.0007000000",// maker fee rate
"fee_rate_taker":"0.0007000000",// taker fee rate
"client_oid":1602644402806,// client order id
"order_from":4, // ignore
"createdAt":"2020-10-14T03:00:08.000Z",// created time
"updatedAt":"2020-10-14T03:00:08.000Z"// updated time
},
...
],
"cmd":"bc/orderById",
"index":1
}
Query funding rate
- GET https://api.bibox.com/v1.1/cquery?cmd=bcFundRate
- Response
{
"result":{
"5BTC_USD":{
"pair":"5BTC_USD", // pair
"close":"0.0000000000", // ignore
"fund_rate":"0.0001000000", // funding rate
"createdAt":"2020-10-14T00:00:00.000Z" // time
},
"5ETH_USD":{
"pair":"5ETH_USD",
"close":"0.0000000000",
"fund_rate":"0.0001000000",
"createdAt":"2020-10-14T00:00:00.000Z"
}
},
"cmd":"bcFundRate"
}
Query mark price
- GET https://api.bibox.com/v1.1/cquery?cmd=bcTagPrice
- Response
{
"result":{
"5BTC_USD":{//pair
"close":"11453.7224909000",// index price
"priceTag":"11454.2951770245",// mark price
"createdAt":"2020-10-14T03:41:08.000Z" // time
},
"5ETH_USD":{
"close":"383.1999999600",
"priceTag":"383.2191599600",
"createdAt":"2020-10-14T03:41:08.000Z"
}
},
"cmd":"bcTagPrice"
}
Query basic contract information
- GET https://api.bibox.com/v1.1/cquery?cmd=bcValue
- Response
{
"result":[
{
"id":465, // ignore
"pair":"5BTC_USD",//pair
"coin_symbol":"BTC", // ignore
"leverage_init":"10.0000000000", // ignore
"leverage_min":"0.0100000000",//Minimum leverage
"leverage_max":"100.0000000000",//Maximum leverage
"value":"1.0000000000",//Contract value
"risk_level_base":"1000000.0000000000",//ignore
"risk_level_dx":"50000.0000000000",//ignore
"maker_fee":"0.0006000000",//Default maker fee rate
"taker_fee":"0.0006000000",//Default taker fee rate
"open_max_per":"10000000.0000000000",//Maximum number of single pending orders
"pending_max":100,//Maximum number of pending order
"hold_max":"100000000.0000000000",//Maximum position value
"price_precision":1 // ignore
},
{
"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"
}
Query accuracy configuration
- GET https://api.bibox.com/v1.1/cquery?cmd=bcUnit
- Response
{
"result":[
{
"pair":"5BTC_USD",//pair
"price_unit":1,//Decimal points for order
"vol_unit":6, // ignore
"value_unit":0 // ignore
},
{
"pair":"5ETH_USD",
"price_unit":1,
"vol_unit":6,
"value_unit":0
}
],
"cmd":"bcUnit"
}