一、API使用说明


         1、请求过程说明

2、安全认证

3、接口

3.1 获取当前最新行情 - Ticker

3.2 市场深度 - Depth

3.3 最近的市场交易 - Orders

3.4 获取所有币种最新行情 - AllTicker

3.5 账户信息 - Account Balance

3.6 挂单查询 - Trade_list

3.7 查询订单信息 - Trade_view

3.8 取消订单 - Trade_cancel

3.9 下单 - Trade_add

4.0 错误代码对照表


二、API实例代码


一、API使用说明

1、请求过程说明

1.1 构造请求数据,用户数据按照Jubi提供的接口规则,通过程序生成签名和要传输给Bit-k的数据集合;

1.2 发送请求数据,把构造完成的数据集合通过POST/GET提交的方式传递给Bit-k

1.3 Bit-k对请求数据进行处理,服务器在接收到请求后,会首先进行安全校验,验证通过后便会处理该次发送过来的请求;

1.4 返回响应结果数据,Bit-k把响应结果以JSON的格式反馈给用户,具体的响应格式,错误代码参见接口部分;

1.5 对获取的返回结果数据进行处理.


2、安全认证

所有的private API都需要经过认证

Api的申请可以到财务中心 -> API,申请得到私钥和公钥,私钥Bit-k将不做储存,一旦丢失将无法找回

注意:请勿向任何人泄露这两个参数,这像您的密码一样重要


3、签名机制

每次请求private api 都需要验证签名,发送的参数示例:

$param = array(

amount => 1,

price => 10000,

type => 'buy',

nonce => 141377098123

key => 5zi7w-4mnes-swmc4-egg9b-f2iqw-396z4-g541b

signature => 459c69d25c496765191582d9611028b9974830e9dfafd762854669809290ed82

);

nonce 可以理解为一个递增的整数:http://zh.wikipedia.org/wiki/Nonce

key 是申请到的公钥

signature是签名,是将amount price type nonce key等参数通过'&'字符连接起来通过md5(私钥)为key进行sha256算法加密得到的值.


4、接口

Ticker(牌价)

Path:/api/v1/ticker/

Request类型:GET

参数

· coin - 币种简称,例如btc、ltc、xas

返回JSON dictionary

· high - 最高价

· low - 最低价

· buy - 买一价

· sell - 卖一价

· last - 最近一次成交价

· vol - 成交量

· volume - 成交额

返回结果示例:

· {"high":22,"low":20,"buy":1.879,"sell":0,"last":38800,"vol":283.954}

Depth(市场深度)

描述:返回所有的市场深度,此回应的数据量会较大,所以请勿频繁调用。

Path:/api/v1/depth/

Request类型:GET

参数

· coin - 币种简称,例如btc、ltc、xas

返回JSON dictionary

· asks - 委买单[价格, 委单量],价格从高到低排序

· bids - 委卖单[价格, 委单量],价格从高到低排序

返回结果示例:

· {"asks":[[70000,5],[69000,0.48],[67000,0.9999],[64498,0.02],[61160,0.017],[60980,0.03],[60000,0.1924],[55900,1.4],[55100,2],[55044,0.019],[54500,0.7836],[54190,1],[52500,5.8645],[51500,5.6594],[51490,0.02],[47500,7],[45999,0.0244],[44585,0.024],[43000,10],[41700,10],[41300,6],[40900,10],[40500,6],[40125,10.0277],[40100,5],[40089,0.509],[39800,14.7132],[39799,0.0695],[39798,5],[39700,2.89],[39000,0.209]],"bids":[[38300,1.879],[38100,1.0078],[38000,1.24],[37700,4.706],[37600,3.8313],[37001,0.146],[36999,5.8],[36400,5],[36200,1.3314],[36002,2],[36000,1.568],[35501,0.282],[35500,9.9],[35200,5.6],[35010,10],[35001,0.03],[34600,7.6],[34500,5.505],[34200,9.3],[34000,6.4],[33800,4.434],[33333,3],[32830,0.0305],[31800,2],[31500,3.018],[30001,0.03],[30000,11.48],[28000,10],[25001,0.04],[22000,5.863],[20001,0.05],[460,10]]}

Orders(市场交易)

描述:返回100个最近的市场交易,按时间倒序排列,此回应的数据量会较大,所以请勿频繁调用。

Path:/api/v1/orders/

Request类型:GET

参数

· coin - 币种简称,例如btc、ltc、xas

返回JSON dictionary

· date - 时间戳

· price - 交易价格

· amount - 交易数量

· tid - 交易ID

· type - 交易类型

返回结果示例:

· [{"date":"0","price":3,"amount":0.1,"tid":"1","type":"buy"},{"date":"0","price":32323,"amount":2,"tid":"2","type":"sell"},{"date":"0","price":32,"amount":432,"tid":"3","type":"sell"},{"date":"0","price":323,"amount":2,"tid":"4","type":"sell"},{"date":"0","price":2100,"amount":0.3,"tid":"5","type":"buy"}]

AllTicker(全部币种牌价)

Path:/api/v1/allticker/

Request类型:GET

返回JSON dictionary

· high - 最高价

· low - 最低价

· buy - 买一价

· sell - 卖一价

· last - 最近一次成交价

· vol - 成交量

· volume - 成交额

返回结果示例:

· {"ltc":{"high":217.68,"low":191.11,"buy":200.03,"sell":201.05,"last":200.03,"vol":34889,"volume":7147420},"btc":{"high":19540,"low":17000,"buy":17549.97,"sell":17549.98,"last":17549.97,"vol":366,"volume":6661461}}

只读权限方法列表

Account Balance(账户信息)

列举您的帐户信息

Path:/api/v1/balance/

Request类型:POST

参数

· key - API key

· signature - signature

· nonce - nonce

返回JSON dictionary

· asset - 折合人民币总余额

· cny_balance - 人民币总余额

· ltc_balance - 比特币总余额

· cny_lock - 人民币冻结余额

· ltc_lock - 比特币冻结余额

· ............

· nameauth - 实名认证状态 0 未实名 1 等待确认 2 已经认证成功

· moflag - 手机绑定状态 0 未绑定 1 绑定

返回结果示例:

· {"uid":8,"nameauth":0,"moflag":0,"doge_balance":4234234,"doge_lock":0,"ltc_balance":32429.6,"ltc_lock":2.4,"xpm_balance":0,"xpm_lock":0,"cny_balance":2344581.519,"cny_lock":868862.481}

Trade_list(挂单查询)

您指定时间后的挂单,可以根据类型查询,比如查看正在挂单和全部挂单

Path:/api/v1/trade_list/

Request类型:POST

参数

· key - API key

· signature - signature

· nonce - nonce

· since - unix timestamp(utc timezone) default == 0, i.e. 返回所有

· coin - 币种简称,例如btc、ltc、xas

· type - 挂单类型[open:正在挂单, all:所有挂单]

返回JSON dictionary

· id - 挂单ID

· datetime - date and time

· type - "buy" or "sell"

· price - price

· amount_original - 下单时数量

· amount_outstanding - 当前剩余数量

返回结果示例:

· [{"id":"11","datetime":"2014-10-21 10:47:20","type":"sell","price":42000,"amount_original":1.2,"amount_outstanding":1.2},{"id":"10","datetime":"2014-10-20 13:29:39","type":"sell","price":42000,"amount_original":1.2,"amount_outstanding":1.2},{"id":"9","datetime":"2014-10-20 13:29:29","type":"sell","price":42000,"amount_original":1.2,"amount_outstanding":1.2},{"id":"8","datetime":"2014-10-20 13:28:14","type":"buy","price":42800,"amount_original":0.34,"amount_outstanding":0.34},{"id":"7","datetime":"2014-10-20 13:27:38","type":"buy","price":42750,"amount_original":0.235,"amount_outstanding":0.235},{"id":"6","datetime":"2014-10-20 13:27:15","type":"buy","price":43299,"amount_original":4.789,"amount_outstanding":4.789},{"id":"5","datetime":"2014-10-20 13:26:52","type":"buy","price":42500,"amount_original":14,"amount_outstanding":14},{"id":"4","datetime":"2014-10-20 13:26:23","type":"buy","price":43200,"amount_original":0.4813,"amount_outstanding":0.4813},{"id":"3","datetime":"2014-10-20 13:25:57","type":"buy","price":43200,"amount_original":0.4813,"amount_outstanding":0.4813}]

Trade_view(查询订单信息)

Path:/api/v1/trade_view/

Request类型:POST

参数

· key - API key

· signature - signature

· nonce - nonce

· id - 挂单ID

· coin - 币种简称,例如btc、ltc、xas

返回JSON dictionary

· id - 挂单ID

· datetime - 挂单时间(格式:YYYY-mm-dd HH:ii:ss)

· type - "buy" or "sell"

· price - 挂单价

· amount_original - 下单时数量

· amount_outstanding - 当前剩余数量

· status - 状态:new(新挂单), open(开放交易), cancelled(撤消), closed(完全成交)

· avg_price - 成交均价

返回结果示例:

· {"id":11,"datetime":"2014-10-21 10:47:20","type":"sell","price":42000,"amount_original":1.2,"amount_outstanding":1.2,"status":"closed"}

完整权限方法列表

Trade_cancel(取消订单)

Path:/api/v1/trade_cancel/

Request类型:POST

参数

· key - API key

· signature - signature

· nonce - nonce

· id - 挂单ID

· coin - 币种简称,例如btc、ltc、xas

返回JSON dictionary

· result - true(成功), false(失败)

· id - 订单ID

返回结果示例:

· {"result":true, "id":"11"}

Trade_add(下单)

Path:/api/v1/trade_add/

Request类型:POST

参数

· key - API key

· signature - signature

· nonce - nonce

· amount - 购买数量

· price - 购买价格

· type - 买单或者卖单

· coin - 币种简称,例如btc、ltc、xas

返回JSON dictionary

· id - 挂单ID

· result - true(成功), false(失败)

返回结果示例:

· {"result":true, "id":"11"}

数据类型

· *_balance - float

· id - int

· datetime - datetime

· since - int

· type - string

· price - float

· amount* - float

· status - string

· trade_id - int

· fee - float

· result - bool

· message - string

· address - string

BIT-K

全球领先的社群数字资产交易平台

服务支持

API文档
上币申请说明
帮助中心
数字资产介绍

关于

费率
公告
关于我们
加入我们

法律

法律声明
隐私条款
用户协议

联系我们

support@bitk.club