API文档

币龙网客服 - 2019年03月18日 r 11:13:31 CST

REST API使用说明

https://www.bitalong.com

 

入门指引

欢迎使用Bitalong开发者文档。此文档目前为Ver1.0版本,会继续更新,请及时关注。

此文档为用户提供了一整套简单而又强大的开发接口,旨在帮助用户快速、高效地将Bitalong交易功能整合到自己的应用当中。

API接口分为公共和私有方法两类,公共方法接口不需要用户身份鉴权,私有方法接口需要用户身份鉴权。

 

鉴权

进行鉴权之前,需要先申请自己的API Key。API Key用于保护数据的完整性和安全性。

用户首先使用WEB方式登录www.bitalong.com,在“安全中心/API Key”下申请自己的api key。api key是一对密钥,包含key和secret。

使用secret,对请求的post数据进行sha512 hash签名,签名后的数据做为SIGN,并将key做为KEY,添加到请求的HTTP header当中。PHP示例代码如下:

$post_data = http_build_query($req, ‘’, ‘&’);
         $sign = hash_hmac(‘sha512’, $post_data, $secret);
         $headers = array(
         ‘KEY: ‘.$key,
         ‘SIGN: ‘.$sign
         );
         static $ch = null;
         if (is_null($ch)) {
                   $ch = curl_init();
                   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                   curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/4.0 (compatible; bitalong PHP bot; ‘.php_uname(‘a’).’; PHP/‘.phpversion().’)’);
         }

curl_setopt($ch, CURLOPT_URL, https://mk.bitalong.com/api/'.$path);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

$res = curl_exec($ch);

 

公共API方法

请注意,每秒向公共API发出超过6次呼叫,或者反复且不必要地获取过多数据,可能会导致您的IP被禁止。

有七个公共方法,所有这些方法都采用HTTP GET请求并以JSON格式返回输出:

 

  •  pairs

地址: https://www.bitalong.com/api/index/pairs

参数:无

获取市场所有的交易对,例如:

 

["btc_usdt","bch_usdt","ltc_usdt","eth_usdt","etc_usdt","zec_usdt","xmr_usdt","dash_usdt","doge_usdt","qtum_usdt","eos_usdt","ae_usdt","zil_usdt","ae_btc","zil_btc","pivx_btc","dero_btc","ltc_btc","bch_btc","eth_btc","zec_btc","xmr_btc","dash_btc","doge_btc","qtum_btc","eos_btc","etn_btc"]

 

  •  tickers

地址:  https://www.bitalong.com/api/index/tickers

参数:无

返回市场所有的交易行情信息,例如:

{

         "btc_usdt": {

                  "result": "true",

                  "last": "6739.4042",

                  "lowestAsk": "6753.4800",

                  "highestBid": "6726.5100",

                  "percentChange": "-2.59",

                  "baseVolume": "435.4103",

                  "quoteVolume": "2968554.2683",

                  "high24hr": "6951.0471",

                  "low24hr": "6655.0953"

         },

         "bch_usdt": {

                  "result": "true",

                  "last": "468.2111",

                  "lowestAsk": "469.0969",

                  "highestBid": "466.8883",

                  "percentChange": "-1.90",

                  "baseVolume": "4791.6736",

                  "quoteVolume": "2220615.8794",

                  "high24hr": "482.0203",

                  "low24hr": "461.1908"

         }

}

 

  • ticker

地址: https://www.bitalong.com/api/index/ticker/btc_usdt

参数:pair名称,例如btc_usdt

返回指定 "[pair]"参数的行情, 例如:

{

         "result": "true",

         "last": "6738.7654",

         "lowestAsk": "6752.2375",

         "highestBid": "6724.7136",

         "percentChange": "-2.60",

         "baseVolume": "435.5750",

         "quoteVolume": "2968554.2683",

         "high24hr": "6951.0471",

         "low24hr": "6655.0953"

}

 

  • orderBook

地址: https://www.bitalong.com/api/index/orderBook/btc_usdt

参数:pair名称,例如btc_usdt

返回指定交易对的市场交易深度信息,例如:

{

         "result": "true",

         "asks": [

                  ["6787.1294", "0.1406"],

                  ["6785.6183", "0.4705"],

                  ["6784.1071", "0.6442"],

                  ["6782.5960", "0.2962"],

                  ["6781.0848", "0.3315"],

                  ["6779.5737", "0.3443"],

                  ["6778.0626", "0.0449"],

                  ["6776.5514", "0.6736"],

                  ["6775.0403", "0.4739"],

                  ["6755.7266", "0.1160"],

                  ["6754.6033", "0.1198"],

                  ["6753.4800", "0.1185"]

         ],

         "bids": [

                  ["6725.9412", "0.1198"],

                  ["6724.8179", "0.1199"],

                  ["6723.6947", "0.1192"],

                  ["6705.0786", "0.0345"],

                  ["6704.3945", "0.0572"],

                  ["6703.7105", "0.0054"],

                  ["6703.5750", "0.0483"],

                  ["6702.0638", "0.0095"],

                  ["6700.5527", "0.0170"],

                  ["6699.0415", "0.0138"],

                  ["6697.5304", "0.0287"],

                  ["6696.0193", "0.0505"]

         ]

}

 

  • tradeHistory

地址: https://www.bitalong.com/api/index/tradeHistory/btc_usdt

参数:pair名称,例如btc_usdt

返回指定交易对的最近80笔交易记录,例如:

  {

    "result": "true",

    "data": [

        {

            "tradeID": "21314854",

            "date": "2018-10-15 15:37:49",

            "type": "sell",

            "rate": "7078.6576",

            "amount": 0.01,

            "total": 70.786576

        },

        {

            "tradeID": "21314822",

            "date": "2018-10-15 15:37:28",

            "type": "buy",

            "rate": "7090.1246",

            "amount": 0.097,

            "total": 687.742086

        }

    ],

    "elapsed": "0.0008ms"

}

  • marketinfo

地址: https://www.bitalong.com/api/index/marketinfo

参数:无

返回市场所有交易对的配置信息,包括小数精度,最小交易额,买卖手续费,例如:

    "result": "true",

    "pairs": {

        "eth_btc": {

            "decimal_places": "8",

            "min_amount": "0.00002",

            "fee_buy": "0.2",

            "fee_sell": "0.2"

        },

        "ltc_btc": {

            "decimal_places": "8",

            "min_amount": "0.00001",

            "fee_buy": "0.2",

            "fee_sell": "0.2"

        },

        "xmr_btc": {

            "decimal_places": "8",

            "min_amount": "0.00002",

            "fee_buy": "0.2",

            "fee_sell": "0.2"

        },

        "ltc_eth": {

            "decimal_places": "6",

            "min_amount": "0.000001",

            "fee_buy": "0.2",

            "fee_sell": "0.2"

        },

        "xmr_eth": {

            "decimal_places": "6",

            "min_amount": "0.000001",

            "fee_buy": "0.2",

            "fee_sell": "0.2"

        },

        "dash_btc": {

            "decimal_places": "8",

            "min_amount": "0.00001",

            "fee_buy": "0.2",

            "fee_sell": "0.2"

        }

    }

}

  • marketlist

