English
javascript

Base-USDT contract

SDK and Demo

Bibox provides contract SDKs for developers in multiple languages.

These SDKs are developed based on the Bibox contract API and automatically complete the following functions:

It's more convenient to use SDK to develop programs to access Bibox than to use API.

If you need to download or read more information, please click the following link:

1.Signature interface request method

Example

let CryptoJS = require("crypto-js");
let request = require("request");

let timestamp = Date.now(); // 1.Current timestamp

let param = { // 2.Requested parameters
    "amount":"0.01",
    "symbol":"USDT",
    "type":0
};

let strParam = JSON.stringify(param); // 2.Formatting parameters

let strToSign = '' + timestamp + strParam; // 3.This is the string that needs to be signed

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.Signed result

let url = "https://api.bibox.com/v3/assets/transfer/cbu";

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//5.Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: strParam // 6.Formatting parameters
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log(body) // 7.response data

    });

Field name Field type Field description Field value
content-type string 'application/json'
bibox-api-key string your apikey
bibox-timestamp long Current timestamp,expressed in milliseconds timestamp
bibox-api-sign string Signature result sign

2.Fund transfer

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let timestamp = Date.now(); // 1.Current timestamp

let param = { // 2.Requested parameters
    "amount":"0.01",
    "symbol":"USDT",
    "type":0
};

let strParam = JSON.stringify(param); // 2.Formatting parameters

let strToSign = '' + timestamp + strParam; // 3.This is the string that needs to be signed

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.Signed result

let url = "https://api.bibox.com/v3/assets/transfer/cbu";

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//5.Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: strParam // 6.Formatting parameters
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log(body) // 7.Response data

    });

POST https://api.bibox.com/v3/assets/transfer/cbu

Name Necessary or not Type Description Default Value Range
amount true string Number to string
symbol true string coin symbol USDT
type true integer 0 transfer in, 1 transfer out 0,1

Response

{
    "state":0, // success
    "result":"352559634189422592"  // ignore
}

Name Description
state 0 means success, otherwise means failure
Other fields ignore

3.Place order

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/order/open";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "pair":"4BTC_USDT",
    "order_side":1,
    "order_type":2,
    "price":"11500",
    "amount":1,
    "order_from":6,
    "client_oid": "1234567890",
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/order/open

Name Necessary or not Type Description Default Value Range
pair true string Contract symbol 4BTC_USDT,4ETH_USDT, ...
amount true string Number to string
order_side true integer Order side, 1 open long, 2 open short, 3 close long, 4 close short 1,2,3,4
order_type true integer Order type, 1 market order, 2 limit order 1,2
price true string Order price
order_from true integer Order source 6
client_oid false string client order id

Response

{
    "state":0,
    "order_id":"425510999949316", // order id
    "client_oid":"1234567890", // client order id
    "status":1, // Order status 1 waiting to be traded, 2 partly traded, 3 fully traded, 4 partly cancelled, 5 fully cancelled, 100 order failed
    "cmd":"open" // ignore
}

Name Description
state 0 means success, otherwise means failure
order_id order id
client_oid client order id
status Order status 1 waiting to be traded, 2 partly traded, 3 fully traded, 4 partly cancelled, 5 fully cancelled, 100 order failed
Other fields ignore

4.Cancel order

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/order/close";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "order_id":"425510999949316"
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/order/close

Name Necessary or not Type Description Default Value Range
order_id true string order id

Response

{
    "state":0, // success
    "result":"success", 
    "cmd":"close"
}

Name Description
state 0 means success, otherwise means failure
Other fields ignore

5.Batch cancellation

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/order/closeBatch";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "order_ids":["2234567890","2234567891"]
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/order/closeBatch

Name Necessary or not Type Description Default Value Range
order_ids true Array Order id array

Response

{
    "state":0,// success
    "result":"success",
    "cmd":"close"
}

Name Description
state 0 means success, otherwise means failure
Other fields ignore

6.Cancel all orders

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/order/closeAll";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "pair":"4BTC_USDT"
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/order/closeAll

Name Necessary or not Type Description Default Value Range
pair true string Contract symbol 4BTC_USDT,4ETH_USDT, ...

Response

{
    "state":0,// success
    "result":"success",
    "cmd":"closeAll"
}

Name Description
state 0 means success, otherwise means failure
Other fields ignore

7.Adjust margin on a fixed position

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/changeMargin";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "pair":"4BTC_USDT",
    "margin":"0.01",
    "side":1
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/changeMargin

Name Necessary or not Type Description Default Value Range
pair true string Contract symbol 4BTC_USDT,4ETH_USDT, ...
margin true string margin
side true integer Position side, 1 long position, 2 short position 1,2

Response

{
    "state":3103, // failed
    "msg":"没有持仓不支持该操作",
    "cmd":"changeMargin"
}

Name Description
state 0 means success, otherwise means failure
Other fields ignore

8.Adjust position mode and leverage

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/changeMode";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "pair":"4BTC_USDT",
    "mode":2,
    "leverage_long":10,
    "leverage_short":20
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/changeMode

Name Necessary or not Type Description Default Value Range
pair true string Contract symbol 4BTC_USDT,4ETH_USDT, ...
mode true integer Position mode, 1 cross, 2 fixed 1,2
leverage_long true integer Long leverage 1~100
leverage_short true integer Short leverage 1~100

Response

{
    "state":0,
    "result":"success",
    "cmd":"changeMode"
}

Name Description
state 0 means success, otherwise means failure
Other fields ignore

9.Query assets

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/assets";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    // "coin":"USDT",
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/assets

Name Necessary or not Type Description Default Value Range
coin false string coin symbol BTC,ETH,...

Response

{
    "state":0,
    "result":[
        { ff: '0',
           b: '219311.9556',
           c: 'USDT',
           u: 100006,
           mc: '93265.8573',
           mf: '60.8824',
           fc: '0' }
    ],
    "cmd":"assets"
}

Name Description
state 0 means success, otherwise means failure
b Available Balance
c coin symbol
u user id
ff Fixed Position Frozen funds
fc Cross Position Frozen funds
mf Fixed Position margin
mc Cross Position margin
Other fields ignore

10.Query position

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/position";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    // "pair":"4BTC_USDT",
    // "side":1
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/position

Name Necessary or not Type Description Default Value Range
pair false string Contract symbol 4BTC_USDT,4ETH_USDT, ...
side false integer Position side, 1 long position, 2 short position 1,2

Response

{
    "state":0,
    "result":[
        {
            "pt":"0",//ignore
            "f":"0",//ignore
            "l":"10", // leverage
            "sd":1, // Position side, 1 Long, 2 Short
            "pa":"0", //Alert price
            "ui":100006,//user id
            "fb0":"0",//ignore
            "pf":"0",//Liquidation price
            "md":2,//Position mode, 1 Cross, 2 Fixed
            "lc":"0",// Can liquidate position value
            "pi":"4BTC_USDT", // pair
            "mg":"0", //margin
            "hc":"0",// Position value = Contract number multiplied by contract value
            "fb":"0",//ignore
            "po":"0" //Open price
        },
        ...
    ],
    "cmd":"position"
}

Name Description
state 0 means success, otherwise means failure
l leverage
sd Position side, 1 Long, 2 Short
pa Alert price
ui user id
pf Liquidation price
md Position mode, 1 Cross, 2 Fixed
lc Can liquidate position value
pi pair
mg margin
hc Position value = Contract number multiplied by contract value
po Open price
Other fields ignore

11.Query order list

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/order/list";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    // "pair":"4BTC_USDT",
    // "order_side":1
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/order/list

Name Necessary or not Type Description Default Value Range
pair false string Contract symbol 4BTC_USDT,4ETH_USDT, ...
order_side true integer Order side, 1 open long, 2 open short, 3 close long, 4 close short 1,2,3,4

Response

{
    "state":0,
    "result":{
        "p":1,
        "t":1,
        "o":[
            {
                "f":"0", //fee
                "dp":"0", //Deal price
                "eq":"0", //Deal amount
                "p":"11092", //Order price
                "tif":0, // ignore
                "q":"1", //Order quantity
                "sd":1, //Order side
                "r":0, //reason
                "s":1, // status
                "t":1602679944815, //time
                "ui":100006, //user id
                "fz":"0.0000091417", //Frozen funds
                "fb0":"0", //Coupon deduction
                "of":4, //order from
                "pi":"4BTC_USDT", //pair
                "oi":"426610511577093", // order id
                "coi":"1602679943911", //clientoid
                "fb":"0", //BIX deduction
                "po":false //ignore
            },
            ...
        ]
    },
    "cmd":"orderList"
}

Name Description
state 0 means success, otherwise means failure
f fee
dp Deal price
eq Deal amount
p Order price
q Order quantity
sd Order side
r Reason for failure
s Order status
t time
ui user id
fz Frozen funds
fb0 Coupon deduction
of Order source
pi pair
oi order id
coi Client order id
fb BIX deduction
Other fields ignore

12.Query order

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/order/detail";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "order_id":"426610511577093",
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/order/detail

Name Necessary or not Type Description Default Value Range
order_id true string order id

Response

{
    "state":0,
    "result":{
        "f":"0", //fee
        "dp":"0", //Deal price
        "eq":"0", //Deal amount
        "p":"11092", //Order price
        "tif":0, // ignore
        "q":"1", //Order quantity
        "sd":1, //Order side
        "r":0, //reason
        "s":1, // status
        "t":1602679944815, //time
        "ui":100006, //user id
        "fz":"0.0000091417", //Frozen funds
        "fb0":"0", //Coupon deduction
        "of":4, //order from
        "pi":"4BTC_USDT", //pair
        "oi":"426610511577093", // order id
        "coi":"1602679943911", //clientoid
        "fb":"0", //BIX deduction
        "po":false //ignore
    },
    "cmd":"orderDetail"
}

Name Description
state 0 means success, otherwise means failure
f fee
dp Deal price
eq Deal amount
p Order price
q Order quantity
sd Order side
r Reason for failure
s Order status
t time
ui user id
fz Frozen funds
fb0 Coupon deduction
of Order source
pi pair
oi order id
coi Client order id
fb BIX deduction
Other fields ignore

13. Batch query order

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/order/listBatch";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "order_ids":["426610511577093"],
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/order/listBatch

Name Necessary or not Type Description Default Value Range
order_ids true Array Order id array

Response

{
    "state":0,
    "result":[
        {
             "f":"0", //fee
            "dp":"0", //Deal price
            "eq":"0", //Deal amount
            "p":"11092", //Order price
            "tif":0, // ignore
            "q":"1", //Order quantity
            "sd":1, //Order side
            "r":0, //reason
            "s":1, // status
            "t":1602679944815, //time
            "ui":100006, //user id
            "fz":"0.0000091417", //Frozen funds
            "fb0":"0", //Coupon deduction
            "of":4, //order from
            "pi":"4BTC_USDT", //pair
            "oi":"426610511577093", // order id
            "coi":"1602679943911", //clientoid
            "fb":"0", //BIX deduction
            "po":false //ignore
        }
    ],
    "cmd":"orderListBatch"
}

Name Description
state 0 means success, otherwise means failure
f fee
dp Deal price
eq Deal amount
p Order price
q Order quantity
sd Order side
r Reason for failure
s Order status
t time
ui user id
fz Frozen funds
fb0 Coupon deduction
of Order source
pi pair
oi order id
coi Client order id
fb BIX deduction
Other fields ignore

14.Query order list based on clientoid

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbu/order/listBatchByClientOid";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "order_ids":["1602679943911"],
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3/cbu/order/listBatchByClientOid

Name Necessary or not Type Description Default Value Range
order_ids true Array Array of client order id

Response

{
    "state":0,
    "result":[
        {
             "f":"0", //fee
            "dp":"0", //Deal price
            "eq":"0", //Deal amount
            "p":"11092", //Order price
            "tif":0, // ignore
            "q":"1", //Order quantity
            "sd":1, //Order side
            "r":0, //reason
            "s":1, // status
            "t":1602679944815, //time
            "ui":100006, //user id
            "fz":"0.0000091417", //Frozen funds
            "fb0":"0", //Coupon deduction
            "of":4, //order from
            "pi":"4BTC_USDT", //pair
            "oi":"426610511577093", // order id
            "coi":"1602679943911", //clientoid
            "fb":"0", //BIX deduction
            "po":false //ignore
        }
    ],
    "cmd":"orderListBatchByCLientOid"
}

Name Description
state 0 means success, otherwise means failure
f fee
dp Deal price
eq Deal amount
p Order price
q Order quantity
sd Order side
r Reason for failure
s Order status
t time
ui user id
fz Frozen funds
fb0 Coupon deduction
of Order source
pi pair
oi order id
coi Client order id
fb BIX deduction
Other fields ignore

15.Get server time

GET https://api.bibox.com/v3/cbu/timestamp

Response

{
    "time":"1602680518605"
}

Name Description
time server time

16.Qeury position holding changed records

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3.1/cquery/base_u/dealLog";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "pair": "4BTC_USDT",
    "page": 1,
    "size": 10,
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3.1/cquery/base_u/dealLog

Name Necessary or not Type Description Default Value Range
pair true string Contract symbol 4BTC_USDT,4ETH_USDT, ...
page true integer page number 1,2, ...
size true integer return size 10,20, ...

Response

{
    "result":{
        "count":3,
        "page":1,
        "items":[
            {
                "id":"1125899906842635654", // record id
                "user_id":100006, // user id
                "coin_symbol":"USDT",// coin symbol
                "pair":"4BTC_USDT",// pair
                "side":1,// Position side, 1 Long, 2 Short
                "model":1,// Position model, 1Cross, 2Fixed
                "log_type":1,// Record type, 1 open position, 2 close position, 3 lighten position to reduce risk level, 4 liquidate position, 5ADL
                "hold_coin_dx":"1.0000000000",// Change in position
                "hold_coin":"1.0000000000",// Position holding
                "price_log":"11692.0000000000",// proposed price
                "price_open":"11692.0000000000",// Average 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"
            },
            ...
        ]
    },
    "state":0
}

Name Description
state 0 means success, otherwise means failure
id record id
user_id user id
coin_symbol coin symbol
pair pair
side Position side, 1 Long, 2 Short
model Position model, 1Cross, 2Fixed
log_type Record type, 1 open position, 2 close position, 3 lighten position to reduce risk level, 4 liquidate position, 5ADL
hold_coin_dx Change in position
hold_coin Position holding
price_log proposed price
price_open Average open price
profit profit
fee fee
fee_bix BIX deduction
fee_bix0 Coupon deduction
createdAt time
Other fields ignore

17.Query order deals detail

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3.1/cquery/base_u/orderDetail";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "orderId":"421112953438213",
    "page":1,
    "size":10
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3.1/cquery/base_u/orderDetail

Name Necessary or not Type Description Default Value Range
orderId true long order id
page true integer page number 1,2, ...
size true integer return size 10,20, ...

Response

{
    "result":{
        "count":1,
        "page":1,
        "items":[
            {
                "id":"1125899906842635651",// record id
                "coin_symbol":"USDT",// coin symbol
                "pair":"4BTC_USDT",// pair
                "side":2,// Pending order side, 1 open long, 2 open short, 3 close long, 4 close short
                "order_from":4,// Order source
                "price":"10692.0000000000",// Pending order 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
            }
        ]
    }
    "state":0
}

Name Description
state 0 means success, otherwise means failure
id record id
coin_symbol coin symbol
pair pair
side Pending order side, 1 open long, 2 open short, 3 close long, 4 close short
order_from Order source
price Pending order price
deal_price Deal price
deal_coin Deal amount
fee fee
fee_bix BIX deduction
fee_bix0 Coupon deduction
createdAt time
is_maker is maker
Other fields ignore

18.Query historical orders

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3.1/cquery/base_u/orderHistory";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "page": 1,
    "size": 10,
    "pair": "4BTC_USDT",
    "side": 1,
    "status": [3, 4, 5, 100],
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3.1/cquery/base_u/orderHistory

Name Necessary or not Type Description Default Value Range
pair false string Contract symbol 4BTC_USDT,4ETH_USDT, ...
page true integer page number 1,2, ...
size true integer return size 10,20, ...
side false integer Order side, 1 open long 2 open short 3 close long 4 close short
status false Array Order status, 1 uncompleted, 2 partially completed, 3 completely completed, 4 partially cancelled, 5 completely cancelled, 100 failed to place an order

Response

{
    "result":{
        "count":1,
        "page":1,
        "items":[
            {
                "id":421112953438215,// order id
                "user_id":100006,// user id
                "coin_symbol":"USDT",// coin symbol
                "pair":"4BTC_USDT",// pair
                "side":1,// Order side, 1 open long 2 open short 3 close long 4 close short
                "order_type":2,// Order type, 1 market price, 2 limit price
                "price":"11692.0000000000",// Pending order price
                "amount_coin":"1.0000000000",// Order quantity
                "freeze":"0.0000000000",// Frozen funds
                "price_deal":"11692.0000000000",// Average deal 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,// Reason for failure
                "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
            }
        ]
    },
    "state":0
}

Name Description
state 0 means success, otherwise means failure
id order id
user_id user id
coin_symbol coin symbol
pair pair
side Pending order side, 1 open long, 2 open short, 3 close long, 4 close short
order_type Order type, 1 market price, 2 limit price
price Pending order price
amount_coin Order quantity
freeze Frozen funds
price_deal Average deal price
deal_coin Deal amount
deal_num Deal number
fee fee
fee_bix BIX deduction
fee_bix0 Coupon deduction
status Order status, 1 uncompleted, 2 partially completed, 3 completely completed, 4 partially cancelled, 5 completely cancelled, 100 failed to place an order
reason Reason for failure
fee_rate_maker maker fee rate
fee_rate_taker taker fee rate
client_oid client order id
order_from Order source
createdAt created time
Other fields ignore

19.Query order

Request

let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3.1/cquery/base_u/orderById";

let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret

let param = {
    "orderIds": ["421112953438213", "421112953438214"],
    "clientOids": ["1602644402806", "1602644402811"],
};

let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds

request.post({
        url: url,//Request path
        method: "POST",//Request method
        headers: {//Set request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//parameter string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }

        console.log(body)

    });

POST https://api.bibox.com/v3.1/cquery/base_u/orderById

Name Necessary or not Type Description Default Value Range
orderIds true Array Order id array
clientOids true Array Array of client order id

Response

{
    "result":[
        {
            "id":421112953438214,// order id
            "user_id":100006,// user id
            "coin_symbol":"USDT",// coin symbol
            "pair":"4BTC_USDT",// pair
            "side":1,// Order side, 1 open long 2 open short 3 close long 4 close short
            "order_type":2,// Order type, 1 market price, 2 limit price
            "price":"11692.0000000000",// Pending order price
            "amount_coin":"1.0000000000",// Order quantity
            "freeze":"0.0000000000",// Frozen funds
            "price_deal":"11692.0000000000",// Average deal 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,// Reason for failure
            "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
        },
        ...
    ],
    "state":0
}

Name Description
state 0 means success, otherwise means failure
id order id
user_id user id
coin_symbol coin symbol
pair pair
side Pending order side, 1 open long, 2 open short, 3 close long, 4 close short
order_type Order type, 1 market price, 2 limit price
price Pending order price
amount_coin Order quantity
freeze Frozen funds
price_deal Average deal price
deal_coin Deal amount
deal_num Deal number
fee fee
fee_bix BIX deduction
fee_bix0 Coupon deduction
status Order status, 1 uncompleted, 2 partially completed, 3 completely completed, 4 partially cancelled, 5 completely cancelled, 100 failed to place an order
reason Reason for failure
fee_rate_maker maker fee rate
fee_rate_taker taker fee rate
client_oid client order id
order_from Order source
createdAt created time
Other fields ignore

20.Qeury fund fee rate

GET https://api.bibox.com/v3.1/cquery/buFundRate

Response

{
    "result":{
        "4BTC_USDT":{
            "pair":"4BTC_USDT",
            "close":"0.0000000000",
            "fund_rate":"0.0001000000",
            "createdAt":"2020-10-14T00:00:00.000Z"
        },
        "4ETH_USDT":{
            "pair":"4ETH_USDT",
            "close":"0.0000000000",
            "fund_rate":"0.0001000000",
            "createdAt":"2020-10-14T00:00:00.000Z"
        }
    },
    "state":0
}

Name Description
state 0 means success, otherwise means failure
pair pair
fund_rate fund fee rate
Other fields ignore

21.Qeury tag price

GET https://api.bibox.com/v3.1/cquery/buTagPrice

Response

{
    "result":{
        "4BTC_USDT":{//pair
            "close":"11453.7224909000",// Index price
            "priceTag":"11454.2951770245",// Tag price
            "createdAt":"2020-10-14T03:41:08.000Z" // time
        },
        "4ETH_USDT":{
            "close":"383.1999999600",
            "priceTag":"383.2191599600",
            "createdAt":"2020-10-14T03:41:08.000Z"
        }
    },
    "state":0
}

Name Description
state 0 means success, otherwise means failure
result The keyword is pair
close Index price
priceTag Tag price
createdAt time
Other fields ignore

22.Query basic contract information

GET https://api.bibox.com/v3.1/cquery/buValue

Response

{
    "result":[
        {
            "id":304,
            "pair":"4BTC_USDT",
            "coin_symbol":"USDT",
            "leverage_init":"10.0000000000",
            "leverage_min":"0.0100000000",
            "leverage_max":"150.0000000000",
            "value":"0.0001000000",
            "risk_level_base":"1.0000000000",
            "risk_level_dx":"1.0000000000",
            "maker_fee":"0.0002000000",
            "taker_fee":"0.0005500000",
            "open_max_per":"100.0000000000",
            "pending_max":100,
            "hold_max":"100.0000000000",
            "price_precision":1
        },
        ...
    ],
    "state":0
}

Name Description
state 0 means success, otherwise means failure
pair pair
leverage_min Minimum leverage
leverage_max Maximum leverage
value contract value
maker_fee default maker fee rate
taker_fee default taker fee rate
open_max_per Maximum number of single pending orders
pending_max Maximum number of pending orders
hold_max Maximum position value
Other fields ignore

23.Query accuracy configuration

GET https://api.bibox.com/v3.1/cquery/buUnit

Response

{
    "result":[
        {
            "pair":"4BTC_USDT",//pair
            "price_unit":1,//Decimal points for order
            "vol_unit":6, // ignore
            "value_unit":0 // ignore
        },
        ...
    ],
    "state":0
}

Name Description
state 0 means success, otherwise means failure
pair pair
price_unit Decimal points for order
Other fields ignore

24.Query Kline

Name Necessary or not Type Description Default Value Range
pair true string pair 4BTC_USDT, 4ETH_USDT, ...
period true string k-line period '1min', '3min', '5min', '15min', '30min', '1hour', '2hour', '4hour', '6hour', '12hour', 'day', 'week'
size false integer size 1000 1-1000

Response

{
    "result":[
        {
            "time":1602680580000,// Timestamp
            "open":"10666.00000000",// Opening price
            "high":"10666.00000000",// Highest price
            "low":"10666.00000000", // Lowest price
            "close":"10666.00000000",// Closing price
            "vol":"0.00000000"// Volume
        },
        ...
    ],
    "cmd":"kline",
    "ver":"2.0"
}

Name Description
result Value means success, otherwise means failure
time Timestamp
open Opening price
high Highest price
low Lowest price
close Closing price
vol Volume
Other fields ignore

25.Query market depth

GET https://api.bibox.com/v2/mdata/depth?pair=4BTC_USDT&size=10

Name Necessary or not Type Description Default Value Range
pair true string pair 4BTC_USDT, 4ETH_USDT, ...
size false integer size 200 1-200

Response

{
    "result":{
        "pair":"4BTC_USDT",
        "update_time":1602669350668,
        "asks":[//Seller Depth of Market

        ],
        "bids":[//Buyer market depth
            {
                "volume":"54054",//Order quantity
                "price":"10666"//Pending order price
            },
            ...
        ]
    },
    "cmd":"depth",
    "ver":"2.0"
}

Name Description
result Value means success, otherwise means failure
pair pair
update_time time
asks Seller Depth of Market
bids Buyer market depth
volume Order quantity
price Pending order price
Other fields ignore

26.Subscription to Kline

Example


const WebSocket = require('ws');
const zlib = require('zlib');

const biboxws = 'wss://push.bibox.me/cbu';

let wsClass = function () {

};

wsClass.prototype._decodeMsg = async function (data) {
    let that = this;
    return new Promise((resolve, reject) => {
        // console.log(Buffer.from(data, 'base64'))
        zlib.unzip(Buffer.from(data, 'base64'), (err, buffer) => {
            if (err) {
                return reject(err);
            }
            try {
                console.log('_decodeMsg', buffer.toString())
                let data = JSON.parse(buffer.toString());
                resolve(data);
            } catch (e) {
                console.log('_decodeMsg catch', buffer.toString())
                reject(e);
            }
        });
    }).catch(err => {
        console.warn(err);
    });
};

wsClass.prototype._consumerMsg = function (msg) {
    let that = this;
    Promise.resolve().then(async () => {
        let data = msg.data;
        if (msg.binary == 1) {
            data = await that._decodeMsg(data);
        }
    }).catch(err => {

    });
};

wsClass.prototype._initWs = async function () {
    let that = this;
    let ws = new WebSocket(biboxws);
    that.ws = ws;

    ws.on('open', function open() {
        console.log(new Date(), 'open')
        {
            ws.send(JSON.stringify({
                event: 'addChannel',
                channel: 'bibox_sub_spot_4BTC_USDT_kline_1min',
                binary: 0,
                ver: 8,
            }));
        }
    });

    ws.on('close', err => {
        console.log('close, ', err);
    });

    ws.on('error', err => {
        console.log('error', err);
    });

    ws.on('ping', err => {
        console.log('ping ', err.toString('utf8'));
    });

    ws.on('pong', err => {
        console.log('pong ', err.toString('utf8'));
    });

    ws.on('message', data => {
        console.log('message', data)
        let jdata = JSON.parse(data); // Response data
        for (let i = 0; i < jdata.length; i++) {
            let item = jdata[i];
            if (!item.data) {
                continue;
            }
            that._consumerMsg(item);
        }
    });
};

let instance = new wsClass();

instance._initWs().catch(err => {
    console.log(err);
});

wss://push.bibox.me/cbu

Name Necessary or not Type Description Default Value Range
pair true string pair 4BTC_USDT, 4ETH_USDT
period true string k-line period 1min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 12hour, day, week
event true string event 'addChannel'
channel true string 'bibox_sub_spot_' + ${pair} + '_kline_' + ${period}
binary true int 0
ver true int 8

Response

[
    {
        "channel":"bibox_sub_spot_4BTC_USDT_kline_1min",
        "binary":0,
        "data_type":1,
        "data":[
            {
                "time":1603969980000,
                "open":"13131.80000000",
                "high":"13136.40000000",
                "low":"13131.80000000",
                "close":"13136.40000000",
                "vol":"43045.00000000"
            },
            {
                "time":1603970040000,
                "open":"13136.30000000",
                "high":"13136.80000000",
                "low":"13136.30000000",
                "close":"13136.70000000",
                "vol":"5561.00000000"
            }
        ]
    }
]

Name Description
time k-line start time
count Deal number
open Opening price
high Highest price
low Lowest price
close Closing price
vol Volume(Contract value)
binary 0 means the data is not compressed, 1 means the data is compressed
Other fields ignore

27.Subscription to Tag price

Example


const WebSocket = require('ws');
const zlib = require('zlib');

const biboxws = 'wss://push.bibox.me/cbu';

let wsClass = function () {

};

wsClass.prototype._decodeMsg = async function (data) {
    let that = this;
    return new Promise((resolve, reject) => {
        // console.log(Buffer.from(data, 'base64'))
        zlib.unzip(Buffer.from(data, 'base64'), (err, buffer) => {
            if (err) {
                return reject(err);
            }
            try {
                console.log('_decodeMsg', buffer.toString())
                let data = JSON.parse(buffer.toString());
                resolve(data);
            } catch (e) {
                console.log('_decodeMsg catch', buffer.toString())
                reject(e);
            }
        });
    }).catch(err => {
        console.warn(err);
    });
};

wsClass.prototype._consumerMsg = function (msg) {
    let that = this;
    Promise.resolve().then(async () => {
        let data = msg.data;
        if (msg.binary == 1) {
            data = await that._decodeMsg(data);
        }
    }).catch(err => {

    });
};

wsClass.prototype._initWs = async function () {
    let that = this;
    let ws = new WebSocket(biboxws);
    that.ws = ws;

    ws.on('open', function open() {
        console.log(new Date(), 'open')
        {
            ws.send(JSON.stringify({
                event: 'addChannel',
                channel: 'bibox_sub_spot_4BTC_USDTTAGPRICE_kline_1min',
                binary: 0,
                ver: 8,
            }));
        }
    });

    ws.on('close', err => {
        console.log('close, ', err);
    });

    ws.on('error', err => {
        console.log('error', err);
    });

    ws.on('ping', err => {
        console.log('ping ', err.toString('utf8'));
    });

    ws.on('pong', err => {
        console.log('pong ', err.toString('utf8'));
    });

    ws.on('message', data => {
        console.log('message', data)
        let jdata = JSON.parse(data); // Response data
        for (let i = 0; i < jdata.length; i++) {
            let item = jdata[i];
            if (!item.data) {
                continue;
            }
            that._consumerMsg(item);
        }
    });
};

let instance = new wsClass();

instance._initWs().catch(err => {
    console.log(err);
});

wss://push.bibox.me/cbu

Name Necessary or not Type Description Default Value Range
pair true string pair 4BTC_USDT, 4ETH_USDT
event true string event 'addChannel'
channel true string 'bibox_sub_spot_' + ${pair} + 'TAGPRICE_kline_1min'
binary true int 0
ver true int 8

Response

[
    {
        "channel":"bibox_sub_spot_4BTC_USDTTAGPRICE_kline_1min",
        "binary":0,
        "data_type":1,
        "data":[
            {
                "time":1603970520000,
                "open":"13153.34453367",
                "high":"13153.34453367",
                "low":"13151.07785535",
                "close":"13151.13533507",
                "vol":"30.00000000"
            },
            {
                "time":1603970580000,
                "open":"13150.75301752",
                "high":"13150.75301752",
                "low":"13149.51581987",
                "close":"13149.51581987",
                "vol":"5.00000000"
            }
        ]
    }
]

Name Description
time k-line start time
count Deal number
open Opening price
high Highest price
low Lowest price
close Latest price
binary 0 means the data is not compressed, 1 means the data is compressed
Other fields ignore

28.Subscription to Market depth

Example


const WebSocket = require('ws');
const zlib = require('zlib');

const biboxws = 'wss://push.bibox.me/cbu';

let wsClass = function () {

};

wsClass.prototype._decodeMsg = async function (data) {
    let that = this;
    return new Promise((resolve, reject) => {
        // console.log(Buffer.from(data, 'base64'))
        zlib.unzip(Buffer.from(data, 'base64'), (err, buffer) => {
            if (err) {
                return reject(err);
            }
            try {
                console.log('_decodeMsg', buffer.toString())
                let data = JSON.parse(buffer.toString());
                resolve(data);
            } catch (e) {
                console.log('_decodeMsg catch', buffer.toString())
                reject(e);
            }
        });
    }).catch(err => {
        console.warn(err);
    });
};

wsClass.prototype._consumerMsg = function (msg) {
    let that = this;
    Promise.resolve().then(async () => {
        let data = msg.data;
        if (msg.binary == 1) {
            data = await that._decodeMsg(data);
        }
    }).catch(err => {

    });
};

wsClass.prototype._initWs = async function () {
    let that = this;
    let ws = new WebSocket(biboxws);
    that.ws = ws;

    ws.on('open', function open() {
        console.log(new Date(), 'open')
        {
            ws.send(JSON.stringify({
                event: 'addChannel',
                channel: 'bibox_sub_spot_4BTC_USDT_depth', // depth
                binary: 0,
                ver: 3,
            }));
        }
    });

    ws.on('close', err => {
        console.log('close, ', err);
    });

    ws.on('error', err => {
        console.log('error', err);
    });

    ws.on('ping', err => {
        console.log('ping ', err.toString('utf8'));
    });

    ws.on('pong', err => {
        console.log('pong ', err.toString('utf8'));
    });

    ws.on('message', data => {
        console.log('message', data)
        let jdata = JSON.parse(data); // Response data
        for (let i = 0; i < jdata.length; i++) {
            let item = jdata[i];
            if (!item.data) {
                continue;
            }
            that._consumerMsg(item);
        }
    });
};

let instance = new wsClass();

instance._initWs().catch(err => {
    console.log(err);
});

wss://push.bibox.me/cbu

Name Necessary or not Type Description Default Value Range
pair true string pair 4BTC_USDT, 4ETH_USDT
event true string event 'addChannel'
channel true string 'bibox_sub_spot_' + ${pair} + '_depth_'
binary true int 0
ver true int 3

Response

{
    "pair":"4BTC_USDT",
    "update_time":1604021669643,
    "seq":4544162,
    "add":{
        "asks":null,
        "bids":null
    },
    "del":{
        "asks":null,
        "bids":null
    },
    "mod":{
        "asks":[
            {
                "volume":"54000",
                "price":"13574.4"
            }
        ],
        "bids":[
            {
                "volume":"17012",
                "price":"13574.3"
            }
        ]
    }
}

Name Description
pair pair
update_time time
seq pair
add add data
del delete data
mod modify data
asks ask data
bids bid data
volume Order quantity
price price
binary 0 means the data is not compressed, 1 means the data is compressed
Other fields ignore

29.Subscription to deals detail

Example


const WebSocket = require('ws');
const zlib = require('zlib');

const biboxws = 'wss://push.bibox.me/cbu';

let wsClass = function () {

};

wsClass.prototype._decodeMsg = async function (data) {
    let that = this;
    return new Promise((resolve, reject) => {
        // console.log(Buffer.from(data, 'base64'))
        zlib.unzip(Buffer.from(data, 'base64'), (err, buffer) => {
            if (err) {
                return reject(err);
            }
            try {
                console.log('_decodeMsg', buffer.toString())
                let data = JSON.parse(buffer.toString());
                resolve(data);
            } catch (e) {
                console.log('_decodeMsg catch', buffer.toString())
                reject(e);
            }
        });
    }).catch(err => {
        console.warn(err);
    });
};

wsClass.prototype._consumerMsg = function (msg) {
    let that = this;
    Promise.resolve().then(async () => {
        let data = msg.data;
        if (msg.binary == 1) {
            data = await that._decodeMsg(data);
        }
    }).catch(err => {

    });
};

wsClass.prototype._initWs = async function () {
    let that = this;
    let ws = new WebSocket(biboxws);
    that.ws = ws;

    ws.on('open', function open() {
        console.log(new Date(), 'open')
        {
            ws.send(JSON.stringify({
                event: 'addChannel',
                channel: 'bibox_sub_spot_4BTC_USDT_deals', 
                binary: 0,
            }));
        }
    });

    ws.on('close', err => {
        console.log('close, ', err);
    });

    ws.on('error', err => {
        console.log('error', err);
    });

    ws.on('ping', err => {
        console.log('ping ', err.toString('utf8'));
    });

    ws.on('pong', err => {
        console.log('pong ', err.toString('utf8'));
    });

    ws.on('message', data => {
        console.log('message', data)
        let jdata = JSON.parse(data); // Response data
        for (let i = 0; i < jdata.length; i++) {
            let item = jdata[i];
            if (!item.data) {
                continue;
            }
            that._consumerMsg(item);
        }
    });
};

let instance = new wsClass();

instance._initWs().catch(err => {
    console.log(err);
});

wss://push.bibox.me/cbu

Name Necessary or not Type Description Default Value Range
pair true string pair 4BTC_USDT, 4ETH_USDT
event true string event 'addChannel'
channel true string 'bibox_sub_spot_' + ${pair} + '_deals'
binary true int 0

Response

[
    {
        "pair":"4BTC_USDT",
        "price":"13570.600000",
        "amount":"800.00",
        "time":1604022129044,
        "side":2,
        "id":0
    }
]

Name Description
pair pair
price Deal price
amount Deal amount
time Timestamp
side trade side, 1 buy, 2 sell
binary 0 means the data is not compressed, 1 means the data is compressed
Other fields ignore

30.Subscription to ticker

Example


const WebSocket = require('ws');
const zlib = require('zlib');

const biboxws = 'wss://push.bibox.me/cbu';

let wsClass = function () {

};

wsClass.prototype._decodeMsg = async function (data) {
    let that = this;
    return new Promise((resolve, reject) => {
        // console.log(Buffer.from(data, 'base64'))
        zlib.unzip(Buffer.from(data, 'base64'), (err, buffer) => {
            if (err) {
                return reject(err);
            }
            try {
                console.log('_decodeMsg', buffer.toString())
                let data = JSON.parse(buffer.toString());
                resolve(data);
            } catch (e) {
                console.log('_decodeMsg catch', buffer.toString())
                reject(e);
            }
        });
    }).catch(err => {
        console.warn(err);
    });
};

wsClass.prototype._consumerMsg = function (msg) {
    let that = this;
    Promise.resolve().then(async () => {
        let data = msg.data;
        if (msg.binary == 1) {
            data = await that._decodeMsg(data);
        }
    }).catch(err => {

    });
};

wsClass.prototype._initWs = async function () {
    let that = this;
    let ws = new WebSocket(biboxws);
    that.ws = ws;

    ws.on('open', function open() {
        console.log(new Date(), 'open')
        {
            ws.send(JSON.stringify({
                event: 'addChannel',
                channel: 'bibox_sub_spot_4BTC_USDT_ticker', 
                binary: 0,
            }));
        }
    });

    ws.on('close', err => {
        console.log('close, ', err);
    });

    ws.on('error', err => {
        console.log('error', err);
    });

    ws.on('ping', err => {
        console.log('ping ', err.toString('utf8'));
    });

    ws.on('pong', err => {
        console.log('pong ', err.toString('utf8'));
    });

    ws.on('message', data => {
        console.log('message', data)
        let jdata = JSON.parse(data); // Response data
        for (let i = 0; i < jdata.length; i++) {
            let item = jdata[i];
            if (!item.data) {
                continue;
            }
            that._consumerMsg(item);
        }
    });
};

let instance = new wsClass();

instance._initWs().catch(err => {
    console.log(err);
});

wss://push.bibox.me/cbu

Name Necessary or not Type Description Default Value Range
pair true string pair 4BTC_USDT, 4ETH_USDT
event true string event 'addChannel'
channel true string 'bibox_sub_spot_' + ${pair} + '_ticker'
binary true int 0

Response

[
    {
        "channel":"bibox_sub_spot_4BTC_USDT_ticker",
        "binary":0,
        "data_type":1,
        "data":{
            "pair":"4BTC_USDT",
            "last":"13593.5",
            "last_usd":"13593.50",
            "last_cny":"91076.20",
            "high":"13700.300000",
            "low":"12986.000000",
            "buy":"13593.5",
            "buy_amount":"48375",
            "sell":"13593.6",
            "sell_amount":"56625",
            "vol":"155811681.00",
            "percent":"+2.44%",
            "timestamp":1604022393028,
            "base_last_cny":"91076.20000000"
        }
    }
]

Name Description
pair pair
last last price
last_cny last cny price
last_usd last usd price
high 24hHighest price
low 24hLowest price
buy Latest bid price
buy_amount Latest bid amount
sell Latest ask price
sell_amount Latest ask amount
vol 24hDeal amount
percent 24h Quote change
timestamp Timestamp
base_last_cny Latest cny price
binary 0 means the data is not compressed, 1 means the data is compressed
Other fields ignore

31.Subscription to user data

Example


'use strict'

const WebSocket = require('ws');
let CryptoJS = require("crypto-js");

const biboxws = 'wss://push.bibox.me/cbu'; // 1.Request path

let apikey = '900625568558820892a8c833c33ebc8fd2701efe'; // your apikey
let param = {  // Define the parameter object param, need to use apikey
    "apikey": apikey,
    "channel": "bibox_sub_spot_ALL_ALL_login",
    "event": "addChannel"
};
let strParam = JSON.stringify(param); // Format the parameter object param, get strParam
let secret = 'c708ac3e70d115ec29efbee197330627d7edf842'; // apikey secret
let sign = CryptoJS.HmacMD5(strParam, secret).toString(); // Use apikey's secret to sign strParam with HmacMD5, and get the signature result sign
let wsparam = {  // 2.Request parameter
    "apikey": apikey,
    "channel": "bibox_sub_spot_ALL_ALL_login",
    "event": "addChannel",
    "sign": sign,
};


let init = function () {

    let ws = new WebSocket(biboxws);

    setInterval(function () {
        if (ws && ws.readyState == WebSocket.OPEN) {
            console.log('manu ping');
            ws.ping(Date.now());
        }
    }, 1000 * 10);

    ws.on('open', function open() {

        console.log('open')
        ws.send(JSON.stringify(wsparam));

    });

    ws.on('close', err => {
        console.log('close, ', err);
    });

    ws.on('error', err => {
        console.log('error', err);
    });

    ws.on('ping', err => {
        console.log('ping', err)
    });

    ws.on('pong', err => {
        console.log('pong', err)
    });

    ws.on('message', function incoming(data) {
        let jdata = JSON.parse(data); // response data
        if (!jdata.ping) {
            console.log('message', data)
        }

    });
};

module.exports = {};

init();


wss://push.bibox.me/cbu

Name Necessary or not Type Description Default Value Range
apikey true string your apikey
sign true string sign
event true string event 'addChannel'
channel true string 'bibox_sub_spot_ALL_ALL_login'

1.Define the parameter object param, need to use apikey

let apikey = 'thisisyourapikey';

let param = { "apikey": apikey, "channel": "bibox_sub_spot_ALL_ALL_login", "event": "addChannel" };

2.Format the parameter object param, get strParam

let strParam = JSON.stringify(param);

3.Use apikey's secret to sign strParam with HmacMD5, and get the signature result sign

let CryptoJS = require("crypto-js");

let secret = 'c708ac3e70d115ec29efbee197330627d7edf842';

let sign = CryptoJS.HmacMD5(strParam, secret).toString();

4.Generate subscription parameters wsparam

let wsparam = { "apikey": apikey, "channel": "bibox_sub_spot_ALL_ALL_login", "event": "addChannel", "sign": sign, };

Response

[
    {
        "channel":"bibox_sub_spot_ALL_ALL_login",
        "binary":"0",
        "data_type":0,
        "data":{
            "result":"订阅成功"
        }
    }
]

Name Description
result "订阅成功" means subscription success
Other fields ignore

32.Get assets from subscribed user data

contract_assets

Response

[
    {
        "channel":"bibox_sub_spot_ALL_ALL_login",
        "binary":"0",
        "data_type":1,
        "data":{
            "contract_assets":{
                "ff":"0",
                "b":"218884.3026",
                "c":"USDT",
                "u":100006,
                "mc":"93265.8573",
                "mf":"486.3048",
                "fc":"0"
            }
        }
    }
]

Name Description
b Available Balance
c coin symbol
u user id
ff Fixed Position Frozen funds
fc Cross Position Frozen funds
mf Fixed Position margin
mc Cross Position margin
Other fields ignore

33.Get position from subscribed user data

contract_order

Response

[
    {
        "channel":"bibox_sub_spot_ALL_ALL_login",
        "binary":"0",
        "data_type":1,
        "data":{
            "contract_order":{
                "pt":"0",
                "f":"0",
                "l":"10",
                "sd":2,
                "pa":"1.0006153088",
                "ui":100006,
                "fb0":"0",
                "pf":"1.0006148393",
                "md":1,
                "lc":"0",
                "pi":"4BTC_USDT",
                "mg":"0",
                "hc":"0",
                "fb":"0",
                "po":"0"
            }
        }
    }
]

Name Description
l leverage
sd Position side, 1 Long, 2 Short
pa Alert price
ui user id
pf Liquidation price
md Position mode, 1 Cross, 2 Fixed
lc Can liquidate position value
pi pair
mg margin
hc Position value = Contract number multiplied by contract value
po Open price
Other fields ignore

34.Get order from subscribed user data

contract_pending

Response

[
    {
        "channel":"bibox_sub_spot_ALL_ALL_login",
        "binary":"0",
        "data_type":1,
        "data":{
            "contract_pending":{
                "f":"0",
                "dp":"0",
                "eq":"0",
                "p":"11692",
                "tif":0,
                "q":"1",
                "sd":2,
                "r":0,
                "s":1,
                "t":1602750121093,
                "ui":100006,
                "fz":"0.0000086786",
                "fb0":"0",
                "of":4,
                "pi":"4BTC_USDT",
                "oi":"432108069716000",
                "coi":"1602750117690",
                "fb":"0",
                "po":false
            }
        }
    }
]

Name Description
f fee
dp Deal price
eq Deal amount
p Order price
q Order quantity
sd Order side
r Reason for failure
s Order status
t time
ui user id
fz Frozen funds
fb0 Coupon deduction
of Order source
pi pair
oi order id
coi Client order id
fb BIX deduction
Other fields ignore

35.Get deals detail from subscribed user data

contract_detail

Response

[
    {
        "channel":"bibox_sub_spot_ALL_ALL_login",
        "binary":"0",
        "data_type":1,
        "data":{
            "contract_detail":{
                "oi":"432108069715999",//Order id
                "ui":"100006",//user id
                "id":"1125899906842648855",//deals detail id
                "coi":"1602750117684",//client order id
                "pi":"4BTC_USDT",//pair
                "sd":1,//
                "s":3,//
                "ot":2,
                "of":4,// Order source
                "q":"1",
                "p":"11692",//Pending order price
                "dp":"10655",//Deal price
                "ep":"1",
                "f":"0.0000000657",//fee
                "fb":"0",//BIX deduction
                "fb0":"0",//Coupon deduction
                "im":0,//is maker
                "t":1602750121093, //time
            }
        }
    }
]

Name Description
oi order id
ui user id
id record id
coi Client order id
pi pair
sd Order side
of Order source
p Order price
dp Deal price
f fee
fb0 Coupon deduction
fb BIX deduction
im is maker
t time
Other fields ignore

36.Get passive changes in positions from subscribed user data

contract_deal_log

Response

[
    {
        "channel":"bibox_sub_spot_ALL_ALL_login",
        "binary":"0",
        "data_type":1,
        "data":{
            "contract_deal_log":{
                "id":"1125899906842654296",// record id
                "user_id":100006,//user id
                "type":5,//Change type, 1 open position, 2 close position, 3 lighten position to reduce risk level, 4 liquidate position, 5ADL
                "mode":2,//Position model, 1Cross, 2Fixed
                "pair":"4BTC_USDT",//pair
                "price":"11247.6",//proposed price
                "hold_dx":"1",//Change in position
                "order_side":2,// Position side, 1Long, 2Short
                "time":1602755131000, //time
            }
        }
    }
]

Name Description
id record id
user_id user id
type Change type, 1 open position, 2 close position, 3 lighten position to reduce risk level, 4 liquidate position, 5ADL
mode Position model, 1Cross, 2Fixed
pair pair
price proposed price
hold_dx Change in position
order_side Position side, 1Long, 2Short
time time
Other fields ignore

Errors

错误码

Code 描述 Msg
2003 Cookie 失效 Cookie expired
2033 操作失败!订单已完成或已撤销 Operation failed! Order completed or canceled
2034 操作失败!请检查参数是否正确 Operation failed! Please check parameter
2040 操作失败!没有该订单 Operation failed! No record
2064 订单撤销中,不能再次撤销 Canceling. Unable to cancel again
2065 委托价格设置过高,请重新设置价格 Precatory price is exorbitant, please reset
2066 委托价格设置过低,请重新设置价格 Precatory price is low , please reset
2067 暂不支持市价单 Limit Order Only
2068 下单数量不能低于0.0001 Min Amount:0.0001
2069 市价单无法撤销 Market order can not be canceled
2078 下单价格非法 unvalid order price
2085 币种最小下单数量限制 the trade amount is low
2086 账户资产异常,限制下单 Abnormal account assets, trade is forbiden
2091 请求过于频繁,请稍后再试 request is too frequency, please try again later
2092 币种最小下单金额限制 Minimum amount not met
3000 请求参数错误 Requested parameter incorrect
3002 参数不能为空 Parameter cannot be null
3009 推送订阅channel不合法 Illegal subscription channel
3010 websocket连接异常 websocket connection error
3011 接口不支持apikey请求方式 Illegal subscribe event
3012 apikey无效 Interface does not support apikey request method
3016 交易对错误 Invalid apikey
3017 推送订阅event不合法 Trading pair error
3024 apikey权限不足 apikey authorization insufficient
3025 apikey签名验证失败 apikey signature verification failed
3026 apikey ip受限制 apikey ip is restricted
3027 账户没有apikey No apikey in your account
3028 账户apikey数量超过了限制数量 Account apikey has exceeded the limit amount
3029 apikey允许ip数量超过了限制数量 apikey ip has exceeded the limit amount
3033 查询类请求限制一个cmd query allow only one cmd
3034 最大cmd个数限制 maxinum cmds
3035 cmd请求个数限制 too many cmds
4000 当前网络连接不稳定,请稍候重试 the network is unstable now, please try again later
4003 服务器繁忙,请稍后再试 The server is busy, please try again later