multiple tokens volume and SMA

Historical data The Trading cube covers real time and roughly the last 30 days. For anything older, rebuild the same numbers from raw trades with DEXTradeByTokens. Datasets: https://docs.bitquery.io/docs/graphql/dataset/archive/ Retention: https://docs.bitquery.io/docs/graphql/data-coverage-retenti

By Kshitij Mahajan · saved 24 June 2026 · run 2 times · Bitquery API v2

What it returns

Filters

The query

# Historical data
#   The Trading cube covers real time and roughly the last 30 days. For
#   anything older, rebuild the same numbers from raw trades with
#   DEXTradeByTokens.
#
# Datasets:  https://docs.bitquery.io/docs/graphql/dataset/archive/
# Retention: https://docs.bitquery.io/docs/graphql/data-coverage-retention/
#
# For more info on the endpoint visit -
# https://docs.bitquery.io/docs/trading/crypto-price-api/introduction/
# For faster results try using indexed feilds in where and orderBy clause -
# https://docs.bitquery.io/docs/graphql/indexed-fields-reference/

{
  TokenAsBase: Trading {
    Pairs(
      where: {
        Interval: {Time: {Duration: {eq: 3600}, Start: {since_relative: {days_ago: 28}}}}, 
        Token: {Id: {in: ["bid:solana:Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", "bid:solana:BKQucpTXB2d67jSNXMznSTj2iNLVtyga9JW86QoWpump"]}}
      }
    ) {
      Token {
        Id
        Name
        Symbol
      }
      Price {
        Average {
          currentPrice: Mean(maximum: Block_Time)
          H1Ago: Mean(
            minimum: Block_Time
            if: {Block: {Time: {since_relative: {hours_ago: 1}}}}
          )
          H4Ago: Mean(
            minimum: Block_Time
            if: {Block: {Time: {since_relative: {hours_ago: 4}}}}
          )
          H24Ago: Mean(
            minimum: Block_Time
            if: {Block: {Time: {since_relative: {hours_ago: 24}}}}
          )
        }
      }
      v1h: sum(of: Volume_Usd, if: {Block: {Time: {since_relative: {hours_ago: 1}}}})
      v4h: sum(of: Volume_Usd, if: {Block: {Time: {since_relative: {hours_ago: 4}}}})
      v24h: sum(of: Volume_Usd)
    }
  }
  TokenAsQuote: Trading {
    Pairs(
      where: {Interval: {Time: {Duration: {eq: 1}, Start: {since_relative: {days_ago: 0}}}}, Token: {Id: {in: ["bid:solana:Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", "bid:solana:BKQucpTXB2d67jSNXMznSTj2iNLVtyga9JW86QoWpump"]}}}
    ) {
      Token {
        Id
        Name
        Symbol
      }
      Price {
        Average {
          currentPrice: Mean(maximum: Block_Time)
          H1Ago: Mean(
            minimum: Block_Time
            if: {Block: {Time: {since_relative: {hours_ago: 1}}}}
          )
          H4Ago: Mean(
            minimum: Block_Time
            if: {Block: {Time: {since_relative: {hours_ago: 4}}}}
          )
          H24Ago: Mean(
            minimum: Block_Time
            if: {Block: {Time: {since_relative: {hours_ago: 24}}}}
          )
        }
      }
      v1h: sum(of: Volume_Usd, if: {Block: {Time: {since_relative: {hours_ago: 1}}}})
      v4h: sum(of: Volume_Usd, if: {Block: {Time: {since_relative: {hours_ago: 4}}}})
      v24h: sum(of: Volume_Usd)
    }
  }
}

Similar queries