Restful API description

REST API Introduction

Bibox provides a new set of API for users, to help them access Bibox trading system quickly, implementing programmed transaction.

API allows the following functions:

  • View the market information (K line, depth, real-time dealing ticker, 24h market)
  • View the account asset information
  • Order, cancel
  • View order information

REST API Url

https://api.bibox.com

REST API Signature

Apikey is required before using REST API to trade and view assets.

Limited speed strategy: For the same apikey, the api request is 30 times/5 seconds; for the same ip, when the number of cmd requests exceeds 15 for one api, the speed limit will be 1 time / 1 second.

Apply for apikey

  • log in https://www.bibox.com/
  • Accnount information -> API
  • apikey and secret are generated according to the instruction, please keep it carefully

Set apikey operating authorization

Legal request structure

Based on the consideration of safety, all API request must be calculated by signature algorithm except market api. A legel request has the following components

  • APIKEY the apikey you applied。
  • Request Method Body is the cmds in request structure, REST API supports a batch of request, which means cmds can contain multiple mthod bodies, each represents an independent API request, every method has a group of required parameters and optional parameters used for defining API. The parameters and their meanings can be viewed in the description of each method.
  • Signature Method the hash-based protocol of calculating signatures by users, HmacMD5 is applied here.
  • Signature the value calculated by signature is used for ensuring that the signature is valid and not tampered. Please be noted: Signature means signing the value of cmds after formatting!

Example

{
    "cmds": "[{\"cmd\":\"transfer/assets\",\"body\":{\"select\":1}}]",
    "apikey":"5213595xxxxedca0809axxxxxaba7580xxxxxa6",
    "sign":"6a21e39e3f68b6fc2227c4074c7e6a6c" //The result of signing cmds by your apisecret
}

Sign Steps

API request can be tempered at great risk while it is sent through the Internet. To ensure that the request is not tempered, we will require users to sign in every request (except market API) for verifying the authticity of parameters or the values of parameters.

  1. Establish a standard for requests of calculating signatures because when using HMAC to calculate signature, total different results will be achieved as different contents are calculated. So before calculating signatures, please make a standard. Examples of the request of viewing asset detail will be given as follows.
{
    "cmds":[
        {
            "cmd":"transfer/assets",
            "body":{
                "select":1
            }
        }
    ],
    "apikey":"",
    "sign":""
}
  1. formatting cmds
    {
     "cmds": "[{\"cmd\":\"transfer/assets\",\"body\":{\"select\":1}}]", //js用 JSON.stringify()进行格式化
     "apikey":"",
     "sign":""
    }
    
  2. Fill in with the apikey you applied
    {
     "cmds": "[{\"cmd\":\"transfer/assets\",\"body\":{\"select\":1}}]",
     "apikey":"5213595xxxxedca0809axxxxxaba7580xxxxxa6",
     "sign":""
    }
    
  3. Use the apisecret you applied to sign cmds
    {
     "cmds": "[{\"cmd\":\"transfer/assets\",\"body\":{\"select\":1}}]",
     "apikey":"5213595xxxxedca0809axxxxxaba7580xxxxxa6",
     "sign":"6a21e39e3f68b6fc2227c4074c7e6a6c"
    }
    

Calculate signature, please introduces the following 2 parameters into hash function

The character string needed to be calculated with signature

"[{\"cmd\":\"transfer/assets\",\"body\":{\"select\":1}}]"

the apisecret needed to be signed

bxxxxxxxxf1236222xxxxxxxxx6d5d76d5xxxxxxxxx

Acquire the result of signature calculation

6a21e39e3f68b6fc2227c4074c7e6a6c

the example of completed signature

nodejs implements


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

let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret

let param = [
    {
        "cmd": "transfer/assets",
        "body": {
            "select": 1
        }
    }
];
let form = {
    "cmds": JSON.stringify(param), //格式化param
    "apikey": apikey,
    "sign": ""
};

