Cover Image for PancakeSwap API – Real-Time Trades, Volume, Liquidity & Pools

PancakeSwap API – Real-Time Trades, Volume, Liquidity & Pools

DEX
Research

With more than $2.15B in Trading volume in PancakeSwap V3, PancakeSwap is one of the most active DEXs, running across BSC (PancakeSwap Infinity), Ethereum, and Base . Below are up-to-date Bitquery GraphQL APIs and subscriptions you can use to pull trades, volume, liquidity signals, and pool activity in real time or historically—no node or custom ETL needed.

To call these APIs outside the Bitquery IDE, create an API token first: How to generate Bitquery API token ➤.

PancakeSwap V3 on Ethereum (EVM)

Latest tradesRun in IDE
Live trades on PancakeSwap V3 (Ethereum). Switch network to bsc to query BSC markets.

query LatestTrades {
  EVM(network: eth) {
    DEXTradeByTokens(
      orderBy: {descending: Block_Time}
      limit: {count: 50}
      where: {
        TransactionStatus: {Success: true}
        Trade: {Dex: {ProtocolName: {is: "pancake_swap_v3"}}}
        Block: {Time: {since: "2025-06-17T09:50:13Z"}}
      }
    ) {
      Block { Time }
      Transaction { Hash }
      Trade {
        Dex { OwnerAddress ProtocolFamily ProtocolName }
        AmountInUSD
        Price
        Amount
        Side {
          Type
          Currency { Symbol SmartContract Name }
          AmountInUSD
          Amount
        }
        Currency { Symbol SmartContract Name }
      }
    }
  }
}

Top traded pairs on ETHRun in IDE
Rank pairs by USD volume and fetch recent prices.

query pairs($network: evm_network, $market: String!, $eth: String!, $usdc: String!, $usdt: String!, $weth: String!) {
  EVM(network: $network) {
    DEXTradeByTokens(
      where: {
        TransactionStatus: {Success: true}
        Block: {Time: {since: "2025-06-17T09:53:37Z"}}
        Trade: {
          Success: true
          Dex: {ProtocolName: {is: $market}}
        }
        any: [
          {Trade: {Side: {Currency: {SmartContract: {is: $eth}}}}}
          {Trade: {Side: {Currency: {SmartContract: {is: $usdt}}}, Currency: {SmartContract: {notIn: [$eth]}}}}
          {Trade: {Side: {Currency: {SmartContract: {is: $usdc}}}, Currency: {SmartContract: {notIn: [$eth, $usdt]}}}}
          {Trade: {Side: {Currency: {SmartContract: {is: $weth}}}, Currency: {SmartContract: {notIn: [$eth, $usdc, $usdt]}}}}
          {Trade: {Side: {Currency: {SmartContract: {notIn: [$usdc, $usdt, $weth, $eth]}}}, Currency: {SmartContract: {notIn: [$usdc, $usdt, $weth, $eth]}}}}
        ]
      }
      orderBy: {descendingByField: "usd"}
      limit: {count: 70}
    ) {
      Block { Time(maximum: Block_Time, selectWhere: {after: "2025-06-18T08:53:37Z"}) }
      Trade {
        Currency { Symbol Name SmartContract ProtocolName }
        Side { Currency { Symbol Name SmartContract ProtocolName } }
        price_last: PriceInUSD(maximum: Block_Number)
        price_10min_ago: PriceInUSD(maximum: Block_Number, if: {Block: {Time: {before: "2025-06-18T09:43:37Z"}}})
        price_1h_ago: PriceInUSD(maximum: Block_Number, if: {Block: {Time: {before: "2025-06-18T08:53:37Z"}}})
        price_3h_ago: PriceInUSD(maximum: Block_Number, if: {Block: {Time: {before: "2025-06-18T06:53:37Z"}}})
      }
      dexes: uniq(of: Trade_Dex_OwnerAddress)
      amount: sum(of: Trade_Side_Amount)
      usd: sum(of: Trade_Side_AmountInUSD)
      sellers: uniq(of: Trade_Seller)
      buyers: uniq(of: Trade_Buyer)
      count(selectWhere: {ge: "100"})
    }
  }
}

