Solana Raydium API
In this section, we will see how to get Raydium information using Bitquery APIs.
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
New Liquidity Pools Created on Solana Raydium DEX (Using Websocket)
You can subscribe to newly created Solana Raydium liquidity pools using the GraphQL subscription (WebSocket). You can try this GraphQL subscription using this link.
In the results, you can get pool and token details using instructions.
Pool Address
You can find the pool address using the following result: Note that the array index starts from 0. Therefore, it will be the 5th entry.
Instructions -> Instruction -> Accounts[4] -> Address
Token A
You can get the 1st token address using the following result: Note that the array index starts from 0. Therefore, it will be the 9th entry.
Instructions -> Instruction -> Accounts[8] -> Address
Token B
You can get the 2nd token address using the following result.
Instructions -> Instruction -> Accounts[9] ->. Address
You can run the following query at Bitquery IDE.
subscription {
Solana {
Instructions(
where: {
Transaction: { Result: { Success: true } }
Instruction: {
Program: {
Method: { is: "initialize2" }
Address: { is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" }
}
}
}
) {
Block {
Time
Date
}
Transaction {
Signature
}
Instruction {
AncestorIndexes
CallerIndex
Depth
Data
ExternalSeqNumber
InternalSeqNumber
Index
Accounts {
Address
IsWritable
Token {
Mint
Owner
ProgramId
}
}
CallPath
Logs
Program {
AccountNames
Method
Json
Name
Arguments {
Type
Name
Value {
__typename
... on Solana_ABI_Integer_Value_Arg {
integer
}
... on Solana_ABI_String_Value_Arg {
string
}
... on Solana_ABI_Address_Value_Arg {
address
}
... on Solana_ABI_BigInt_Value_Arg {
bigInteger
}
... on Solana_ABI_Bytes_Value_Arg {
hex
}
... on Solana_ABI_Boolean_Value_Arg {
bool
}
... on Solana_ABI_Float_Value_Arg {
float
}
... on Solana_ABI_Json_Value_Arg {
json
}
}
}
}
}
}
}
}
Pair Creation time for a specific pair
You can use the following query to get the pair creation time for a specific pair on Raydium DEX on Solana. But you need to use keyword query
obviously.
You can run this query using this link.
Solana {
Instructions(
where: {Transaction: {Result: {Success: true}}, Instruction: {Program: {Method: {is: "initializeUserWithNonce"}, Address: {is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"}}, Accounts: {includes: {Address: {is: "CSyP9JXCVuVoobWrdtBqQeq7s7VWwNAJ7FFBhLnLFUCE"}}}}}
) {
Block {
Time
}
Transaction {
Signature
}
}
}
}
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
}
}
}
}
}
}
Latest price of a token
You can use the following query to get the latest price of a token on Raydium DEX on Solana.
You can run this query using this link.
{
Solana {
DEXTradeByTokens(
limit: {count: 1}
orderBy: {descending: Block_Time}
where: {Trade: {Dex: {ProgramAddress: {is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"}}, Currency: {MintAddress: {is: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"}}, Side: {Currency: {MintAddress: {is: "So11111111111111111111111111111111111111112"}}}}}
) {
Block {
Time
}
Trade {
Price
PriceInUSD
}
}
}
}
Latest Trades on Solana Raydium DEX
To subscribe to the real-time trades stream for Solana Raydium DEX, try this GraphQL subscription (WebSocket).
subscription {
Solana {
DEXTrades(
where: {
Trade: {
Dex: {
ProgramAddress: {
is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
}
}
}
}
) {
Trade {
Dex {
ProgramAddress
ProtocolFamily
ProtocolName
}
Buy {
Account {
Address
}
Amount
Currency {
MintAddress
Decimals
Symbol
ProgramAddress
Name
}
PriceAgaistSellCurrency: Price
}
Sell {
Account {
Address
}
Amount
Currency {
MintAddress
Decimals
Symbol
Name
}
PriceAgaistBuyCurrency: Price
}
}
Block {
Time
Height
}
Transaction {
Signature
FeePayer
Signer
}
}
}
}
Latest Trades for a specific currency on Solana Raydium DEX
Let's say you want to receive trades only for a specific currency on Raydium DEX. You can use the following stream. Use currency's mint address; for example, in the following query, we are using Ray token's Mint address to get buy and sells of Ray token.
If you limit it to 1, you will get the latest price of the token because the latest trade = the Latest Price.
Run this query using this link.
subscription {
Solana {
Buyside: DEXTrades(
where: {
Trade: {
Buy: {
Currency: {
MintAddress: {
is: "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
}
}
}
Dex: {
ProgramAddress: {
is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
}
}
}
}
) {
Trade {
Dex {
ProgramAddress
ProtocolFamily
ProtocolName
}
Buy {
Account {
Address
}
Amount
Currency {
Decimals
Symbol
MintAddress
Name
}
PriceAgaistSellCurrency: Price
}
Sell {
Account {
Address
}
Amount
Currency {
Decimals
Symbol
MintAddress
Name
}
PriceAgaistBuyCurrency: Price
}
}
Block {
Time
Height
}
Transaction {
Signature
FeePayer
Signer
}
}
Sellside: DEXTrades(
limit: { count: 10 }
where: {
Trade: {
Sell: {
Currency: {
MintAddress: {
is: "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
}
}
}
Dex: {
ProgramAddress: {
is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
}
}
}
}
) {
Trade {
Dex {
ProgramAddress
ProtocolFamily
ProtocolName
}
Buy {
Account {
Address
}
Amount
Currency {
Decimals
Symbol
MintAddress
Name
}
PriceAgaistSellCurrency: Price
}
Sell {
Account {
Address
}
Amount
Currency {
Decimals
Symbol
MintAddress
Name
}
PriceAgaistBuyCurrency: Price
}
}
Block {
Time
Height
}
Transaction {
Signature
FeePayer
Signer
}
}
}
}
Raydium OHLC API
If you want to get OHLC data for any specific currency pair on Raydium DEX, you can use this api.
Only use this API as query
and not subscription
websocket as Aggregates and Time Intervals don't work well with subscriptions.
{
Solana {
DEXTradeByTokens(
orderBy: { descendingByField: "Block_Timefield" }
where: {
Trade: {
Currency: {
MintAddress: { is: "6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui" }
}
Side: {
Currency: {
MintAddress: { is: "So11111111111111111111111111111111111111112" }
}
}
Dex: {
ProgramAddress: {
is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
}
}
PriceAsymmetry: { lt: 0.1 }
}
}
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
}
}
}
Track Latest Add Liquidity Transactions on Raydium DEX
You can also track Add Liquidity transactions in real time on Raydium DEX from Raydium API using instructions. Firstly, you can use this query to get all the methods of Raydium V4 program to deduce which program method is triggered for add liquidity transactions. The method we want to filter for turns out to be setPositionStopLoss
.
If you want to track latest liquidity additions in Raydium pools, you can use this Websocket api.
In the response, mint under 7th and 8th addresses in the Accounts array gives you the Token A and Token B respectively of the pool in which liquidity is added.
subscription {
Solana {
Instructions(
where: {
Instruction: {
Program: {
Address: { is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" }
Method: { is: "setPositionStopLoss" }
}
}
Transaction: { Result: { Success: true } }
}
) {
Transaction {
Signature
}
Block {
Time
}
Instruction {
Accounts {
Address
IsWritable
Token {
ProgramId
Owner
Mint
}
}
AncestorIndexes
BalanceUpdatesCount
CallPath
CallerIndex
Data
Depth
Logs
InternalSeqNumber
Index
ExternalSeqNumber
Program {
Address
AccountNames
Method
Arguments {
Name
Type
Value {
... on Solana_ABI_Integer_Value_Arg {
integer
}
... on Solana_ABI_String_Value_Arg {
string
}
... on Solana_ABI_Address_Value_Arg {
address
}
... on Solana_ABI_BigInt_Value_Arg {
bigInteger
}
... on Solana_ABI_Bytes_Value_Arg {
hex
}
... on Solana_ABI_Boolean_Value_Arg {
bool
}
... on Solana_ABI_Float_Value_Arg {
float
}
... on Solana_ABI_Json_Value_Arg {
json
}
}
}
}
}
}
}
}
Track Latest Remove Liquidity Transactions on Raydium DEX
You can also track Remove Liquidity transactions in real time on Raydium DEX from Raydium API using instructions. Firstly, you can use this query to get all the methods of Raydium V4 program to deduce which program method is triggered for remove liquidity transactions. The method we want to filter for turns out to be setPositionRangeStop
.
If you want to track latest liquidity removals in Raydium pools, you can use this Websocket api.
In the response, mint under 7th and 8th addresses in the Accounts array gives you the Token A and Token B respectively of the pool in which liquidity is removed.
subscription {
Solana {
Instructions(
where: {
Instruction: {
Program: {
Address: { is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" }
Method: { is: "setPositionRangeStop" }
}
}
Transaction: { Result: { Success: true } }
}
) {
Transaction {
Signature
}
Block {
Time
}
Instruction {
Accounts {
Address
IsWritable
Token {
ProgramId
Owner
Mint
}
}
AncestorIndexes
BalanceUpdatesCount
CallPath
CallerIndex
Data
Depth
Logs
InternalSeqNumber
Index
ExternalSeqNumber
Program {
Address
AccountNames
Method
Arguments {
Name
Type
Value {
... on Solana_ABI_Integer_Value_Arg {
integer
}
... on Solana_ABI_String_Value_Arg {
string
}
... on Solana_ABI_Address_Value_Arg {
address
}
... on Solana_ABI_BigInt_Value_Arg {
bigInteger
}
... on Solana_ABI_Bytes_Value_Arg {
hex
}
... on Solana_ABI_Boolean_Value_Arg {
bool
}
... on Solana_ABI_Float_Value_Arg {
float
}
... on Solana_ABI_Json_Value_Arg {
json
}
}
}
}
}
}
}
}
Track Raydium DEXTrades enabled by OpenBook Protocol
You can track Raydium DEXTrades which are enabled by OpenBook Protocol in real time on Raydium DEX from Raydium API using instructions. So OpenBook is an Order Book Protocol which Raydium has integrated in its constant product amm. If you want a full explaination of this API, watch our Youtube Video.
If you want to track latest Raydium DEXTrades enabled by OpenBook order book Protocol, you can use this Websocket api.
subscription {
Solana {
DEXTrades(
where: {
Trade: { Dex: { ProtocolFamily: { is: "Raydium" } } }
Instruction: {
Accounts: {
includes: {
Address: { is: "srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX" }
}
}
}
}
) {
Trade {
Buy {
Account {
Address
}
Amount
AmountInUSD
Currency {
MintAddress
Symbol
}
Price
PriceInUSD
}
Market {
MarketAddress
}
Dex {
ProtocolFamily
ProtocolName
ProgramAddress
}
Sell {
Account {
Address
}
Amount
AmountInUSD
Currency {
MintAddress
Symbol
}
Price
PriceInUSD
}
}
Transaction {
Signature
}
}
}
}