Skip to content

REST_Request_Response

zhuyangtao edited this page Nov 4, 2019 · 4 revisions

API Request and Response Format

BiboxEurope REST API parameter standard, supports a batch of requests, please read carefully.

header

  • To prevent replay attacks, all header requests must have a time stamp of the parameter X-Ca-Nonce for API requests
// node.js demo
request.post({
        url: url, form: params, headers: {'X-Ca-Nonce': Date.now()}
    }, function (error, response, body) {
        if (!error && response && response.statusCode === 200) {
            let result = JSON.parse(body);
            callBack(result);
        } else {
            console.log('err: ', error);
            callBack(error);
        }
    });

Request Parameter

  • the request format of requiring apikey
// Request
{
    "cmds": [ // Supporting a batch of requests (different setting of cmd is used for differentiating the result of return)
        {
            "cmd": "orderpending/trade",
            "index": 1234567,
            "body": {
                "pair": "ETH_BTC",
                ... //other parameters
            }
        },
        {
            "cmd": "orderpending/cancelTrade",
            "body": {
                "orders_id": 12345
            }
        }
    ],
    "apikey": "**************", // your apikey
    "sign": "**************" // The result of signing cmds with you apisecret signature (serialized)
}
  • the request format of not requiring apikey
// Request
{
    "cmds": [
        {
            "cmd": "api/ticker",
            "body": {
                "pair": "ETH_BTC"
            }
        },
        
        {
            "cmd": "api/depth",
            "body": {
                "pair": "ETH_BTC",
                "size": 10,
            }
        }
    ]
}

The explanation of parameter

cmds: The encapsulation format of requesting parameter, arraytype, serialized is required when using, each element in array represents an independent API invoking.
cmd: The name of API interface, please refer to API Reference
body: The corresponding request parameter of cmd, please refer to API_Reference
apikey: The apikey alloacated by system
sign: The result of signing cmds (after formatting) with api secret allocated by system

The result of return

  • Request success return
{
    "result":[
        {
            "cmd":"api/pairList",
            "result":[
                {
                    "id":1,
                    "pair":"ETH_BTC"
                },
                {
                    "id":2,
                    "pair":"BTC_EUR"
                }
            ]
        }
    ]
}

The explanation of results

cmd: The name of API interface, please refer to API Reference
result(outside): a batch of requests of returning results, the order consistency is not guaranteed
result(inside): The result of returning specific cmd interface  
  • Request error return
{
    "error":{
        "code":"1000",
        "msg":"something error"
    }
}

The explanation of results

code: error code
msg: The description of error
  • a batch request of returns
{
    "result":[
        { //success
            "cmd":"api/pairList",
            "result":[
                {
                    "id":1,
                    "pair":"ETH_BTC"
                },
                {
                    "id":2,
                    "pair":"BTC_EUR"
                }
            ]
        },
        { //error
            "cmd":"api/depth",
            "error":{
                "code":"1000",
                "msg":"something error"
            }
        }
    ]
}

Example

// Request
{
    "cmds": [
        {
            "cmd": "orderpending/cancelTrade",
            "index": 12345,
            "body": {
                "orders_id": 1000032341
            }
        }
    ],
    "apikey": "**************",
    "sign": "**************"
}

// Response
{
    "result": [{
       "result":"cancelling",
       "index": 12345,
       "cmd":"orderpending/cancelTrade"
   }]
}

Clone this wiki locally