Top traders for a tokenRun in IDE
Find the biggest traders for any token on PancakeSwap V3 (example shows USDC on ETH).

query topTraders {
  EVM(network: eth) {
    DEXTradeByTokens(
      orderBy: {descendingByField: "volumeUsd"}
      limit: {count: 100}
      where: {
        Trade: {
          Currency: {SmartContract: {is: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}}
          Dex: {ProtocolName: {is:"pancake_swap_v3"}}
        }
      }
    ) {
      Trade { Buyer }
      bought: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: buy}}}})
      sold: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: sell}}}})
      volume: sum(of: Trade_Amount)
      volumeUsd: sum(of: Trade_Side_AmountInUSD)
    }
  }
}

PancakeSwap Infinity on Base

Subscribe to latest tradesRun in IDE

query MyQuery {
  EVM(dataset: realtime, network: base) {
    DEXTrades(
      where: {Trade: {Dex: {ProtocolName: {is: "pancakeswap_infinity"}}}}
      limit: {count: 10}
      orderBy: {descending: Block_Time}
    ) {
      Transaction { From To }
      Trade {
        Dex { ProtocolName SmartContract }
        Buy { Currency { Name } Price Amount }
        Sell { Amount Currency { Name } Price }
      }
      Block { Time }
    }
  }
}

Latest price for a tokenRun in IDE

query MyQuery {
  EVM(dataset: realtime, network: base) {
    DEXTradeByTokens(
      where: {
        Trade: {
          Currency: {SmartContract: {is: "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf"}}
          Dex: {ProtocolName: {is: "pancakeswap_infinity"}}
        }
      }
      limit: {count: 10}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Trade {
        Price PriceInUSD Amount AmountInUSD
        Currency { Name Symbol SmartContract }
        Dex { ProtocolName SmartContract }
        Side {
          Amount AmountInUSD
          Currency { Name Symbol SmartContract }
        }
      }
    }
  }
}

Top traders for a tokenRun in IDE

query topTraders($network: evm_network, $token: String) {
  EVM(network: $network) {
    DEXTradeByTokens(
      orderBy: {descendingByField: "volumeUsd"}
      limit: {count: 100}
      where: {
        Trade: {
          Currency: {SmartContract: {is: $token}}
          Dex: {ProtocolName: {is: "pancakeswap_infinity"}}
        }
      }
    ) {
      Trade {
        Dex { OwnerAddress ProtocolFamily ProtocolName }
        Buyer
      }
      bought: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: buy}}}})
      sold: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: sell}}}})
      volume: sum(of: Trade_Amount)
      volumeUsd: sum(of: Trade_Side_AmountInUSD)
    }
  }
}

OHLC (price candles)Run in IDE

{
  EVM(network: base, dataset: realtime) {
    DEXTradeByTokens(
      orderBy: {descendingByField: "Block_testfield"}
      where: {
        Trade: {
          Currency: {SmartContract: {is: "0x22af33fe49fd1fa80c7149773dde5890d3c76f3b"}}
          Side: {Currency: {SmartContract: {is: "0x4200000000000000000000000000000000000006"}}, Type: {is: buy}}
          PriceAsymmetry: {lt: 0.1}
          Dex: {ProtocolName: {is: "pancakeswap_infinity"}}
        }
      }
      limit: {count: 10}
    ) {
      Block { testfield: Time(interval: {in: hours, count: 1}) }
      volume: sum(of: Trade_Amount)
      Trade {
        high: Price(maximum: Trade_Price)
        low: Price(minimum: Trade_Price)
        open: Price(minimum: Block_Number)
        close: Price(maximum: Block_Number)
      }
      count
    }
  }
}

Volume, buy/sell splitsRun in IDE

