美文网首页区块链研习社互联网科技程序员
Coinbase 公共数据 API 获取交易对订单记录 - 区块

Coinbase 公共数据 API 获取交易对订单记录 - 区块

作者: 极客红石 | 来源:发表于2019-03-09 22:03 被阅读33次

简介:Coinbase,相信大家都不陌生,世界顶级数字货币交易所。Coinbase 有非常完备的 API 服务,包括允许开发人员使用 OAuth2 协议允许 Coinbase 用户授予第三方应用程序对其帐户的完全或部分访问权限,而无需共享帐户的 API 密钥或登录凭据。本篇文章介绍开发者如何使用 Coinbase 公共数据 API 获取交易对订单记录。

Coinbase,相信大家都不陌生,世界顶级数字货币交易所。Coinbase 有非常完备的 API 服务,包括允许开发人员使用 OAuth2 协议允许 Coinbase 用户授予第三方应用程序对其帐户的完全或部分访问权限,而无需共享帐户的 API 密钥或登录凭据。

Coinbase, which I believe everyone knows, is the world's top digital currency exchange. Coinbase's API services are very comprehensive, it allows developers to use the OAuth2 protocol to allow a Coinbase user to grant a 3rd party application full or partial access to his/her account, without sharing the account’s API key or login credentials.

本篇文章,我们展示如何利用 Coinbase 的 Market Data API 获取交易对订单记录。

In this article, we show how to use Coinbase's Market Data API to get a list of open orders for a product.

Market Data API 是 Coinbase Pro API 中不需要身份验证的公共信息端口,用于检索市场数据。它提供市场数据的快照。

The Market Data API is an unauthenticated set of endpoints for retrieving market data. These endpoints provide snapshots of market data.

Market Data API 官方文档:https://docs.pro.coinbase.com/#market-data

Market Data API official documentation: https://docs.pro.coinbase.com/#market-data

获取交易对订单记录:

Get a list of open orders for a product:

基本查询:

Basic query:

https://api-public.sandbox.pro.coinbase.com/products/<product-id>/book

比如查询 ETH-BTC 交易对:

For example, query ETH-BTC:

https://api-public.sandbox.pro.coinbase.com/products/ETH-BTC/book

Node.js 代码示例:

Code example (Node.js):

返回的 JSON 示例:

Return JSON example:

在这个查询中,显示的详细信息量可以使用 level 参数进行自定义。默认情况下 level 参数为1.

In this query, the amount of detail shown can be customized with the level parameter. The default level is 1.

高级查询:

Advanced Search:

对 level 进行设置可改变输出结果:

The amount of detail shown can be customized with the level parameter:

 只显示最好的出价和 ask

前50的出价和 ask 汇总

3  完整订单列表

Only the best bid and ask

2  Top 50 bids and asks (aggregated)

3  Full order book (non aggregated)

https://api-public.sandbox.pro.coinbase.com/products/<product-id>/book?level=x

比如查询 BTC-USD 交易对并设置 level 为2:

For example, query BTC-USD and set the level to 2:

https://api-public.sandbox.pro.coinbase.com/products/BTC-USD/book?level=2

Node.js 代码示例:

Code example (Node.js):

返回的 JSON 示例(查询 BTC-USD 交易对并设置 level 为2):

Return JSON example (query BTC-USD and set the level to 2):

Market Data API 思维导图:

Mind map of the Market Data API:

本文为原创双语文章,不是纯翻译文章。双语呈现是为了更好理解。还请多多支持。

其实自己英语也没有多好,所以文章中如有错误或纰漏,欢迎指正。

我们有一个区块链知识星球,做区块链前沿资料的归纳整理以方便大家检索查询使用,也是国内顶尖区块链技术社区,欢迎感兴趣的朋友加入。如果你对上面内容有疑问,也可以加入知识星球提问我:

相关文章

网友评论

    本文标题:Coinbase 公共数据 API 获取交易对订单记录 - 区块

    本文链接:https://www.haomeiwen.com/subject/avjxpqtx.html