let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign cmds
form.sign = sign;

console.log(form)

output


{
    "cmds":"[{\"cmd\":\"transfer/assets\",\"body\":{\"select\":1}}]",
    "apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
    "sign":"86e88a4bc8eedc795b453f121f5894ee"
}

API Request and Response Format

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

Request Parameter

  • the request format of requiring apikey
// Request
{
    "cmds": JSON.stringify([ // Supporting a batch of requests (different setting of cmd is used for differentiating the result of return)
        {
            "cmd": "orderpending/trade", 
            "index": 1234567,
            "body": {
                "pair": "BIX_BTC",
                ... 
            }
        },
        {
            "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": JSON.stringify([ 
          {
              "cmd": "api/ticker", 
              "body": {
                  "pair": "BIX_BTC"
              }
          },
    
          {
              "cmd": "api/depth", 
              "body": {
                  "pair": "BIX_BTC",
                  "size": 10,
              }
          }
      ])
    }
    
  • The explanation of parameter

name desc
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":"BIX_BTC"
                },
                {
                    "id":2,
                    "pair":"ETH_BTC"
                }
            ]
        }
    ]
}
  • The explanation of results
name desc
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
name desc
code error code
msg The description of error
  • a batch request of returns
{
    "result":[
        { //success
            "cmd":"api/pairList",
            "result":[
                {
                    "id":1,
                    "pair":"BIX_BTC"
                },
                {
                    "id":2,
                    "pair":"ETH_BTC"
                }
            ]
        },
        { //error
            "cmd":"api/depth",
            "error":{
                "code":"1000",
                "msg":"something error"
            }
        }
    ]
}

Example

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

let url = "https://api.bibox.com/v1/transfer";

let apikey = "1e01c22ff8c59e9d98d93423817303f0e7c6d79d"; //your apikey
let secret = "1e01c22ff8c59e9d98d93423817303f098d93423"; //your apikey secret

let param = [
    {
        "cmd": "transfer/assets",
        "body": {
            "select": 1
        }
    }
];
let form = {
    "cmds": JSON.stringify(param), //stringify param
    "apikey": apikey,
    "sign": ""
};

let sign = CryptoJS.HmacMD5(form.cmds, secret).toString();//sign cmds
form.sign = sign;

console.log({url, form})

request.post({url, form }, (error, response, body) => {
    if (!error && response && response.statusCode === 200) {
        try {
            let result = JSON.parse(body);
            console.log(result)
        } catch (error) {
            console.log(error)
        }
    } else {
        console.log(error, response, body);
    }
});

request parameter

{
    "url":"https://api.bibox.com/v1/transfer",
    "form":{
        "cmds":"[{\"cmd\":\"transfer/assets\",\"body\":{\"select\":1}}]",
        "apikey":"1e01c22ff8c59e9d98d93423817303f0e7c6d79d",
        "sign":"86e88a4bc8eedc795b453f121f5894ee"
    }
}

error return

// Response
{
    "error":{
        "code":"3012",
        "msg":"apikey无效"
    }
}

success return

// Response
{
    "result":[
        {
            "result":{
                "total_btc":"3.28811692",
                "total_cny":"201875.67",
                "total_usd":"28847.20",
                "assets_list":[
                    {
                        "coin_symbol":"BTC",
                        "BTCValue":"0.21730559",
                        "CNYValue":"13341.59",
                        "USDValue":"1906.46",
                        "balance":"0.21730558",
                        "freeze":"0.00000000"
                    },
                    {
                        "coin_symbol":"BIX",
                        "BTCValue":"0.03018417",
                        "CNYValue":"1853.17",
                        "USDValue":"264.81",
                        "balance":"62.68909999",
                        "freeze":"0.00000000"
                    }
                ]
            },
            "cmd":"transfer/assets"
        }
    ]
}
Copyright © bibox.com 2019 all right reserved,powered by GitbookUpdate Date: 2019-11-13

results matching ""

    No results matching ""