Skip to main content

DEXScreener EVM Chains Data

This section will guide you through different APIs which will tell you how to get data like realtime trades, price of a token, buys, sells, sell volume, makers, top holders of a token, liquidity of a pair and many more just like how DEXScreener shows for EVM Chains.

Get the Top Trading Pairs

The query will fetch you the Top Trading Pairs in desceneding order of the total number of trades took place in them just like how DEXScreener shows in its UI. You can check out the video tutorial here to understand the query better.

You can find the query here

query TrendingPairs {
EVM(dataset: combined, network: eth) {
DEXTradeByTokens(
orderBy: {descendingByField: "TradeCount"}
where: {Block: {Time: {since: "2024-06-05T08:08:00Z"}}, TransactionStatus: {Success: true}}
limit: {count: 10}
limitBy: {by: Trade_Dex_Pair_SmartContract, count: 1}
) {
TradeCount: count
Trade {
Dex {
SmartContract
ProtocolName
ProtocolFamily
Pair {
SmartContract
}
}
Currency {
Symbol
SmartContract
}
Side {
Currency {
Symbol
SmartContract
}
}
}
}
}
}


Get Trade Transactions for a particular pair in realtime

The query will subscribe you to real-time trade transactions for a pair, providing a continuous stream of data as new trades are processed and recorded. You can find the query here

