Restful API Coin-based contract V3

Signature and return format

  • All are post requests, and the request data is directly placed in httpbody 'content-type': 'application/json',

  • The apikey and signature are placed in httpheader 'bibox-api-key': apikey 'bibox-api-sign': sign

  • Add a timestamp to the httpheader to indicate the timestamp of the request sent, expressed in milliseconds, to limit the time of the request 'bibox-timestamp': timestamp

  • Return value, each response contains state, 0 means success, other error codes, means failure

  • example

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

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

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

let param = {
    "amount":"0.01",
    "symbol":"BTC",
    "type":0
};

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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Fund transfer

Name Necessary or not Type Description Default Value Range
amount true string string of amount
symbol true string coin symbol BTC,ETH, ...
type true integer 0 transfer in, 1 transfer out 0,1
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

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

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

let param = {
    "amount":"0.01",
    "symbol":"BTC",
    "type":0
};

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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

// Response
{
    "state":0, // success
    "result":"352559634189422592"  // ignore
}
{
    "state":3016, // failed
    "msg":"交易对错误"
}

Place an order

Name Necessary or not Type Description Default Value Range
pair true string pair 5BTC_USD,5ETH_USD, ...
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 target price
order_from true integer order from 6
client_oid false string client order id
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

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

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

let param = {
    "pair":"5BTC_USD",
    "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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

// Response
{
    "state":0,
    "order_id":"425510999949316", // order id
    "client_oid":"1234567890", // client order id
    "status":1, // order status,1 uncompleted, 2 partially completed, 3 completely completed, 4 partially cancelled, 5 completely cancelled, 100 failed to place an order
    "cmd":"open" // ignore
}

Cancel order

Name Necessary or not Type Description Default Value Range
order_id true string order id
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbc/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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

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

Batch cancellation

Name Necessary or not Type Description Default Value Range
order_ids true array array of order id
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbc/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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

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

Cancel all orders

Name Necessary or not Type Description Default Value Range
pair true string pair 5BTC_USD,5ETH_USD, ...
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

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

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

let param = {
    "pair":"5BTC_USD"
};

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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

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

Adjust margin on a fixed position

Name Necessary or not Type Description Default Value Range
pair true string pair 5BTC_USD,5ETH_USD, ...
margin true string margin
side true integer position side, 1 long side, 2 short side 1,2
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

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

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

let param = {
    "pair":"5BTC_USD",
    "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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

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

Adjust position mode and leverage

Name Necessary or not Type Description Default Value Range
pair true string pair 5BTC_USD,5ETH_USD, ...
mode true integer position mode, 1 cross, 2 fi 1,2
leverage_long true integer Long leverage 1~100
leverage_short true integer Short leverage 1~100
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

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

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

let param = {
    "pair":"5BTC_USD",
    "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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

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

Query assets

Name Necessary or not Type Description Default Value Range
coin false string coin symbol BTC,ETH,...
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

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

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

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

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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

// Response
{
    "state":0,
    "result":[
        {
            "b":"1", // Available Balance
            "c":"BTC", // coin symbol
            "u":100006, // user id
            "f":"0", // Frozen funds
            "m":"0" // Margin
        },
        {
            "b":"1",
            "c":"ETH",
            "u":100006,
            "f":"0",
            "m":"0"
        }
    ],
    "cmd":"assets"
}

Query position

Name Necessary or not Type Description Default Value Range
pair false string pair 5BTC_USD,5ETH_USD, ...
side false integer position side, 1 long side, 2 short side 1,2
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

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

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

let param = {
    // "pair":"5BTC_USD",
    // "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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

// 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",// Closable position price
            "pi":"5BTC_USD", // pair
            "mg":"0", //margin
            "hc":"0",// Position value
            "fb":"0",//ignore
            "po":"0" //Opening price
        },
        ...
    ],
    "cmd":"position"
}

Query order list

Name Necessary or not Type Description Default Value Range
pair false string pair 5BTC_USD,5ETH_USD, ...
order_side true integer order side,1 open long, 2 open short, 3 close long, 4 close short 1,2,3,4
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

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

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

let param = {
    // "pair":"5BTC_USD",
    // "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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

// Response
{
    "state":0,
    "result":{
        "p":1,
        "t":1,
        "o":[
            {
                "f":"0", //fee
                "dp":"0", //deal price
                "eq":"0", //deal  amount
                "p":"11092", //target 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":"5BTC_USD", //pair
                "oi":"426610511577093", // order id
                "coi":"1602679943911", //clientoid
                "fb":"0", //bix deduction
                "po":false //ignore
            },
            ...
        ]
    },
    "cmd":"orderList"
}

Checking order

Name Necessary or not Type Description Default Value Range
order_id true string order id
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbc/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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

// Response
{
    "state":0,
    "result":{
        "f":"0", //fee
        "dp":"0", //deal price
        "eq":"0", //deal  amount
        "p":"11092", //target 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":"5BTC_USD", //pair
        "oi":"426610511577093", // order id
        "coi":"1602679943911", //clientoid
        "fb":"0", //bix deduction
        "po":false //ignore
    },
    "cmd":"orderDetail"
}

Bulk query order list

Name Necessary or not Type Description Default Value Range
order_ids true array array of order id
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbc/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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

// Response
{
    "state":0,
    "result":[
        {
             "f":"0", //fee
            "dp":"0", //deal price
            "eq":"0", //deal amount
            "p":"11092", //target 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":"5BTC_USD", //pair
            "oi":"426610511577093", // order id
            "coi":"1602679943911", //clientoid
            "fb":"0", //bix deduction
            "po":false //ignore
        }
    ],
    "cmd":"orderListBatch"
}

Batch query order list according to clientoid

Name Necessary or not Type Description Default Value Range
order_ids true array array of client order id
  • example
let CryptoJS = require("crypto-js");
let request = require("request");

let url = "https://api.bibox.com/v3/cbc/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: {//Request headers
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        },
        body: cmd//Request parms string
    },

    function optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log({
            url,
            'content-type': 'application/json',
            'bibox-api-key': apikey,
            'bibox-api-sign': sign,
            'bibox-timestamp': timestamp
        });
        console.log(body)

    });

Response

// Response
{
    "state":0,
    "result":[
        {
             "f":"0", //fee
            "dp":"0", //deal price
            "eq":"0", //deal amount
            "p":"11092", //target 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":"5BTC_USD", //pair
            "oi":"426610511577093", // order id
            "coi":"1602679943911", //clientoid
            "fb":"0", //bix deduction
            "po":false //ignore
        }
    ],
    "cmd":"orderListBatchByCLientOid"
}

Get server time

Response

// Response
{
    "time":"1602680518605"
}
Copyright © bibox.com 2019 all right reserved,powered by GitbookUpdate Date: 2020-10-30

results matching ""

    No results matching ""