Pancake Swap API
BalanceUpdates sunsets 10 August 2026Queries on this page that use BalanceUpdates will stop working on 10 August 2026. Migrate to the Balances and Holders cubes, which return the current balance directly instead of summing deltas.
For coverage, plans and streaming options on BNB Chain, see the Binance Smart Chain API page.
See the migration mapping for the query-by-query translation.
For real-time + last ~30 days, use the Trading cube: Trading.Trades gives you clean, MEV-filtered PancakeSwap swaps with USD price, market cap, and supply on every row across 10 chains in one API. Use the EVM queries on this page for raw per-swap detail or call and event context. An EVM query without a dataset argument runs on the realtime dataset, which holds only the last few days; add dataset: combined or dataset: archive for historical PancakeSwap data.
In this section we will use APIs from Bitquery to get the on-chain trade related data, trade metrics, trades for a token or a trader on the Pancake Swap DEX.
To get the trade activities of the Pancake Swap exclusively we have added a filter out trades based on Factory Contract address, 0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865 for the case of Pancake Swap V3. To get the trades and trade related data for Pancake Swap V1 or V2 you would need their respective addresses. Create your account and get started by following the Quickstart instructions.
ProductUsing this in production? See the Binance Smart Chain API page for plans, free trial and enterprise delivery options.
Bitquery DEX Data Access Options
- GraphQL APIs: Query historical and real-time EVM data with flexible filtering and aggregation
- Real-time Streams: Subscribe to live EVM blockchain events via WebSocket subscriptions
- Cloud Solutions: Access EVM data through AWS, GCP, and Snowflake or your custom cloud solution.
- Kafka Streams: High-throughput data streaming for enterprise applications
Getting Started with Bitquery:
- BSC DEX Trades: Real time DEX Trading data via examples.
- BSC Uniswap APIs: Uniswap Trades on BSC network with the help of examples.
- BSC Four Meme APIs: Four Meme Trades on BSC network with the help of examples.
- Trade APIs: Multi-chain Trade API Examples.
Get Latest Trades on Pancake Swap
This API returns the most recent trades on PancakeSwap v3.
Click to expand GraphQL query
{
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
}
Receipt {
ContractAddress
Status
}
TransactionStatus {
Success
}
Log {
Signature {
Name
}
SmartContract
}
Call {
From
InternalCalls
Signature {
Name
Signature
}
To
Value
}
Transaction {
Value
ValueInUSD
Hash
From
To
}
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 Latest Trades on Pancake Swap
This subscription streams the latest trades on PancakeSwap v3.
Click to expand GraphQL query
subscription {
EVM(network: bsc) {
DEXTrades(
where: {
TransactionStatus: { Success: true }
Trade: {
Dex: {
OwnerAddress: { is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865" }
}
}
}
) {
Block {
Time
Number
}
Receipt {
ContractAddress
Status
}
TransactionStatus {
Success
}
Log {
Signature {
Name
}
SmartContract
}
Call {
From
InternalCalls
Signature {
Name
Signature
}
To
Value
}
Transaction {
Value
ValueInUSD
Hash
From
To
}
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
}
}
}
}
}
Subscribe to Mempool Trades on Pancake Swap
This subscription streams PancakeSwap v3 trades from the mempool, before they are confirmed.
Click to expand GraphQL query
subscription {
EVM(network: bsc, mempool: true) {
DEXTrades(
where: {
TransactionStatus: { Success: true }
Trade: {
Dex: {
OwnerAddress: { is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865" }
}
}
}
) {
Block {
Time
Number
}
Receipt {
ContractAddress
Status
}
TransactionStatus {
Success
}
Log {
Signature {
Name
}
SmartContract
}
Call {
From
InternalCalls
Signature {
Name
Signature
}
To
Value
}
Transaction {
Value
ValueInUSD
Hash
From
To
}
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
}
}
}
}
}
Latest Trades of a Token on Pancake Swap
This returns the latest trades of one token on PancakeSwap v3, CAKE (0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82) in this example. You can also stream the same trades live.
Click to expand GraphQL query
{
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
}
Log {
Signature {
Name
Signature
}
SmartContract
}
Receipt {
ContractAddress
}
Call {
From
Gas
GasUsed
InternalCalls
Signature {
Name
Signature
}
To
Value
}
Trade {
Amount
AmountInUSD
Buyer
Price
PriceInUSD
Buyer
Seller
Sender
Success
URIs
Fees {
Amount
AmountInUSD
Payer
Recipient
}
Dex {
ProtocolName
ProtocolFamily
}
Currency {
Name
Symbol
SmartContract
}
Side {
Amount
AmountInUSD
Buyer
Currency {
Name
Symbol
SmartContract
}
Ids
OrderId
Seller
Type
URIs
}
}
Transaction {
Hash
From
To
}
}
}
}
Also, checkout the Four Meme documentation for APIs related to Four Meme tokens and Four Meme Exchange.
Get Top Traders of a Token on Pancake Swap
Returns the top 100 traders of CAKE on PancakeSwap v3 by USD volume. It ranks Transaction.From, the account that sent each swap, since on a sale Trade.Buyer is the pool or a router. Side.Type describes the counter-side of each trade, so bought sums the rows where Side.Type is sell. PriceAsymmetry: { lt: 0.1 } leaves out trades whose two sides disagree on value (PriceAsymmetry reference).
Note: This queries the
realtimedatabase by default. To queryarchivedata, change thedatasetparameter and add a date period as a filter
Click to expand GraphQL query
{
EVM(network: bsc) {
DEXTradeByTokens(
orderBy: { descendingByField: "volumeUsd" }
limit: { count: 100 }
where: {
Trade: {
Currency: {
SmartContract: { is: "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82" }
}
Dex: {
OwnerAddress: { is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865" }
}
PriceAsymmetry: { lt: 0.1 }
}
}
) {
Transaction {
From
}
Trade {
Dex {
OwnerAddress
ProtocolFamily
ProtocolName
}
}
bought: sum(
of: Trade_Amount
if: { Trade: { Side: { Type: { is: sell } } } }
)
sold: sum(
of: Trade_Amount
if: { Trade: { Side: { Type: { is: buy } } } }
)
volume: sum(of: Trade_Amount)
volumeUsd: sum(of: Trade_Side_AmountInUSD)
}
}
}
Get Trading Volume, Buy Volume, Sell Volume of a Token
Returns the traded, buy and sell volume of CAKE on PancakeSwap v3 over the last 24 hours. PriceAsymmetry: { lt: 0.1 } drops mispriced trades, which would otherwise skew the USD sums.
Click to expand GraphQL query
query MyQuery {
EVM(network: bsc) {
DEXTradeByTokens(
where: {
Trade: {
Currency: {
SmartContract: { is: "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82" }
}
Dex: {
OwnerAddress: { is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865" }
}
PriceAsymmetry: { lt: 0.1 }
}
TransactionStatus: { Success: true }
Block: { Time: { since_relative: { hours_ago: 24 } } }
}
) {
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 } } } }
)
}
}
}
Get Metadata of a Token
Returns a token's metadata: Name, Symbol, SmartContract and Decimals.
Click to expand GraphQL query
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 of a Token on Pancake Swap
This returns OHLC (K-line) data for one token against another.
This query uses the Trading cube from the Crypto Price APIs
Click to expand GraphQL query
{
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 Percentage for a Token on Pancake Swap
This returns the price change percentage of a PancakeSwap token over 24hr, 1hr and 5 min, using the calculate expression feature.
Click to expand GraphQL query
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"
)
}
}
}
{
"currency": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82"
}
New Liquidity Pools Created on Pancake Swap
This returns the latest pool creation events on PancakeSwap v3. You can also stream new pools as they are created. To make sure that we are only getting newly created liquidity pools on Pancake Swap, we are applying the conditon that the LogHeader is 0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865.
Click to expand GraphQL query
{
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
}
Receipt {
ContractAddress
}
Topics {
Hash
}
TransactionStatus {
Success
}
LogHeader {
Address
Index
Data
}
Transaction {
Hash
From
To
}
Log {
EnterIndex
ExitIndex
Index
LogAfterCallIndex
Pc
SmartContract
Signature {
Name
Signature
}
}
Arguments {
Name
Value {
... on EVM_ABI_Integer_Value_Arg {
integer
}
... on EVM_ABI_Address_Value_Arg {
address
}
... on EVM_ABI_String_Value_Arg {
string
}
... on EVM_ABI_BigInt_Value_Arg {
bigInteger
}
... on EVM_ABI_Bytes_Value_Arg {
hex
}
... on EVM_ABI_Boolean_Value_Arg {
bool
}
}
}
}
}
}
Subscribe the Liquidity Addition Event on Pancake Swap
Liquidity addition is an important event related to any liquidity pool. This subscription streams liquidity additions to PancakeSwap v3 pools in real time. To make sure that we are only getting liquidity addition events for Pancake Swap we are placing condition that the transaction is sent to 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364 address.
Click to expand GraphQL query
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
}
Receipt {
ContractAddress
}
Topics {
Hash
}
TransactionStatus {
Success
}
LogHeader {
Address
Index
Data
}
Transaction {
Hash
From
To
}
Log {
EnterIndex
ExitIndex
Index
LogAfterCallIndex
Pc
SmartContract
Signature {
Name
Signature
}
}
Arguments {
Name
Value {
... on EVM_ABI_Integer_Value_Arg {
integer
}
... on EVM_ABI_Address_Value_Arg {
address
}
... on EVM_ABI_String_Value_Arg {
string
}
... on EVM_ABI_BigInt_Value_Arg {
bigInteger
}
... on EVM_ABI_Bytes_Value_Arg {
hex
}
... on EVM_ABI_Boolean_Value_Arg {
bool
}
}
}
}
}
}
Subscribe the Liquidity Removal Event on Pancake Swap
This subscription streams liquidity removals from PancakeSwap v3 pools.
Click to expand GraphQL query
subscription {
EVM(network: bsc) {
Events(
orderBy: [
{ descending: Block_Time }
{ descending: Transaction_Index }
{ descending: Log_Index }
]
where: {
Log: { Signature: { Name: { is: "Burn" } } }
Transaction: {
To: { is: "0x46A15B0b27311cedF172AB29E4f4766fbE7F4364" }
}
}
) {
Block {
Time
Number
Hash
}
Receipt {
ContractAddress
}
Topics {
Hash
}
TransactionStatus {
Success
}
LogHeader {
Address
Index
Data
}
Transaction {
Hash
From
To
}
Log {
EnterIndex
ExitIndex
Index
LogAfterCallIndex
Pc
SmartContract
Signature {
Name
Signature
}
}
Arguments {
Name
Value {
... on EVM_ABI_Integer_Value_Arg {
integer
}
... on EVM_ABI_Address_Value_Arg {
address
}
... on EVM_ABI_String_Value_Arg {
string
}
... on EVM_ABI_BigInt_Value_Arg {
bigInteger
}
... on EVM_ABI_Bytes_Value_Arg {
hex
}
... on EVM_ABI_Boolean_Value_Arg {
bool
}
}
}
}
}
}
Get the Latest Pool Reserves for a Pair on Pancake Swap
This returns the latest reserves of one PancakeSwap v3 pool, given its address (0xafb2da14056725e3ba3a30dd846b6bbbd7886c56 in this example).
Click to expand GraphQL query
Migrated query: use this one. BalanceUpdates sunsets 10 August 2026.
{
EVM(dataset: combined, network: bsc) {
Balances(
where: {
Currency: {
SmartContract: {
in: [
"0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82"
"0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"
]
}
}
Balance: {
Address: { is: "0xafb2da14056725e3ba3a30dd846b6bbbd7886c56" }
}
}
) {
Balance { Amount(selectWhere: { gt: "0" }) }
Currency {
Name
Symbol
SmartContract
Decimals
}
}
}
}
Old BalanceUpdates version (stops working 10 August 2026)
{
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 of a Token on Pancake Swap
This returns every pair of a token on PancakeSwap v3. The result contains info of the liquidity pool such as currency details, trade amount, number of trades and price of token in USD in various time frames.
Click to expand GraphQL query
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
}
}
}
{
"network": "bsc",
"owner": "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865",
"base": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
"time_10min_ago": "2025-04-10T09:03:33Z",
"time_1h_ago": "2025-04-10T08:13:33Z",
"time_3h_ago": "2025-04-10T06:13:33Z",
"time_ago": "2025-04-07T09:13:33Z"
}
Video Tutorials
Get Pancakeswap Token Trade Metrics using Bitquery API
How to get PancakeSwap trades in realtime
Frequently Asked Questions
How do I query PancakeSwap trades on BSC?
Use EVM.DEXTrades with network bsc and filter Trade.Dex.OwnerAddress to the PancakeSwap factory: 0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865 for v3 or 0xca143ce32fe78f1f7019d7d551a6402fc5350c73 for v2. ProtocolName works for v3 (pancake_swap_v3) but not for v2, whose trades carry the uniswap_v2 label.
Does Bitquery cover PancakeSwap v3 pools?
Yes. The trade and pool examples on this page use PancakeSwap v3. For v2, swap in its factory address, 0xca143ce32fe78f1f7019d7d551a6402fc5350c73.
Can I stream PancakeSwap trades live?
Use GraphQL subscriptions on EVM.DEXTrades or Kafka EVM protobuf streams for production pipelines.
Ready to run this in production?
Get an API key and run these queries in minutes, or talk to us about plans and enterprise delivery.