地址: https://www.bitalong.com/api/index/marketlist

参数:无

返回市场所有交易对的行情信息,包括最新价格,交易量、涨跌幅等,例如:

    {

    "result": "true",

    "data": [

        {

            "no": 1,

            "symbol": "btc",

            "name": "BTC",

            "name_en": "BTC",

            "name_cn": "BTC",

            "pair": "btc_usdt",

            "rate": 7268.8463,

            "vol_a": 557.8176,

            "vol_b": "3707522.8190",

            "curr_a": "btc",

            "curr_b": "usdt",

            "curr_suffix": "usdt",

            "rate_percent": "14.02",

            "trend": "up"

        },

        {

            "no": 2,

            "symbol": "bch",

            "name": "BCH",

            "name_en": "BCH",

            "name_cn": "BCH",

            "pair": "bch_usdt",

            "rate": 499.558,

            "vol_a": 5747.31,

            "vol_b": "2701870.1639",

            "curr_a": "bch",

            "curr_b": "usdt",

            "curr_suffix": "usdt",

            "rate_percent": "10.04",

            "trend": "up"

        }

    ]

}

 

 

私有API方法

私有接口可用于订单管理和账户管理。每个私有请求必须使用规范的验证形式进行签名。私有接口需要使用您的API key进行验证。

 

  • balances

地址: https://www.bitalong.com/api/private/balances

请求方式:POST

参数:无

返回用户账户资金余额,包括可用余额和冻结余额。例如:

      {

        "result": "true",

        "available": {

            "BTC": "1000",

            "ETH": "968.8",

            "ETC": "0",

            },

        "locked": {

            "ETH": "1"

            }

    }

 

  • buy

地址: https://www.bitalong.com/api/private/buy

请求方式:POST

参数:

参数名

必须

类型

说明

currencyPair

string

交易币种对

(如ltc_btc,ltc_btc)

rate

string

价格

amount

string

数量

 

下单买入,只有当您的账户有足够的资金才能下单。返回结果如下:

{

        "result":"true",

        "orderNumber":"123456",

        "code":"0",

        "message":"Success"

}

 

  • sell

