Last active
June 11, 2021 07:08
-
-
Save sayon-bitquery/bfbe97d8a755ef387edf93d0d8afbd63 to your computer and use it in GitHub Desktop.
The GraphQL query to return the updated price of the Ethereum currency
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
# The GraphQL query | |
query = """ | |
{ | |
ethereum(network: bsc) { | |
dexTrades( | |
baseCurrency: {is: "BASE ADDRESS TOKEN"} | |
quoteCurrency: {is: "QUOTE ADDRESS TOKEN"} | |
options: {desc: ["block.height", "transaction.index"], limit: 1} | |
) { | |
block { | |
height | |
timestamp { | |
time(format: "%Y-%m-%d %H:%M:%S") | |
} | |
} | |
transaction { | |
index | |
} | |
baseCurrency { | |
symbol | |
} | |
quoteCurrency { | |
symbol | |
} | |
quotePrice | |
} | |
} | |
} | |
""" | |
result = run_query(query) | |
quotePrice = result.get('data').get('ethereum').get('dexTrades')[0].get('quotePrice') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment