Last active
June 10, 2021 17:37
-
-
Save sayon-bitquery/7094a096d5390377489d7497f2415c60 to your computer and use it in GitHub Desktop.
Function to integrate Bitquery's GraphQL API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_query(query): | |
headers = {'X-API-KEY': YOUR API KEY} | |
request = requests.post('https://graphql.bitquery.io/', json={'query': query}, headers=headers) | |
if request.status_code == 200: | |
return request.json() | |
else: | |
raise Exception('Query failed and return code is {}. {}'.format(request.status_code, query)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment