Skip to main content

BSC DEX Trades API

In this section we will see how to get BSC DEX trades information using our API.

Subscribe to Latest BSC Trades​

This subscription will return information about the most recent trades executed on BSC's DEX platforms. You can find the query here

subscription {
EVM(network: bsc) {
DEXTrades {
Block {
Time
}
Trade {
Dex {
ProtocolName
ProtocolFamily
SmartContract
}
Buy {
Amount
Buyer
Seller
Currency {
Decimals
Fungible
HasURI
Name
ProtocolName
SmartContract
Symbol
}
OrderId
}
Sell {
Buyer
Seller
Currency {
Decimals
Fungible
HasURI
Name
ProtocolName
SmartContract
Symbol
}
}
}
}
}
}


Get all DEXs on BSC Network​

This query retrieves all the DEXes operating on BSC network and gives info such as ProtocolName , ProtocolVersion and ProtocolFamily. Find the query here.

query MyQuery {
EVM(network: bsc, dataset: realtime) {
DEXTrades {
Trade {
Dex {
ProtocolName
ProtocolVersion
ProtocolFamily
}
}
count
}
}
}

Subscribe to Latest Price of a Token in Real-time on BSC​

This query provides real-time updates on price of ETH 0x2170Ed0880ac9A755fd29B2688956BD959F933F8 in terms of WBNB 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c, including details about the DEX, market, and order specifics. Find the query here

subscription {
EVM(network: bsc) {
DEXTrades(
where: {Trade: {Sell: {Currency: {SmartContract: {is: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"}}}, Buy: {Currency: {SmartContract: {is: "0x2170Ed0880ac9A755fd29B2688956BD959F933F8"}}}}}
) {
Block {
Time
}
Trade {
Buy {
Amount
AmountInUSD
Buyer
Seller
Price_in_terms_of_sell_currency: Price
PriceInUSD
Currency {
Name
Symbol
SmartContract
}
OrderId
}
Sell {
Amount
Buyer
Seller
Price_in_terms_of_buy_currency: Price
Currency {
Symbol
SmartContract
Name
}
OrderId
}
Dex {
ProtocolFamily
ProtocolName
SmartContract
ProtocolVersion
}
}
}
}
}

Latest USD Price of a Token​

The below query retrieves the USD price of a token on BSC by setting {Trade: {Buy: {Currency: {SmartContract: {is: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"}}}}} . Check the field PriceInUSD for the USD value. You can access the query here.

subscription {
EVM(network: bsc) {
DEXTrades(
where: {Trade: {Buy: {Currency: {SmartContract: {is: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"}}}}}
) {
Block {
Number
Time
}
Transaction {
From
To
Hash
}
Trade {
Buy {
Amount
Buyer
Currency {
Name
Symbol
SmartContract
}
Seller
Price
PriceInUSD
}
Sell {
Amount
Buyer
Currency {
Name
SmartContract
Symbol
}
Seller
Price
}
PriceAsymmetry(selectWhere: {lt: 1})
}
}
}
}

Video Tutorial on BSC DEXTrades API | How to get BSC Decentralized Exchange Data with DEX Trades API​