九.API文档
域名为: https://api.hb.top
一、文档说明
Example:
Java_Demo Download Python3.6_Demo Download例:
https://api.hb.top/api/v1/getAccountBalance?nonce=1511872841898&ticker=btc&userCode=EA8DA5A29BDEBFFE5202CF61E262233C&signature=aEyDq1Ph8SIO8zLoexILIZmkHocCbaIOyepVHJAxuzQQT9uJNyeFodGI6h1v0iB24%2FTMmLdej%2Fy0qnJyXWMBz71F%2B5EU3WwablLpPe8JnNP8eSsXuOyxmeMK2wUIPQ%2BxqJEkneQ5oa866rwUj5tpzSFu97eCCUfn4NU9%2BqoA0W4%3D
二、接口说明
private API
1.1功能描述
url | method | description |
---|
api/v1/ addTrade | POST | 挂单 |
1.2接口参数
名称 | 类型 | 是否必须 | 说明 |
---|
userCode | String | Y | 用户名唯一标识 |
market | String | Y | 市场币种(小写) |
nonce | Long | Y | 当前时间 |
price | BigDecimal | Y | 挂单价格 |
qty | BigDecimal | Y | 挂单数量 |
ticker | String | Y | 币种(小写) |
type | String | Y | 挂单类型(买单:buy;卖单:sell) |
signature | String | Y | 是将userCode market nonce price qty ticker type等参数排序后通过'&'字符连接起来通过私钥为key进行RSA算法加密得到的值 |
1.3返回数据
格式如下:
{
"code":0,
"msg":"",
"detailMsg":"",
"data":{
"id":"6548234"
}
}
1.4备注
code含义:0:成功, 1:参数错误
2.1功能描述
url | method | description |
---|
api/v1/getAccountBalance | POST | 获取账户余额 |
2.2接口参数
名称 | 类型 | 是否必须 | 说明 |
---|
userCode | String | Y | 用户名唯一标识 |
nonce | Long | Y | 当前时间 |
ticker | String | N | 币种,当有值时查询该单一币种余额,默认查询全部币种余额 |
signature | String | Y | 是将userCode nonce ticker等参数按顺序通过'&'字符连接起来通过私钥为key进行RSA算法加密得到的值 |
2.3返回数据
格式如下:
{
“code”: 0,
“msg”: “”,
“detailMsg”: “”,
“data”: {
“data”:[{“ticker”: “btc”, “balance”: “0.98765432”, “frozenbalance”: “0.12345678”},{……},{……},……]
}
}
2.4备注
code含义: 0:成功, 1:参数错误
3.1功能描述
url | method | description |
---|
api/v1/getOrderList | POST | 获取挂单记录 |
3.2接口参数
名称 | 类型 | 是否必须 | 说明 |
---|
userCode | String | Y | 用户名唯一标识 |
market | String | Y | 市场币种(小写) |
ticker | String | Y | 币种(小写) |
nonce | Long | Y | 当前时间 |
signature | String | Y | 是将userCode nonce等参数按顺序通过'&'字符连接起来通过私钥为key进行RSA算法加密得到的值 |
3.3返回数据
格式如下:
{
“code”: 0,
“msg”: “”,
“detailMsg”: “”,
“data”: {
“list”:[{ “id”: “100000”, “date”: “2017-11-23 11:24”, “price”: “7800.12345678”, “totalVolume”: “1.2345”, “type”: “1”, “tradedVolume”: “0.0000”, “unsettledVolume”: “1.2345”},{……},{……},……]
}
}
3.4备注
code含义: 0:成功, 1:参数错误
type含义: 0:卖单, 1:买单
4.1功能描述
url | method | description |
---|
api/v1/cancelOrder | POST | 取消挂单 |
4.2接口参数
名称 | 类型 | 是否必须 | 说明 |
---|
userCode | String | Y | 用户唯一标识 |
orderId | String | Y | 挂单id |
nonce | Long | Y | 当前时间 |
signature | String | Y | 是将userCode id nonce等参数按顺序通过'&'字符连接起来通过私钥为key进行RSA算法加密得到的值 |
4.3返回数据
格式如下:
{
“code”: 0,
“msg”: “”,
“detailMsg”: “”
}
4.4备注
code含义: 0:成功, 1:参数错误
public API
5.1功能描述
url | method | description |
---|
api/v1/getDepth | POST | 获取深度数据 |
5.2接口参数
名称 | 类型 | 是否必须 | 说明 |
---|
symbol | String | Y | 币种_市场 |
num | int | Y | 深度数据条数(20,50,100),默认100 |
5.3返回数据
格式如下:
{
“code”: 0,
“msg“: “”,
“detailMsg”: “”,
“data”:{
“buy”:{[“price”:1.23456789, “volume”:1, “marketAmount”: “1.23456789”],[……],……}
},“sell”:{ “price”:2.34567890, “qty”:2, “marketAmount”: “4.6913578”],[……],……}
}
5.4备注
code含义: 0:成功, 1:参数错误
6.1功能描述
url | method | description |
---|
api/v1/getPrice | POST | 24小时内成交信息 |
6.2接口参数
名称 | 类型 | 是否必须 | 说明 |
---|
market | String | Y | 市场 |
ticker | String | Y | 币种 |
6.3返回数据
格式如下:
{
“code”: 0,
“msg”: “”,
“detailMsg”: “”,
“data”:{
“buy”: “0.00835616”, “sell”: “0.00891424”, “high”: “0.00891424”, “low”: “0.00876002”, “last”: “0.00878529”, “volume”: “2870.83540000”
}
6.4备注
code含义: 0:成功, 1:参数错误
7.1功能描述
url | method | description |
---|
api/v1/tickers | POST | 24小时内价格信息 |
7.2接口参数
7.3返回数据
Field | DataType | description |
---|
buy | String | 买一价 |
sell | String | 卖一价 |
high | String | 24小时最高 |
low | String | 24小时最低 |
last | String | 收盘价 |
volume | String | 24小时成交量 |
symbol | String | 交易对 |
格式如下:
{
"code": 0,
"msg": "",
"detailMsg": "",
"data": {
"buy": "0.10826495", "sell": "0.13400000", "high": "0.12853050", "low": "0.12677050", "last": "0.12785700", "volume": "2398.0202", "symbol": "bch_btc"
}
7.4备注
code含义: 0:成功, 1:参数错误
8.1功能描述
url | method | description |
---|
api/v1/markets | POST | 平台所有开放的交易对 |
8.2接口参数
8.3返回数据
Field | DataType | description |
---|
bch_btc | String | 交易币种BCH,交易市场BTC |
格式如下:
{
"code": 0,
"msg": "",
"detailMsg": "",
"data": {
"bch_btc": { "amountScale": 0, "priceScale": 0 },
"eth_btc": { "amountScale": 0, "priceScale": 0 }
}
8.4备注
code含义: 0:成功, 1:参数错误
9.1功能描述
url | method | description |
---|
/api/v1/trades | GET | 成交记录接口 |
9.2接口参数
名称 | 类型 | 是否必须 | 说明 |
---|
symbol | string | Y | 交易对(ltc_btc) |
size | Integer | N | 条数(默认值600, 最多600条) |
9.3返回数据
Field | DataType | description |
---|
date | String | 交易时间 |
date_ms | String | 交易时间(ms) |
price | String | 交易价格 |
amount | String | 交易数量 |
tid | String | 交易生成ID |
type | String | buy/sell |
格式如下:
{
"code": 0,
"msg": "",
"detailMsg": "",
"data": [
{
"date": "1531967566",
"date_ms": "1531967566000",
"price": "428.62",
"amount": "0.6956",
"tid": "14338342",
"type": "buy"
},
{
"date": "1531967331",
"date_ms": "1531967331000",
"price": "428.03",
"amount": "2.5692",
"tid": "14338341",
"type": "buy"
},
{
"date": "1531967311",
"date_ms": "1531967311000",
"price": "429.41",
"amount": "2.3991",
"tid": "14338340",
"type": "buy"
}
]
}
9.4备注
code含义: 0:成功, 1:参数错误
10.1功能描述
url | method | description |
---|
/api/v1/kline | GET | K线接口 |
10.2接口参数
名称 | 类型 | 是否必须 | 说明 |
---|
symbol | string | Y | 交易对(ltc_btc) |
type | string | Y | 目前只支持1min数据(1min) |
size | Integer | N | 条数(默认2000条) |
10.3返回数据
格式如下:
{
"code": 0,
"msg": "",
"detailMsg": "",
"data": [
[
1531907700000, // timestamp
498.55, // open
498.55, // high
498.55, // close
498.55, // low
1 // volume
]
]
}
10.4备注
code含义: 0:成功, 1:参数错误
11.1功能描述
url | method | description |
---|
/api/v1/order | GET | 通过挂单id获取挂单详情 |
11.2接口参数
名称 | 类型 | 是否必须 | 说明 |
---|
orderId | string | Y | 挂单id |
userCode | string | Y | 用户唯一标识 |
nonce | Long | Y | 当前时间 |
signature | String | Y | #google_onoff将orderId,userCode, nonce等参数按顺序通过'&'字符连接起来通过私钥为key进行RSA算法加密得到的值 |
11.3返回数据
格式如下:
{
"code": 0,
"msg": "",
"detailMsg": "",
"data": {
"account-id": "144262", // account id
"id": "7367307264", // order id
"amount": "2.00000000", // qty
"price": "696.00000000", // price
"created-at": 1535091838000, // order time
"field-amount": "0E-8", // field amount
"field-cash-amount": "0E-8", // field total amount
"source": 0,
"state": 0, // state (0 submitted, 1 partical-filled, 2 cancelling)
"symbol": "eth_usdt", // pair(coin_market)
"type": 0 //type(0:sell, 1:buy)
}
}
11.4备注
code含义: 0:成功, 1:参数错误