query MyQuery {
  EVM(network: base) {
    DEXTradeByTokens(
      where: {
        Trade: {
          Currency: {SmartContract: {is: "0x22af33fe49fd1fa80c7149773dde5890d3c76f3b"}}
          Dex: {ProtocolName: {is: "pancakeswap_infinity"}}
        }
        TransactionStatus: {Success: true}
        Block: {Time: {since: "2025-02-12T00:00:00Z"}}
      }
    ) {
      Trade { Currency { Name Symbol SmartContract Decimals } }
      traded_volume_in_usd: sum(of: Trade_Side_AmountInUSD)
      sell_volume_in_usd: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: buy}}}})
      buy_volume_in_usd: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: sell}}}})
    }
  }
}

Top bought / sold tokensRun in IDE
Swap orderBy between buy and sell to rank directions.

query timeDiagram($network: evm_network) {
  EVM(network: $network) {
    DEXTradeByTokens(
      orderBy: {descendingByField: "buy"}
      limit: {count: 100}
      where: {Trade: {Dex: {ProtocolName: {is: "pancakeswap_infinity"}}}}
    ) {
      Trade {
        Currency { Symbol Name SmartContract }
        Dex { ProtocolName }
      }
      buy: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: buy}}}})
      sell: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: sell}}}})
    }
  }
}

Token metadataRun in IDE
Fetch name, symbol, decimals, and protocol details.

query MyQuery {
  EVM(network: base, dataset: realtime) {
    DEXTradeByTokens(
      limit: {count: 1}
      orderBy: {descending: Block_Time}
      where: {
        Trade: {
          Currency: {SmartContract: {is: "0x22af33fe49fd1fa80c7149773dde5890d3c76f3b"}}
          Dex: {ProtocolName: {is: "pancakeswap_infinity"}}
        }
      }
    ) {
      Trade {
        Currency {
          Name Symbol SmartContract ProtocolName HasURI Fungible Decimals
        }
      }
    }
  }
}

PancakeSwap V3 on BSC

Latest tradesRun in IDE

{
  EVM(dataset: realtime, network: bsc) {
    DEXTrades(
      orderBy: [
        {descending: Block_Time}
        {descending: Transaction_Index}
        {descending: Trade_Index}
      ]
      where: {
        TransactionStatus: {Success: true}
        Trade: {Dex: {OwnerAddress: {is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865"}}}
      }
      limit: {count: 20}
    ) {
      Block { Time Number }
      Transaction { Hash From To Value ValueInUSD }
      Trade {
        Buy {
          Amount AmountInUSD Buyer Seller
          Currency { Decimals Name Symbol SmartContract }
          Price PriceInUSD
        }
        Sell {
          Amount AmountInUSD Buyer Seller
          Currency { Name Symbol SmartContract }
          Price PriceInUSD
        }
        Dex { ProtocolName SmartContract OwnerAddress }
      }
    }
  }
}

Streaming trades (confirmed)Run in IDE
Switch network: bsc and keep the same owner filter to get real-time trades.

subscription {
  EVM(network: bsc) {
    DEXTrades(
      where: {
        TransactionStatus: {Success: true}
        Trade: {Dex: {OwnerAddress: {is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865"}}}
      }
    ) {
      Block { Time Number }
      Transaction { Hash From To Value ValueInUSD }
      Trade {
        Buy { Amount AmountInUSD Currency { Symbol } Price PriceInUSD }
        Sell { Amount AmountInUSD Currency { Symbol } Price PriceInUSD }
        Dex { ProtocolName SmartContract OwnerAddress }
      }
    }
  }
}

Streaming mempool tradesRun in IDE

subscription {
  EVM(network: bsc, mempool: true) {
    DEXTrades(
      where: {
        TransactionStatus: {Success: true}
        Trade: {Dex: {OwnerAddress: {is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865"}}}
      }
    ) {
      Block { Time Number }
      Transaction { Hash From To Value ValueInUSD }
      Trade {
        Buy { Amount AmountInUSD Currency { Symbol } Price PriceInUSD }
        Sell { Amount AmountInUSD Currency { Symbol } Price PriceInUSD }
        Dex { ProtocolName SmartContract OwnerAddress }
      }
    }
  }
}

Trades for a specific tokenRun in IDE

{
  EVM(dataset: realtime, network: bsc) {
    DEXTradeByTokens(
      limit: {count: 20}
      orderBy: [
        {descending: Block_Time}
        {descending: Transaction_Index}
        {descending: Trade_Index}
      ]
      where: {
        Trade: {
          Dex: {OwnerAddress: {is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865"}}
          Currency: {SmartContract: {is: "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82"}}
        }
      }
    ) {
      Block { Time Number }
      TransactionStatus { Success }
      Transaction { Hash From To }
      Trade {
        Amount AmountInUSD Price PriceInUSD Success
        Dex { ProtocolName ProtocolFamily }
        Currency { Name Symbol SmartContract }
        Side {
          Amount AmountInUSD Buyer Seller Type
          Currency { Name Symbol SmartContract }
        }
      }
    }
  }
}

Top traders for a tokenRun in IDE

{
  EVM(network: bsc) {
    DEXTradeByTokens(
      orderBy: {descendingByField: "volumeUsd"}
      limit: {count: 100}
      where: {
        Trade: {
          Currency: {SmartContract: {is: "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82"}}
          Dex: {OwnerAddress: {is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865"}}
        }
      }
    ) {
      Trade { Dex { OwnerAddress ProtocolFamily ProtocolName } Buyer }
      bought: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: buy}}}})
      sold: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: sell}}}})
      volume: sum(of: Trade_Amount)
      volumeUsd: sum(of: Trade_Side_AmountInUSD)
    }
  }
}

Trading volume, buy volume, sell volumeRun in IDE

query MyQuery {
  EVM(network: bsc) {
    DEXTradeByTokens(
      where: {
        Trade: {
          Currency: {SmartContract: {is: "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82"}}
          Dex: {OwnerAddress: {is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865"}}
        }
        TransactionStatus: {Success: true}
        Block: {Time: {since: "2025-02-12T00:00:00Z"}}
      }
    ) {
      Trade { Currency { Name Symbol SmartContract Decimals } }
      traded_volume_in_usd: sum(of: Trade_Side_AmountInUSD)
      sell_volume_in_usd: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: buy}}}})
      buy_volume_in_usd: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: sell}}}})
    }
  }
}

