【发布时间】:2019-06-25 04:44:45
【问题描述】:
我正在探索 Bitso API(Bitso 是一个墨西哥加密货币交易所)。
API 的文档在 Python 和 Ruby 等一些语言中得到了很好的解释,供其使用。这里的问题是没有使用直接 URL 进行请求的示例。
我打算做的是创建代码在其请求函数上创建的 URL。
有一个余额帐户请求,这是我想要获取的数据。 根据文档,这是一个私有请求,在请求中需要一些标头(密钥、随机数和签名),您可以查看here。
在 Python 中发出这个请求的代码如下:
import time
import hmac
import hashlib
import requests
bitso_key = "BITSO_KEY"
bitso_secret = "BITSO_SECRET"
nonce = str(int(round(time.time() * 1000)))
http_method = "GET"
request_path = "/v3/balance/"
json_payload = ""
# Create signature
message = nonce+http_method+request_path+json_payload
signature = hmac.new(bitso_secret.encode('utf-8'),
message.encode('utf-8'),
hashlib.sha256).hexdigest()
# Build the auth header
auth_header = 'Bitso %s:%s:%s' % (bitso_key, nonce, signature)
# Send request
response = requests.get("https://api.bitso.com/v3/balance/", headers={"Authorization": auth_header})
print(response.content)
因此,基于此,我可以说 URL 是这样的:
https://api.bitso.com/v3/balance/Bitso%20<Key>:<nonce>:<signature>
我确定我的假设是错误的,我知道headers={"Authorization": auth_header} 似乎是用作 URL 中的标头的 JSON 对象,但我想知道该 JSON 对象在发出请求的 URL。我想在浏览器上复制粘贴该 URL 并获取数据作为响应。
我需要该 URL,以便可以使用它将服务连接到商业智能工具。
谢谢!
【问题讨论】: