Tron DEX Trades API
In this section we will see how to get Tron DEX trades information using our API.
Subscribe to Latest Tron Trades​
This subscription will return information about the most recent trades executed on Tron's DEX platforms. You can try the query here
subscription {
Tron {
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 {
Fungible
Decimals
Name
Native
SmartContract
Symbol
}
}
}
}
}
}
Get Token Stats like buyers, sellers, makers, total trades, total volume, buy volume, sell volume​
This query fetches you all the important token statistics such as number of buyers, sellers, makers, total trades, total volume, buy volume, sell volume. Try the query here
query MyQuery( $token: String,$pairAddress: String , $min5_timestamp: DateTime, $hr1_timestamp: DateTime) {
Tron {
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}}}
)
}
}
}
{
"token": "put token address here",
"pairAddress": "put pair address here",
"hr1_timestamp": "2024-11-14T03:20:00Z",
"min5_timestamp": "2024-11-14T04:15:00Z"
}
Get Top gainer tokens on Tron Network​
This query fetches you the top gainer tokens on Tron network. You can try the query here.
{
Tron {
DEXTradeByTokens(
where: {Transaction: {Result: {Success: true}}}
orderBy: {descendingByField: "usd"}
limit: {count: 100}
) {
Trade {
Currency {
Symbol
Name
SmartContract
}
Side {
Currency {
Symbol
Name
SmartContract
}
}
price_last: PriceInUSD(maximum: Block_Number)
price_1h_ago: PriceInUSD(minimum: Block_Number)
}
dexes: uniq(of: Trade_Dex_OwnerAddress)
amount: sum(of: Trade_Side_Amount)
usd: sum(of: Trade_Side_AmountInUSD)
buyers: uniq(of: Trade_Buyer)
sellers: uniq(of: Trade_Seller)
count(selectWhere: {ge: "100"})
}
}
}
You can check the data here on DEXrabbit.
Get Top bought tokens on Tron Network​
This query fetches you the top bought tokens on Tron network. You can try the query here.
{
Tron {
DEXTradeByTokens(
orderBy: {descendingByField: "buy"}
where: {Transaction: {Result: {Success: true}}}
limit: {count: 100}
) {
Trade {
Currency {
Symbol
Name
SmartContract
}
}
buy: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: buy}}}})
sell: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: sell}}}})
}
}
}
Arranged in the descending order of bought - sold
on DEXrabbit.
You can check the data here on DEXrabbit.
Get Top sold tokens on Tron Network​
This query fetches you the top sold tokens on Tron network. You can try the query here.
{
Tron {
DEXTradeByTokens(
orderBy: {descendingByField: "sell"}
where: {Transaction: {Result: {Success: true}}}
limit: {count: 100}
) {
Trade {
Currency {
Symbol
Name
SmartContract
}
}
buy: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: buy}}}})
sell: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: sell}}}})
}
}
}
Arranged in the descending order of sold - bought
on DEXrabbit.
You can check the data here on DEXrabbit.
Get OHLC data of a token on Tron Network​
This query fetches you the OHLC data of a specific token on Tron network. You can try the query here.
query tradingViewPairs($token: String, $base: String) {
Tron {
DEXTradeByTokens(
orderBy: {ascendingByField: "Block_Time"}
where: {Trade: {Side: {Amount: {gt: "0"}, Currency: {SmartContract: {is: $base}}}, Currency: {SmartContract: {is: $token}}, PriceAsymmetry: {lt: 0.1}}}
) {
Block {
Time(interval: {count: 5, in: minutes})
}
Trade {
open: PriceInUSD(minimum: Block_Number)
close: PriceInUSD(maximum: Block_Number)
max: PriceInUSD(maximum: Trade_PriceInUSD)
min: PriceInUSD(minimum: Trade_PriceInUSD)
}
volume: sum(of: Trade_Side_Amount)
}
}
}
{
"token": "TJ9mxWPmQSJswqMakEehFWcAntg73odiAq",
"base": "TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR"
}
You can check the data here on DEXrabbit.
Get Latest Trades of a token on Tron Network​
This query fetches you the latest trades of a specific token on Tron network. You can try the query here.
query LatestTrades($token: String, $base: String) {
Tron {
DEXTradeByTokens(
orderBy: {descending: Block_Time}
limit: {count: 50}
where: {Trade: {Side: {Amount: {gt: "0"}, Currency: {SmartContract: {is: $base}}}, Currency: {SmartContract: {is: $token}}, Price: {gt: 0}}, Transaction: {Result: {Success: true}}}
) {
Block {
allTime: Time
}
Trade {
Dex {
OwnerAddress
ProtocolFamily
ProtocolName
}
Currency {
Symbol
SmartContract
Name
}
Price
AmountInUSD
Amount
Side {
Type
Currency {
Symbol
SmartContract
Name
}
AmountInUSD
Amount
}
}
}
}
}
{
"token": "TJ9mxWPmQSJswqMakEehFWcAntg73odiAq",
"base": "TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR"
}
You can check the data here on DEXrabbit.
Get Top Traders of a token on Tron Network​
This query fetches you the top traders of a specific token on Tron network. You can try the query here.
query TopTraders($token: String, $base: String) {
Tron {
DEXTradeByTokens(
orderBy: {descendingByField: "volumeUsd"}
limit: {count: 100}
where: {Trade: {Currency: {SmartContract: {is: $token}}, Side: {Amount: {gt: "0"}, Currency: {SmartContract: {is: $base}}}}, Transaction: {Result: {Success: true}}}
) {
Trade {
Dex {
OwnerAddress
ProtocolFamily
ProtocolName
}
}
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)
}
}
}
{
"token": "TJ9mxWPmQSJswqMakEehFWcAntg73odiAq",
"base": "TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR"
}
You can check the data here on DEXrabbit.
Get Top Buyers of a token on Tron Network​
This query fetches you the top 10 buyers of a specific token on Tron network. You can try the query here.
{
Tron {
DEXTradeByTokens(
orderBy: {descendingByField: "bought"}
limit: {count: 10}
where: {Trade: {Currency: {SmartContract: {is: "TXL6rJbvmjD46zeN1JssfgxvSo99qC8MRT"}}}, TransactionStatus: {Success: true}}
) {
Trade {
Buyer
Currency {
Symbol
Name
SmartContract
}
}
bought: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: sell}}}})
}
}
}
Get Top Sellers of a token on Tron Network​
This query fetches you the top 10 sellers of a specific token on Tron network. You can try the query here.
{
Tron {
DEXTradeByTokens(
orderBy: {descendingByField: "sold"}
limit: {count: 10}
where: {Trade: {Currency: {SmartContract: {is: "TXL6rJbvmjD46zeN1JssfgxvSo99qC8MRT"}}}, TransactionStatus: {Success: true}}
) {
Trade {
Buyer
Currency {
Symbol
Name
SmartContract
}
}
sold: sum(of: Trade_Side_AmountInUSD, if: {Trade: {Side: {Type: {is: buy}}}})
}
}
}
Get DEX markets for a specific Token​
This query fetches you the DEXs where a specific token is being traded on Tron network. You can try the query here.
query ($token: String, $base: String, $time_10min_ago: DateTime, $time_1h_ago: DateTime, $time_3h_ago: DateTime) {
Tron {
DEXTradeByTokens(
orderBy: {descendingByField: "amount"}
where: {Trade: {Currency: {SmartContract: {is: $token}}, Side: {Amount: {gt: " "}, Currency: {SmartContract: {is: $base}}}}, Transaction: {Result: {Success: true}}, Block: {Time: {after: $time_3h_ago}}}
) {
Trade {
Dex {
ProtocolFamily
ProtocolName
}
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(minimum: Block_Number)
}
amount: sum(of: Trade_Side_Amount)
pairs: uniq(of: Trade_Side_Currency_SmartContract)
trades: count
}
}
}
{
"token": "TSig7sWzEL2K83mkJMQtbyPpiVSbR6pZnb",
"base": "TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR",
"time_10min_ago": "2024-09-20T08:36:40Z",
"time_1h_ago": "2024-09-20T07:46:40Z",
"time_3h_ago": "2024-09-20T05:46:40Z"
}
You can check the data here on DEXrabbit.
Get All DEXs info on Tron network​
This query fetches you all the DEXs information on Tron network such as unique sellers, unique buyers etc. You can try the query here.
query DexMarkets {
Tron {
DEXTradeByTokens {
Trade {
Dex {
ProtocolFamily
}
}
buyers: uniq(of: Trade_Buyer)
sellers: uniq(of: Trade_Sender)
count(if: {Trade: {Side: {Type: {is: buy}}}})
}
}
}
You can check the data here on DEXrabbit.
Get Top Traders on Tron network​
This query fetches you TOp Traders information on Tron network. You can try the query here.
query DexMarkets {
Tron {
DEXTradeByTokens(orderBy: {descendingByField: "trades"}, limit: {count: 100}) {
Trade {
Dex {
OwnerAddress
}
}
trades: count(if: {Trade: {Side: {Type: {is: buy}}}})
tokens: uniq(of: Trade_Currency_SmartContract)
}
}
}
You can check the data here on DEXrabbit.
Subscribe to Latest Price of a Token in Real-time​
This query provides real-time updates on price of token TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t
in terms of USDT TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t
, including details about the DEX. Try the query here
subscription MyQuery {
Tron {
DEXTradeByTokens(
where: {Trade: {Currency: {SmartContract: {is: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"}}}, TransactionStatus: {Success: true}}
) {
Block {
Time
}
Trade {
Amount
AmountInUSD
Buyer
Price
PriceInUSD
Seller
Currency {
Symbol
SmartContract
Name
}
Dex {
SmartContract
ProtocolName
ProtocolFamily
}
Side {
Amount
AmountInUSD
Buyer
Seller
Currency {
Name
Symbol
SmartContract
}
}
}
}
}
}