Solana DEX Trades API
In this section we will see how to get Solana DEX trades information using our API.
This Solana API is part of our Early Access Program (EAP), which is intended for evaluation purposes. This program allows you to test the data and its integration into your applications before full-scale implementation. Read more here
Subscribe to Latest Solana Trades
This subscription will return information about the most recent trades executed on Solana's DEX platforms. You can find the query here
subscription {
Solana {
DEXTrades {
Trade {
Dex {
ProgramAddress
ProtocolFamily
ProtocolName
}
Buy {
Amount
Account {
Address
}
Currency {
MetadataAddress
Key
IsMutable
EditionNonce
Decimals
CollectionAddress
Fungible
Symbol
Native
Name
}
Order {
LimitPrice
LimitAmount
OrderId
}
Price
}
Market {
MarketAddress
}
Sell {
Account {
Address
}
Currency {
IsMutable
Decimals
CollectionAddress
Fungible
Symbol
Native
Name
}
Price
}
}
}
}
}
Get Latest Trades of a token
This query will return information about the most recent trades executed for this token CzLSujWBLFsSjncfkh59rUFqvafWcY5tzedWJSuypump
on Solana's DEX platforms.
You can find the query here
query LatestTrades($token: String, $base: String) {
Solana {
DEXTradeByTokens(
orderBy: {descending: Block_Time}
limit: {count: 50}
where: {Trade: {Side: {Amount: {gt: "0"}, Currency: {MintAddress: {is: $base}}}, Currency: {MintAddress: {is: $token}}, Price: {gt: 0}}, Transaction: {Result: {Success: true}}}
) {
Block {
allTime: Time
}
Trade {
Dex {
ProgramAddress
ProtocolFamily
ProtocolName
}
Account {
Owner
}
Side {
Type
Account {
Address
Owner
}
}
Price
Amount
Side {
Currency {
Symbol
MintAddress
Name
}
AmountInUSD
Amount
}
}
}
}
}
{
"token": "CzLSujWBLFsSjncfkh59rUFqvafWcY5tzedWJSuypump",
"base": "So11111111111111111111111111111111111111112"
}
Check data here on DEXrabbit.
Get Trade Summary of a Trade
A lot of times a trade is implemented using multiple swaps. The summary of these trades are the token originally sold and the token finally purchased. To get the summary for such trades use this query.
{
Solana {
DEXTrades(
where: {Transaction: {Signer: {is: "9B4okPpQcz1MSt8cLLb7YGo2NKvgsw82pEhHqKsKW9uS"}, Result: {Success: true}}}
orderBy: {descending: Block_Time}
) {
Trade {
Buy {
Amount
PriceInUSD
Currency {
Decimals
Name
MintAddress
Symbol
}
Account {
Address
Owner
}
}
Dex {
ProgramAddress
ProtocolFamily
ProtocolName
}
Sell {
Amount
Price
Currency {
Name
Symbol
MintAddress
Decimals
}
}
Index
}
Transaction {
Signature
Result {
Success
}
}
Block {
Time
}
}
}
}
The response of the query is given below. Given multiple trades with same Block Time
, the summary is
given by the sell currency
for the lowest Trade Index and the buy currency
for the highest Trade Index.
{
"Block": {
"Time": "2024-11-12T05:56:55Z"
},
"Trade": {
"Buy": {
"Account": {
"Address": "FJnivW3jSXVuR2P6Z6e9iRkVHEyEzppHcnUdMgsLBSgY",
"Owner": "4xDsmeTWPNjgSVSS1VTfzFq3iHZhp77ffPkAmkZkdu71"
},
"Amount": "7599.73089",
"Currency": {
"Decimals": 5,
"MintAddress": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"Name": "Bonk",
"Symbol": "Bonk"
},
"PriceInUSD": 0.000028919810335657223
},
"Dex": {
"ProgramAddress": "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo",
"ProtocolFamily": "Meteora",
"ProtocolName": "lb_clmm"
},
"Index": 0,
"Sell": {
"Amount": "0.219833",
"Currency": {
"Decimals": 6,
"MintAddress": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"Name": "USD Coin",
"Symbol": "USDC"
},
"Price": 34570.47345030091
}
},
"Transaction": {
"Result": {
"Success": true
},
"Signature": "43aymSmr2op2aEnCiMfzkqqfpWwSofWk8EBcUWhKEUsHRrZV4KpTGW4iuxLxJyS1HKoLS7gTamzuqKiwi3e3z4Li"
}
},
{
"Block": {
"Time": "2024-11-12T05:56:55Z"
},
"Trade": {
"Buy": {
"Account": {
"Address": "6zAcFYmxkaH25qWZW5ek4dk4SyQNpSza3ydSoUxjTudD",
"Owner": "4xDsmeTWPNjgSVSS1VTfzFq3iHZhp77ffPkAmkZkdu71"
},
"Amount": "0.001015898",
"Currency": {
"Decimals": 9,
"MintAddress": "So11111111111111111111111111111111111111112",
"Name": "Wrapped Solana",
"Symbol": "WSOL"
},
"PriceInUSD": 210.759146972229
},
"Dex": {
"ProgramAddress": "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo",
"ProtocolFamily": "Meteora",
"ProtocolName": "lb_clmm"
},
"Index": 1,
"Sell": {
"Amount": "7599.73089",
"Currency": {
"Decimals": 5,
"MintAddress": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"Name": "Bonk",
"Symbol": "Bonk"
},
"Price": 1.336755228184139e-7
}
},
"Transaction": {
"Result": {
"Success": true
},
"Signature": "43aymSmr2op2aEnCiMfzkqqfpWwSofWk8EBcUWhKEUsHRrZV4KpTGW4iuxLxJyS1HKoLS7gTamzuqKiwi3e3z4Li"
}
}
Get the historical Created pairs on any Solana DEX
This query will return information about the historical created pairs according to the selected date frame. You can find the query here
query{
Solana(dataset: archive) {
DEXTradeByTokens(
where: {
Trade: {
Dex: {
ProtocolFamily: {
is: "Raydium"
}
}
}
}
limit: {
count: 100
}) {
Block {
Date(minimum: Block_Date
selectWhere: {
since: "2024-10-01"
till: "2024-11-01"
})
}
Trade {
Dex {
ProtocolFamily
}
Market{
MarketAddress
}
Currency {
Symbol
MintAddress
}
Side {
Currency {
Symbol
MintAddress
}
}
}
}
}
}
Get Buy Volume, Sell Volume, Buys, Sells, Makers, Total Trade Volume, Buyers, Sellers of a specific Token
The below query gives you the essential stats for a token such as buy volume, sell volume, total buys, total sells, makers, total trade volume, buyers, sellers (in last 5 min, 1 hour) of a specific token. You can run the query here
query MyQuery($token: String!, $side_token: String!, $pair_address: String!, $time_5min_ago: DateTime!, $time_1h_ago: DateTime!) {
Solana(dataset: realtime) {
DEXTradeByTokens(
where: {Transaction: {Result: {Success: true}}, Trade: {Currency: {MintAddress: {is: $token}}, Side: {Currency: {MintAddress: {is: $side_token}}}, Market: {MarketAddress: {is: $pair_address}}}, Block: {Time: {since: $time_1h_ago}}}
) {
Trade {
Currency {
Name
MintAddress
Symbol
}
start: PriceInUSD(minimum: Block_Time)
min5: PriceInUSD(
minimum: Block_Time
if: {Block: {Time: {after: $time_5min_ago}}}
)
end: PriceInUSD(maximum: Block_Time)
Dex {
ProtocolName
ProtocolFamily
ProgramAddress
}
Market {
MarketAddress
}
Side {
Currency {
Symbol
Name
MintAddress
}
}
}
makers: count(distinct: Transaction_Signer)
makers_5min: count(
distinct: Transaction_Signer
if: {Block: {Time: {after: $time_5min_ago}}}
)
buyers: count(
distinct: Transaction_Signer
if: {Trade: {Side: {Type: {is: buy}}}}
)
buyers_5min: count(
distinct: Transaction_Signer
if: {Trade: {Side: {Type: {is: buy}}}, Block: {Time: {after: $time_5min_ago}}}
)
sellers: count(
distinct: Transaction_Signer
if: {Trade: {Side: {Type: {is: sell}}}}
)
sellers_5min: count(
distinct: Transaction_Signer
if: {Trade: {Side: {Type: {is: sell}}}, Block: {Time: {after: $time_5min_ago}}}
)
trades: count
trades_5min: count(if: {Block: {Time: {after: $time_5min_ago}}})
traded_volume: sum(of: Trade_Side_AmountInUSD)
traded_volume_5min: sum(
of: Trade_Side_AmountInUSD
if: {Block: {Time: {after: $time_5min_ago}}}
)
buy_volume: sum(
of: Trade_Side_AmountInUSD
if: {Trade: {Side: {Type: {is: buy}}}}
)
buy_volume_5min: sum(
of: Trade_Side_AmountInUSD
if: {Trade: {Side: {Type: {is: buy}}}, Block: {Time: {after: $time_5min_ago}}}
)
sell_volume: sum(
of: Trade_Side_AmountInUSD
if: {Trade: {Side: {Type: {is: sell}}}}
)
sell_volume_5min: sum(
of: Trade_Side_AmountInUSD
if: {Trade: {Side: {Type: {is: sell}}}, Block: {Time: {after: $time_5min_ago}}}
)
buys: count(if: {Trade: {Side: {Type: {is: buy}}}})
buys_5min: count(
if: {Trade: {Side: {Type: {is: buy}}}, Block: {Time: {after: $time_5min_ago}}}
)
sells: count(if: {Trade: {Side: {Type: {is: sell}}}})
sells_5min: count(
if: {Trade: {Side: {Type: {is: sell}}}, Block: {Time: {after: $time_5min_ago}}}
)
}
}
}
{
"token":"2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump",
"side_token": ""So11111111111111111111111111111111111111112",
"pair_address: "4AZRPNEfCJ7iw28rJu5aUyeQhYcvdcNm8cswyL51AY9i",
"time_5min_ago":"2024-11-06T15:13:00Z",
"time_1h_ago": "2024-11-06T14:18:00Z"
}
Top 10 Trending Solana Tokens
This query returns the top 10 trending tokens on Solana across all DEXs based on the number of trades with unique traders.
This query returns the trending list of tokens for a particular time period, 1 hour
in this case.
query TrendingTokens {
Solana {
DEXTradeByTokens(
limit: { count: 10 }
orderBy: { descendingByField: "tradesCountWithUniqueTraders" }
) {
Trade {
Currency {
Name
Symbol
MintAddress
}
}
tradesCountWithUniqueTraders: count(distinct: Transaction_Signer)
}
}
}
You can also checkout how such queries are used as a base to completed features such as DEXrabbit Solana Trends as shown in the image below.
Top Traders of a token
This query will give you top traders for this token 59VxMU35CaHHBTndQQWDkChprM5FMw7YQi5aPE5rfSHN
on Solana's DEX platforms.
You can find the query here
query TopTraders($token: String, $base: String) {
Solana {
DEXTradeByTokens(
orderBy: {descendingByField: "volumeUsd"}
limit: {count: 100}
where: {Trade: {Currency: {MintAddress: {is: $token}}, Side: {Amount: {gt: "0"}, Currency: {MintAddress: {is: $base}}}}, Transaction: {Result: {Success: true}}}
) {
Trade {
Account {
Owner
}
Dex {
ProgramAddress
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": "59VxMU35CaHHBTndQQWDkChprM5FMw7YQi5aPE5rfSHN",
"base": "So11111111111111111111111111111111111111112"
}
Check data here on DEXrabbit.
Get DEX Markets for a Token
This query will give you Solana DEXs on which the token 59VxMU35CaHHBTndQQWDkChprM5FMw7YQi5aPE5rfSHN
is getting traded.
You can find the query here
query ($token: String, $base: String, $time_10min_ago: DateTime, $time_1h_ago: DateTime, $time_3h_ago: DateTime) {
Solana {
DEXTradeByTokens(
orderBy: {descendingByField: "amount"}
where: {Trade: {Currency: {MintAddress: {is: $token}}, Side: {Amount: {gt: "0"}, Currency: {MintAddress: {is: $base}}}}, Transaction: {Result: {Success: true}}, Block: {Time: {after: $time_3h_ago}}}
) {
Trade {
Dex {
ProtocolFamily
ProtocolName
}
price_last: PriceInUSD(maximum: Block_Slot)
price_10min_ago: PriceInUSD(
maximum: Block_Slot
if: {Block: {Time: {before: $time_10min_ago}}}
)
price_1h_ago: PriceInUSD(
maximum: Block_Slot
if: {Block: {Time: {before: $time_1h_ago}}}
)
price_3h_ago: PriceInUSD(minimum: Block_Slot)
}
amount: sum(of: Trade_Side_Amount)
pairs: uniq(of: Trade_Side_Currency_MintAddress)
trades: count
}
}
}
{
"token": "59VxMU35CaHHBTndQQWDkChprM5FMw7YQi5aPE5rfSHN",
"base": "So11111111111111111111111111111111111111112",
"time_10min_ago": "2024-09-19T10:45:46Z",
"time_1h_ago": "2024-09-19T09:55:46Z",
"time_3h_ago": "2024-09-19T07:55:46Z"
}
Check data here on DEXrabbit.
Get Top Bought Tokens on Solana
This query will give you most bought Solana Tokens on Raydium. You can find the query here
{
Solana {
DEXTradeByTokens(
orderBy: {descendingByField: "buy"}
where: {Trade: {Currency: {MintAddress: {notIn: ["So11111111111111111111111111111111111111112", "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"]}}, Dex: {ProtocolFamily: {is: "Raydium"}}}, Transaction: {Result: {Success: true}}}
limit: {count: 100}
) {
Trade {
Currency {
Symbol
Name
MintAddress
}
}
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.
Check data here on DEXrabbit.
Get Top Sold Tokens on Solana
This query will give you most sold Solana Tokens on Raydium. You can find the query here
{
Solana {
DEXTradeByTokens(
orderBy: {descendingByField: "sell"}
where: {Trade: {Currency: {MintAddress: {notIn: ["So11111111111111111111111111111111111111112", "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"]}}, Dex: {ProtocolFamily: {is: "Raydium"}}}, Transaction: {Result: {Success: true}}}
limit: {count: 100}
) {
Trade {
Currency {
Symbol
Name
MintAddress
}
}
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.
Check data here on DEXrabbit.
Get Top Traded Pairs
This query will give you top traded pairs data. You can find the query here
query ($time_10min_ago: DateTime, $time_1h_ago: DateTime, $time_3h_ago: DateTime) {
Solana {
DEXTradeByTokens(
where: {Transaction: {Result: {Success: true}}, Block: {Time: {after: $time_3h_ago}}, any: [{Trade: {Side: {Currency: {MintAddress: {is: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"}}}}}, {Trade: {Currency: {MintAddress: {not: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"}}, Side: {Currency: {MintAddress: {is: "So11111111111111111111111111111111111111112"}}}}}, {Trade: {Currency: {MintAddress: {notIn: ["So11111111111111111111111111111111111111112", "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"]}}, Side: {Currency: {MintAddress: {notIn: ["So11111111111111111111111111111111111111112", "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"]}}}}}]}
orderBy: {descendingByField: "usd"}
limit: {count: 100}
) {
Trade {
Currency {
Symbol
Name
MintAddress
}
Side {
Currency {
Symbol
Name
MintAddress
}
}
price_last: PriceInUSD(maximum: Block_Slot)
price_10min_ago: PriceInUSD(
maximum: Block_Slot
if: {Block: {Time: {before: $time_10min_ago}}}
)
price_1h_ago: PriceInUSD(
maximum: Block_Slot
if: {Block: {Time: {before: $time_1h_ago}}}
)
price_3h_ago: PriceInUSD(minimum: Block_Slot)
}
dexes: uniq(of: Trade_Dex_ProgramAddress)
amount: sum(of: Trade_Side_Amount)
usd: sum(of: Trade_Side_AmountInUSD)
traders: uniq(of: Trade_Account_Owner)
count(selectWhere: {ge: "100"})
}
}
}
{
"time_10min_ago": "2024-09-19T12:26:17Z",
"time_1h_ago": "2024-09-19T11:36:17Z",
"time_3h_ago": "2024-09-19T09:36:17Z"
}
Check data here on DEXrabbit.
Get Top DEXs information
This query will give you top DEXs info. You can find the query here
query DexMarkets {
Solana {
DEXTradeByTokens {
Trade {
Dex {
ProtocolFamily
}
}
traders: uniq(of: Trade_Account_Owner)
count(if: {Trade: {Side: {Type: {is: buy}}}})
}
DEXPools {
Pool {
Dex {
ProtocolFamily
}
}
pools: uniq(of: Pool_Market_MarketAddress)
}
}
}
Check data here on DEXrabbit.
Get All Traded Pairs Info of a Token
This query will give you the information on all the traded pairs of a particular token EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm
.
You can find the query here
query ($token: String, $time_10min_ago: DateTime, $time_1h_ago: DateTime, $time_3h_ago: DateTime) {
Solana {
DEXTradeByTokens(
orderBy: {descendingByField: "usd"}
where: {Trade: {Currency: {MintAddress: {is: $token}}}, Transaction: {Result: {Success: true}}, Block: {Time: {after: $time_3h_ago}}}
limit: {count: 200}
) {
Trade {
Currency {
Symbol
Name
MintAddress
Fungible
}
Side {
Currency {
Symbol
Name
MintAddress
}
}
price_usd: PriceInUSD(maximum: Block_Slot)
price_last: Price(maximum: Block_Slot)
price_10min_ago: Price(
maximum: Block_Slot
if: {Block: {Time: {before: $time_10min_ago}}}
)
price_1h_ago: Price(
maximum: Block_Slot
if: {Block: {Time: {before: $time_1h_ago}}}
)
price_3h_ago: PriceInUSD(minimum: Block_Slot)
}
usd: sum(of: Trade_AmountInUSD)
count
}
}
}
{
"token": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",
"time_10min_ago": "2024-09-19T12:02:23Z",
"time_1h_ago": "2024-09-19T11:12:23Z",
"time_3h_ago": "2024-09-19T09:12:23Z"
}
Check data here on DEXrabbit.
Get all DEXes
To get the list of all DEXes operating within the Solana ecosystem, use the following query. Find the query here
query MyQuery {
Solana {
DEXTrades(limitBy: {by: Trade_Dex_ProtocolFamily, count: 1}, limit: {count: 10}) {
Trade {
Dex {
ProgramAddress
ProtocolFamily
ProtocolName
}
}
}
}
}
Get Solana DEX Orders in Real-Time
This query provides real-time updates on order events, including details about the DEX, market, and order specifics. You can run the query here
subscription {
Solana {
DEXOrders {
Instruction {
Index
Program {
Address
AccountNames
Name
Method
}
}
OrderEvent {
Dex {
ProtocolName
ProtocolFamily
ProgramAddress
}
Index
Market {
MarketAddress
CoinToken {
Wrapped
VerifiedCollection
Uri
UpdateAuthority
TokenStandard
Symbol
TokenCreator {
Share
Address
}
Name
Key
Fungible
CollectionAddress
}
PriceToken {
Wrapped
VerifiedCollection
Uri
TokenStandard
Native
Name
MetadataAddress
Key
Fungible
Decimals
CollectionAddress
}
}
Order {
BuySide
Account
Payer
OrderId
Owner
}
Type
}
}
}
}
Get Latest Price of a Token in Real-time
This query provides real-time trade, including details about the DEX, market, and order specifics. Find the query here
To get the most real-time price, you can use this query, which orders transactions based on the transaction_index. Since a block can have multiple trades of the same pair, using the latest transaction based on the transaction_index will provide the most current price.
subscription {
Solana {
DEXTradeByTokens(
where: {Trade: {Currency: {MintAddress: {is: "6n7Janary9fqzxKaJVrhL9TG2F61VbAtwUMu1YZscaQS"}}, Side: {Currency: {MintAddress: {is: "So11111111111111111111111111111111111111112"}}}}}
) {
Block {
Time
}
Trade {
Amount
Price
Currency {
Symbol
Name
MintAddress
}
Side {
Amount
Currency {
Symbol
Name
MintAddress
}
}
Dex {
ProgramAddress
ProtocolFamily
ProtocolName
}
Market {
MarketAddress
}
Order {
LimitAmount
LimitPrice
OrderId
}
}
}
}
}
Latest USD Price of a Token
The below query retrieves the USD price of a token on Solana by setting SmartContract: {is: "So11111111111111111111111111111111111111112"}
. Check the field PriceInUSD
for the USD value. You can access the query here.
subscription {
Solana {
DEXTradeByTokens(
where: {Trade: {Currency: {MintAddress: {is: "So11111111111111111111111111111111111111112"}}}}
) {
Transaction {
Signature
}
Trade {
AmountInUSD
Amount
Currency {
MintAddress
Name
}
Dex {
ProgramAddress
ProtocolName
}
Price
PriceInUSD
Side {
Account {
Address
}
AmountInUSD
Amount
Currency {
Name
MintAddress
}
}
}
}
}
}
Get all the Tokens owned by an address
The below query retrieves the token addresses and their balances owned by a particular account address You can access the query here.
query MyQuery {
Solana {
BalanceUpdates(
where: {BalanceUpdate: {Account: {Owner: {is: "61DR2QJRi47X4dzNPU626mJVWfMPKs5Rs5D7pHVjtXPt"}}}}
orderBy: {descendingByField: "BalanceUpdate_Balance_maximum"}
) {
BalanceUpdate {
Balance: PostBalance(maximum: Block_Slot)
Currency {
Name
Symbol
}
}
}
}
}
Get the First 100 buyers of a Token
The below query retrieves the first 100 buyers of a secified token. You can run the query here
query MyQuery {
Solana {
DEXTrades(
where: {
Trade: {
Buy: {
Currency: {
MintAddress: {
is: "2Z4FzKBcw48KBD2PaR4wtxo4sYGbS7QqTQCLoQnUpump"
}
}
}
}
}
limit: { count: 100 }
orderBy: { ascending: Block_Time }
) {
Trade {
Buy {
Amount
Account {
Token {
Owner
}
}
}
}
}
}
}
Get the Token details like Update Authority, decimals, URI, is Mutable or not
The below query retrieves the token details such as update authority for a particular token and also checks if a token's data is mutable or not. You can access the query here.
query MyQuery {
Solana {
DEXTradeByTokens(
where: {Trade: {Currency: {MintAddress: {is: "AREn4LyUS4pNUGzwXcks7oefjT751G1XwYZ4GLTppump"}}}, Transaction: {Result: {Success: true}}}
orderBy: {descending: Block_Time}
limit: {count: 1}
) {
Trade {
Currency {
Uri
UpdateAuthority
Name
IsMutable
}
}
}
}
}
Solana OHLC API
You can query OHLC data in for any Solana token. In the below query we are fetching OHLC information for the pair Shark Cat-SOL by using the smart contract addresses in the MintAddress
filter. Only use this API as query
and not subscription
websocket as Aggregates and Time Intervals don't work well with subscriptions.
You can run and test the saved query here.
{
Solana {
DEXTradeByTokens(
orderBy: {descendingByField: "Block_Timefield"}
where: {Trade: {Currency: {MintAddress: {is: "6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui"}}, Side: {Currency: {MintAddress: {is: "So11111111111111111111111111111111111111112"}}}}}
limit: {count: 10}
) {
Block {
Timefield: Time(interval: {in: minutes, count: 1})
}
volume: sum(of: Trade_Amount)
Trade {
high: Price(maximum: Trade_Price)
low: Price(minimum: Trade_Price)
open: Price(minimum: Block_Slot)
close: Price(maximum: Block_Slot)
}
count
}
}
}
Check data here on DEXrabbit.
Solana Real time prices from multiple Markets
You can retrieve data from multiple Solana DEX markets using our APIs or streams. The following query demonstrates how to do this. However, there's a caveat: since we are not specifying the buy or sell currency in the filters, the query will display both currencies on the buy side (or sell side). This happens because both currencies are traded within the pool. If you want the price of only one asset, you can define it in the filter. ere is an example from the same markets, where we specified that we need trades when the buy currency is defined.
subscription {
Solana {
DEXTrades(
where: {Transaction: {Result: {Success: true}}, Trade: {Market: {MarketAddress: {in: ["5qrvgpvr55Eo7c5bBcwopdiQ6TpvceiRm42yjHTbtDvc", "FpCMFDFGYotvufJ7HrFHsWEiiQCGbkLCtwHiDnh7o28Q"]}}}}
) {
average(of: Trade_Buy_Price)
Trade {
Buy {
Currency {
Name
Symbol
MintAddress
}
}
}
}
}
}
Using Pre-Made Aggregates in Solana DEX Trades
When querying Solana DEXTradeByTokens, you can use pre-made aggregates to optimize performance. The aggregates
flag provides three options to control the use of these aggregates:
aggregates: only
: This option uses only the pre-made aggregates, which can significantly increase the speed of the response.aggregates: yes
: This option uses both pre-made aggregates and individual transaction data.aggregates: no
: This option does not use any pre-made aggregates.
When using the aggregates: only option, you need to include the mintaddress field in the response to ensure proper aggregation and filtering.
{
Solana(aggregates: only) {
DEXTradeByTokens(
orderBy: {descendingByField: "Block_Timefield"}
where: {Trade: {Currency: {MintAddress: {is: "6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui"}}, Side: {Currency: {MintAddress: {is: "So11111111111111111111111111111111111111112"}}}}}
limit: {count: 10}
) {
Block {
Timefield: Time(interval: {in: minutes, count: 1})
}
volume: sum(of: Trade_Amount)
Trade {
high: Price(maximum: Trade_Price)
low: Price(minimum: Trade_Price)
open: Price(minimum: Block_Slot)
close: Price(maximum: Block_Slot)
Currency {
MintAddress
}
}
count
}
}
}