Coinbase 公共数据 API 获取交易对订单记录 – 区块链数据开发实战

作者 : 开心源码 本文共2217个字,预计阅读时间需要6分钟 发布时间: 2022-05-12 共147人阅读

简介: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:

1??只显示最好的出价和 ask

2? 前50的出价和 ask 汇总

3??完整订单列表

1? 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:

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

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

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

说明
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » Coinbase 公共数据 API 获取交易对订单记录 – 区块链数据开发实战

发表回复