问题:
- 我正在尝试从加密货币交易所"perpetual protocol"下载数据
- API文档页面是here,它可以让您看到API是如何工作的李>
- 因为我的主要编程语言是Python,所以我使用它来下载数据,但是我得到了以下错误消息。
{'errors': [{'locations': [{'line': 0, 'column': 0}], 'message': 'No value provided for required argument: id'}]}
李> - 有人能告诉我如何修复这个错误来下载数据吗李>
import request
timestamp = 1607904000
graphql_endpoint = 'https://api.thegraph.com/subgraphs/name/perpetual-protocol/perp-position-subgraph'
headers = {"Content-Type": "application/json"}
fundingRateUpdatedEvent_query = """query {
fundingRateUpdatedEvent(first: 1000, orderBy:timestamp,orderDirection:asc, where:{timestamp_gt: %i}) {
id
amm
rate
underlyingPrice
timestamp
}}""" % (timestamp)
request_result = requests.post(graphql_endpoint, json={'query': fundingRateUpdatedEvent_query}, headers=headers)
if request_result.status_code == 200:
request_result.json()['data']['fundingRateUpdatedEvents']
else:
raise Exception(f"GraphQL query failed to run by returning code of {request.status_code}.")
- 这对我来说很奇怪,因为下面的代码工作起来没有问题。唯一的区别是查询语句中的内容李>
timestamp = 1607904000
graphql_endpoint = 'https://api.thegraph.com/subgraphs/name/perpetual-protocol/perp-position-subgraph'
headers = {"Content-Type": "application/json"}
positionChanged_query = """query {
positionChangedEvents(first: 1000, orderBy:timestamp,orderDirection:asc, where:{timestamp_gt: %i}) {
id
trader
timestamp
amm
margin
positionNotional
exchangedPositionSize
fee
positionSizeAfter
realizedPnl
unrealizedPnlAfter
badDebt
liquidationPenalty
spotPrice
fundingPayment
}}""" % (timestamp)
request_result = requests.post(graphql_endpoint, json={'query': positionChanged_query}, headers=headers)
print(request_result)
if request_result.status_code == 200:
print(request_result.json())
request_result.json()['data']['positionChangedEvents']
else:
raise Exception(f"GraphQL query failed to run by returning code of {request.status_code}.")
Tags:
您需要将查询的实体多元化:
fundingRateUpdatedEvents
我相信我们在使用图表时遇到了同样的问题
相关问题 更多 >
编程相关推荐