简介:火币交易所相信大家都比较熟悉了。火币提供了丰富的 API 服务以便分析师投资人查询数字货币交易信息以及进行投资操作。本篇文章整理开发者如何使用火币公共数据 API 获取指定交易对市场深度数据。
火币交易所相信大家都比较熟悉了。火币提供了丰富的 API 服务以便分析师投资人查询数字货币交易信息以及进行投资操作。
本篇文章整理开发者如何使用火币公共数据 API 获取指定交易对市场深度数据。
由于某些原因,如果访问不了火币 API,可能需要使用中国大陆以外的 IP 访问。
火币 API 官方文档:https://huobiapi.github.io/docs/v1/cn/
API 基本端口:
API 基本返回字段:
status
: string, API接口返回状态;
ch
: string, 接口数据对应的数据流。部分接口没有对应数据流因此不返回此字段;
ts
: int, 接口返回的调整为北京时间的时间戳,单位毫秒;
data
: object, 接口返回数据主体;
火币 API 获取指定交易对市场深度数据:
端口:
请求参数:
symbol
: string,必填,交易对,如 btcusdt, ethbtc...
depth
: integer,非必填,默认20,返回深度的数量,如 5,10,20;
type
: string,必填,深度的价格聚合度,如 step0,step1,step2,step3,step4,step5;
参数 type
的各值说明:
step0: 无聚合;
step1: 聚合度为报价精度10;
step2: 聚合度为报价精度100;
step3: 聚合度为报价精度1000;
step4: 聚合度为报价精度10000;
step5: 聚合度为报价精度*100000.
当 type
值为 ‘step0’ 时,‘depth’ 的默认值为150而非20.
Curl示例:
curl "https://api.huobi.pro/market/depth?symbol=btcusdt&type=step2"
Node.js 示例:
const fetch = require('node-fetch');
fetch('https://api.huobi.pro/market/depth?symbol=btcusdt&type=step2', {
method: 'get',
}).then(response => response.json()
.then(data => console.log(data)));
返回的 JSON 示例:
返回的 JSON 顶级数据对象名为 tick
而不是通常的 data
.
{
"version": 31615842081,
"ts": 1489464585407,
"bids": [
[7964, 0.0678], // [price, amount]
[7963, 0.9162],
[7961, 0.1],
[7960, 12.8898],
[7958, 1.2],
...
],
"asks": [
[7979, 0.0736],
[7980, 1.0292],
[7981, 5.5652],
[7986, 0.2416],
[7990, 1.9970],
...
]
}
火币 API 服务思维导图:
![](https://img.haomeiwen.com/i7031412/b6923e50348c3a8f.png)
我们有一个区块链知识星球,做区块链前沿资料的归纳整理以方便大家检索查询使用,也是国内顶尖区块链技术社区,欢迎感兴趣的朋友加入。如果你对上面内容有疑问,也可以加入知识星球提问我:
![](https://img.haomeiwen.com/i7031412/b92c912401e3b9d1.png)
网友评论