Reputation: 428
{'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}.")
Upvotes: 0
Views: 1986
Reputation: 29
You need to pluralize the entity you are querying:
fundingRateUpdatedEvents
I believe we encountered the same issue using the graph!
Upvotes: 2