Skip to content

Instantly share code, notes, and snippets.

@sayon-bitquery
Last active June 11, 2021 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sayon-bitquery/bfbe97d8a755ef387edf93d0d8afbd63 to your computer and use it in GitHub Desktop.
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
# 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