地址: https://www.bitalong.com/api/private/sell

请求方式:POST

参数:

参数名

必须

类型

说明

currencyPair

string

交易币种对(如ltc_btc,ltc_btc)

rate

string

价格

amount

string

数量

 

下单卖出,只有当您的账户有足够的资金才能下单。返回结果如下:

{

        "result":"true",

        "orderNumber":"123456",

        "code":"0",

        "message":"Success"

}

 

  • cancelOrder

地址: https://www.bitalong.com/api/private/cancelOrder

请求方式:POST

参数:

参数名

必须

类型

说明

orderNumber

string

订单编号

currencyPair

string

交易币种对

(如 ltc_btc)

 

取消指定的订单。返回结果如下:

{"result":"true","message":"Success"}

 

  • cancelAllOrders

地址: https://www.bitalong.com/api/private/cancelAllOrders

请求方式:POST

参数:

参数名

必须

类型

说明

currencyPair

string

交易币种对

(如ltc_btc,ltc_btc)

type

int

下单类型

(0:卖出,1:买入,-1:不限制)

取消指定交易对的所有订单。返回结果如下:

 {"result":"true","message":"Success"}

 

  • getOrder

地址: https://www.bitalong.com/api/private/getOrder

请求方式:POST

参数:

参数名

必须

类型

说明

currencyPair

string

交易币种对

(如ltc_btc,ltc_btc)

type

int

下单类型(0:卖出,1:买入,-1:不限制)

获取下单状态。返回结果如下:

  {

        "result":"true",

        "order":{

            "orderNumber":"15088",

            "status":"cancelled",

            "currencyPair":"eth_btc",

            "type":"sell",

            "amount":"0.39901357",

            "initialRate":811,

            "initialAmount":"1"

            },

        "message":"Success"

}

 

  • openOrders

地址: https://www.bitalong.com/api/private/openOrders

请求方式:POST

参数:无

获取账户最近1024条未完成订单,按时间倒序返回。返回结果如下:

  {

        "result": "true", "message": "Success", "code": 0,"elapsed": "6.262ms",

        "orders": [

                {

                "orderNumber": "30032151",

                "type": "buy",

                "amount": "0.0936",

                "total": "2000",

                "initialRate": 21367.521367521,

                "initialAmount": "0.0936",

                "filledAmount": 0,

                "currencyPair": "eth_btc",

                "timestamp": "1407828913",

                "status": "open"

                }

            ]

        }

 

  • tradeHistory

地址: https://www.bitalong.com/api/private/tradeHistory

请求方式:POST

参数:

参数名

必须

类型

说明

currencyPair

string

交易币种对

获取账呢24小时内成交记录。返回结果如下:

  {

        "result": "true",

        "message": "Success",

        "trades": [

                {

                "id": "7942422",

                "orderid": "38100491",

                "pair": "ltc_btc",

                "type": "buy",

                "rate": "0.01719",

                "amount": "0.0588",

                "time": "06-12 02:49:11",

                "time_unix": "1402512551"

                }

            ]

}

 

  • withdraw

地址: https://www.bitalong.com/api/private/withdraw

请求方式:POST

参数:

参数名

必须

类型

说明

currency

string

提现币种(如:btc)

amount

string

提现数量

address

string

提现地址(如:1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs)

发起指定币种的提现请求。返回结果如下:

  {"result": "true",  "message": "Success"}

 

  • depositAddress

地址: https://www.bitalong.com/api/private/depositAddress

请求方式:POST

参数:

参数名

必须

类型

说明

currency

string

币种 如(BTC, LTC)

获取充值地址。返回结果如下:

  {

        "result": "true",

        "addr": "LPXtk1kWHioP62SzfqwKbYE3Z7Wt2ujYEc",

        "message": "Sucess",

        "code": 0

}

 

  • depositsWithdrawals

地址: https://www.bitalong.com/api/private/depositsWithdrawals

请求方式:POST

参数:

参数名

必须

类型

说明

start

string

起始UNIX时间

(如 1469092370)

end

string

终止UNIX时间

(如 1469713981)

获取账户所有币种的充值提现历史。返回结果如下:

  {

        "result": "true",

        "deposits": [

                {

                "id": "c204730",

                "currency": "ETH",

                "address": "1111 1111 1111 1111 1111 1",

                "amount": "222.61",

                "txid": "210496",

                "timestamp": "1474962729",

                "status": "DONE"

                }

            ],

        "withdraws": [

                {

                "currency": "ETC",

                "address": "addr2",

                "amount": "600000000",

                "txid": "2104963",

                "timestamp": "1469092378",

                "status": "DONE"

                }

            ],

        "message": "Success"

}

 

评论

登录 添加您的评论。