subscription{
EVM(network: eth) {
DEXTradeByTokens(
orderBy: {ascending: Block_Time}
where: {Trade: {Currency: {SmartContract: {is: "0x382ea807A61a418479318Efd96F1EFbC5c1F2C21"}}, Side: {Currency: {SmartContract: {is: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"}}}}}
) {
Block{
Time
}
Trade {
Amount
Currency {
Symbol
}
PriceInUSD
Dex {
ProtocolName
SmartContract
}
Side {
Amount
AmountInUSD
Currency {
Symbol
}
Buyer
Seller
}
Buyer
Seller
}
Transaction {
Maker: From
Hash
Type
}
}
}
}


Get Price of a Token

This query will give you the latest Price of a specified token using DEXTrades API. Here we have calculated the price of a token in USD and also against the sell currency. Here is the saved query link

query MyQuery {
EVM(network: eth, dataset: realtime) {
DEXTrades(
limit: {count: 1}
orderBy: {descending: Block_Time}
where: {Trade: {Buy: {Currency: {SmartContract: {is: "0xaaeE1A9723aaDB7afA2810263653A34bA2C21C7a"}}}, Sell: {Currency: {SmartContract: {is: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"}}}, Dex: {Pair: {SmartContract: {is: "0xc2eaB7d33d3cB97692eCB231A5D0e4A649Cb539d"}}}}, TransactionStatus: {Success: true}}
) {
Trade {
Buy {
Currency {
Symbol
}
Price_In_USD: PriceInUSD
Price_against_sell_currency: Price
}
Sell {
Currency {
Symbol
}
}
}
}
}
}


Get Liquidity of a specific pair by using its Pair Address

The below query finds the liquidity of a pool using the pool address 0xc2eaB7d33d3cB97692eCB231A5D0e4A649Cb539d. With this query we can get balance of the pool tokens. And to get the USD Liquidity you can multiply the balances of both the tokens to their respective USD prices and then sum it up.

You can find the query here

query MyQuery {
EVM(dataset: archive, network: eth) {
BalanceUpdates(
where: {BalanceUpdate: {Address: {is: "0xc2eaB7d33d3cB97692eCB231A5D0e4A649Cb539d"}}, Currency: {SmartContract: {in: ["0xaaeE1A9723aaDB7afA2810263653A34bA2C21C7a","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"]}}}
orderBy: {descendingByField: "balance"}
) {
Currency {
Name
}
balance: sum(of: BalanceUpdate_Amount)
}
}
}


Get the Buys, Sells, Buy Volume, Sell Volume and Makers

The query will fetch you the buys, sells, buy volume, sell volume and also the number of makers for a particular token just like how DEXScreener shows in its UI. We are getting these trade metrics for this particular pool address 0x842293fa6ee0642bf61ebf8310e7e546039ba7f4.

You can find the query here

query MyQuery($network: evm_network, $token: String,$pairAddress: String , $min5_timestamp: DateTime, $hr1_timestamp: DateTime) {
EVM(dataset: realtime, network: $network) {
DEXTradeByTokens(
where: {TransactionStatus: {Success: true}, Trade: {Currency: {SmartContract: {is: $token}}, Dex: {SmartContract: {is: $pairAddress}}}, Block: {Time: {since: $hr1_timestamp}}}
) {
Trade {
Currency {
Name
SmartContract
Symbol
}
startPrice: PriceInUSD(minimum: Block_Time)
Price_at_min5: PriceInUSD(
minimum: Block_Time
if: {Block: {Time: {after: $min5_timestamp}}}
)
current_price: PriceInUSD(maximum: Block_Time)
Dex {
ProtocolName
ProtocolFamily
SmartContract
}
Side {
Currency {
Symbol
Name
SmartContract
}
}
}
makers: count(distinct: Transaction_From)
makers_5min: count(
distinct: Transaction_From
if: {Block: {Time: {after: $min5_timestamp}}}
)
buyers: count(
distinct: Transaction_From
if: {Trade: {Side: {Type: {is: sell}}}}
)
buyers_5min: count(
distinct: Transaction_From
if: {Trade: {Side: {Type: {is: sell}}}, Block: {Time: {after: $min5_timestamp}}}
)
sellers: count(
distinct: Transaction_From
if: {Trade: {Side: {Type: {is: buy}}}}
)
sellers_5min: count(
distinct: Transaction_From
if: {Trade: {Side: {Type: {is: buy}}}, Block: {Time: {after: $min5_timestamp}}}
)
trades: count
trades_5min: count(if: {Block: {Time: {after: $min5_timestamp}}})
traded_volume: sum(of: Trade_Side_AmountInUSD)
traded_volume_5min: sum(
of: Trade_Side_AmountInUSD
if: {Block: {Time: {after: $min5_timestamp}}}
)
buy_volume: sum(
of: Trade_Side_AmountInUSD
if: {Trade: {Side: {Type: {is: sell}}}}
)
buy_volume_5min: sum(
of: Trade_Side_AmountInUSD
if: {Trade: {Side: {Type: {is: sell}}}, Block: {Time: {after: $min5_timestamp}}}
)
sell_volume: sum(
of: Trade_Side_AmountInUSD
if: {Trade: {Side: {Type: {is: buy}}}}
)
sell_volume_5min: sum(
of: Trade_Side_AmountInUSD
if: {Trade: {Side: {Type: {is: buy}}}, Block: {Time: {after: $min5_timestamp}}}
)
buys: count(if: {Trade: {Side: {Type: {is: sell}}}})
buys_5min: count(
if: {Trade: {Side: {Type: {is: sell}}}, Block: {Time: {after: $min5_timestamp}}}
)
sells: count(if: {Trade: {Side: {Type: {is: buy}}}})
sells_5min: count(
if: {Trade: {Side: {Type: {is: buy}}}, Block: {Time: {after: $min5_timestamp}}}
)
}
}
}
{
"network": "eth",
"token": "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
"pairAddress": "0xA43fe16908251ee70EF74718545e4FE6C5cCEc9f",
"hr1_timestamp": "2024-11-14T03:20:00Z",
"min5_timestamp": "2024-11-14T04:15:00Z"
}

Video Tutorial on How to Get EVM Chains Trades Data just like DEXScreener from Bitquery API

Video Tutorial on How to Get USD Price of a pool Token and Liquidity of the Pool just like DEXScreener shows

Video Tutorial on How to Get Buys, Sells, Buy Volume, Sell Volume, and Makers for EVM Chains just like DEXScreener

Video Tutorial on How to Get Top Trading Pairs for EVM Chains just like DEXScreener