Get Price, Trading Volume, Trade Count of all Tokens in a Single API

Here is the way to get the token price of all tokens in one query.

In this query, I am saying “Give me the latest data for all base currency where quote current is USDT and limit results by per base currency”

{
  ethereum(network: ethereum) {
    list1: dexTrades(
      options: {limitBy: {each: "baseCurrency.address", limit: 1}, desc: ["block.timestamp.time", "tradeIndex"]}
      exchangeName: {is: "Uniswap"}
      quoteCurrency: {in: ["0xdac17f958d2ee523a2206206994597c13d831ec7"]}
      time: {since: "2021-06-01T00:00:00"}
    ) {
      baseCurrency {
        address
        symbol
      }
      block {
        height
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
      }
      tradeIndex
      trades: count
      tradeAmount(in: USD)
      quoteAmount
      quotePrice
      quoteCurrency {
        address
        symbol
      }
    }
  }
}

4 Likes

Using the same method anyone can get the OHLC for all the tokens in 1 API call.

{
  ethereum(network: bsc) {
    dexTrades(
      options: {limitBy: {each: "baseCurrency.address", limit: 1}, desc: ["timeInterval.minute"]}
      date: {since: "2021-06-01"}
      exchangeName: {is: "Pancake"}
      quoteCurrency: {is: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"}
    ) {
      timeInterval {
        minute(count: 5)
      }
      baseCurrency {
        symbol
        address
      }
      baseAmount
      quoteCurrency {
        symbol
        address
      }
      quoteAmount
      trades: count
      quotePrice
      maximum_price: quotePrice(calculate: maximum)
      minimum_price: quotePrice(calculate: minimum)
      median_price: quotePrice(calculate: median)
      open_price: minimum(of: block, get: quote_price)
      close_price: maximum(of: block, get: quote_price)
    }
  }
}
3 Likes