在调用Bittrex交易所API时,如果之前响应是有效的而现在为空,可能有几个原因导致。以下是一些可能的解决方法和代码示例:
import requests
response = requests.get('https://api.bittrex.com/v3/markets')
print(response.status_code) # 检查响应状态码
print(response.json()) # 打印响应内容
import requests
import hashlib
import hmac
import time
import json
api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'
# 创建签名
timestamp = str(int(time.time() * 1000))
content_hash = hashlib.sha512().hexdigest()
pre_sign = timestamp + 'GET' + '/v3/markets' + content_hash
signature = hmac.new(api_secret.encode(), pre_sign.encode(), hashlib.sha512).hexdigest()
# 发送请求
headers = {
'Content-Type': 'application/json',
'Api-Key': api_key,
'Api-Timestamp': timestamp,
'Api-Content-Hash': content_hash,
'Api-Signature': signature
}
response = requests.get('https://api.bittrex.com/v3/markets', headers=headers)
print(response.status_code) # 检查响应状态码
print(response.json()) # 打印响应内容
以上是一些常见的解决方法和代码示例,您可以根据具体情况进行调整和优化。如果问题仍然存在,建议查阅Bittrex交易所的官方文档或向官方技术支持寻求帮助。