Token metadataRun in IDE

query MyQuery {
  EVM(network: bsc, dataset: realtime) {
    DEXTradeByTokens(
      limit: {count: 1}
      orderBy: {descending: Block_Time}
      where: {
        Trade: {
          Currency: {SmartContract: {is: "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82"}}
          Dex: {OwnerAddress: {is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865"}}
        }
      }
    ) {
      Trade {
        Currency {
          Name Symbol SmartContract ProtocolName HasURI Fungible Decimals
        }
      }
    }
  }
}

OHLC via Trading cubeRun in IDE

{
  Trading(dataset: realtime) {
    Pairs(
      where: {
        Price: {IsQuotedInUsd: false}
        Interval: {Time: {Duration: {eq: 1}}}
        Currency: {Id: {is: "bid:eth"}}
        QuoteCurrency: {Id: {is: "usdc"}}
        Market: {Protocol: {is: "pancake_swap_v3"}}
      }
      limit: {count: 10}
      orderBy: {descending: Interval_Time_End}
    ) {
      Token { Id Symbol Address NetworkBid Network Name }
      QuoteToken { Id Symbol Address Name NetworkBid }
      Interval { Time { Start End Duration } }
      Volume { Usd Quote Base }
      Price {
        IsQuotedInUsd
        Ohlc { Open High Low Close }
        Average { Estimate ExponentialMoving Mean SimpleMoving WeightedSimpleMoving }
      }
    }
  }
}

Price change (24h / 1h / 5m)Run in IDE

query MyQuery($currency: String) {
  EVM(network: bsc) {
    DEXTradeByTokens(
      where: {
        Trade: {
          Currency: {SmartContract: {is: $currency}}
          Dex: {OwnerAddress: {is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865"}}
          Success: true
        }
        Block: {Time: {since_relative: {hours_ago: 24}}}
      }
    ) {
      Trade {
        Currency { Name Symbol SmartContract }
        price_24hr: PriceInUSD(minimum: Block_Time)
        price_1hr: PriceInUSD(if: {Block: {Time: {is_relative: {hours_ago: 1}}}})
        price_5min: PriceInUSD(if: {Block: {Time: {is_relative: {minutes_ago: 1}}}})
        current: PriceInUSD
      }
      change_24hr: calculate(expression: "( $Trade_current - $Trade_price_24hr ) / $Trade_price_24hr * 100")
      change_1hr: calculate(expression: "( $Trade_current - $Trade_price_1hr ) / $Trade_price_1hr * 100")
      change_5min: calculate(expression: "( $Trade_current - $Trade_price_5min ) / $Trade_price_5min * 100")
    }
  }
}

New pools createdRun in IDE

{
  EVM(dataset: realtime, network: bsc) {
    Events(
      orderBy: [
        {descending: Block_Time}
        {descending: Transaction_Index}
        {descending: Log_Index}
      ]
      where: {
        LogHeader: {Address: {is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865"}}
        Log: {Signature: {Name: {is: "PoolCreated"}}}
      }
    ) {
      Block { Time Number Hash }
      Transaction { Hash From To }
      Receipt { ContractAddress }
      Arguments { Name Value { ... on EVM_ABI_Address_Value_Arg { address } } }
    }
  }
}

Liquidity add/remove eventsRun in IDE
Filter by Mint (add) or Burn (remove) signatures.

subscription {
  EVM(network: bsc) {
    Events(
      orderBy: [
        {descending: Block_Time}
        {descending: Transaction_Index}
        {descending: Log_Index}
      ]
      where: {
        Log: {Signature: {Name: {is: "Mint"}}}
        Transaction: {To: {is: "0x46A15B0b27311cedF172AB29E4f4766fbE7F4364"}}
      }
    ) {
      Block { Time Number Hash }
      Transaction { Hash From To }
      LogHeader { Address Data }
      Arguments { Name Value { ... on EVM_ABI_Address_Value_Arg { address } } }
    }
  }
}

Latest pool reserves for a pairRun in IDE

{
  EVM(dataset: combined, network: bsc) {
    BalanceUpdates(
      where: {
        Currency: {
          SmartContract: {in: ["0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82", "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"]}
        }
        BalanceUpdate: {Address: {is: "0xafb2da14056725e3ba3a30dd846b6bbbd7886c56"}}
      }
    ) {
      sum(of: BalanceUpdate_Amount, selectWhere: {gt: "0"})
      Currency { Name Symbol SmartContract Decimals }
    }
  }
}

All pairs for a tokenRun in IDE

query pairDexList(
  $network: evm_network
  $base: String
  $time_10min_ago: DateTime
  $time_1h_ago: DateTime
  $time_3h_ago: DateTime
  $time_ago: DateTime
  $owner: String
) {
  EVM(network: $network) {
    DEXTradeByTokens(
      orderBy: {descendingByField: "amount"}
      where: {
        TransactionStatus: {Success: true}
        Trade: {
          Currency: {SmartContract: {is: $base}}
          Side: {Amount: {gt: "0"}}
          Dex: {OwnerAddress: {is: $owner}}
        }
        Block: {Time: {after: $time_ago}}
      }
    ) {
      Trade {
        Currency { Name SmartContract }
        Side { Currency { Name SmartContract } }
        Dex { SmartContract }
        price_last: PriceInUSD(maximum: Block_Number)
        price_10min_ago: PriceInUSD(maximum: Block_Number, if: {Block: {Time: {before: $time_10min_ago}}})
        price_1h_ago: PriceInUSD(maximum: Block_Number, if: {Block: {Time: {before: $time_1h_ago}}})
        price_3h_ago: PriceInUSD(maximum: Block_Number, if: {Block: {Time: {before: $time_3h_ago}}})
      }
      amount: sum(of: Trade_Side_AmountInUSD)
      trades: count
    }
  }
}

Build charts and dashboards quickly

All queries return structured JSON you can drop into charting libraries (TradingView, ECharts, Plotly) or pipe into streams/Kafka for low-latency analytics. Swap network, contract addresses, or protocol names to cover additional PancakeSwap markets across chains.

Subscribe to our newsletter

Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.