Skip to main content

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: "initializeUserWithNonce" }
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
}
}
}
}
}
}
}
}

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: {Currency: {MintAddress: {is: "So11111111111111111111111111111111111111112"}}, Side: {Currency: {MintAddress: {is: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"}}}}}
) {
Block {
Time
}
Trade {
Price
}
}
}
}

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​

You can also query OHLC data in real time from Raydium DEX.

Here is Websocket to get OHLC data for all currencies, however, if you want to get OHLC data for any specific currency pair, you can use this Websocket api.

subscription {
Solana {
DEXTradeByTokens(
orderBy: { descendingByField: "Block_Timefield" }
where: {
Trade: {
Currency: {
MintAddress: { is: "6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui" }
}
Side: {
Currency: {
MintAddress: { is: "So11111111111111111111111111111111111111112" }
}
}
Dex: {
ProgramAddress: {
is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
}
}
}
}
) {
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
}
}
}
}
}
}
}
}

Video Tutorial | How to Track Latest Trades, Latest Price of a Token on Solana Raydium DEX​

Video Tutorial | How to Track Latest Created Liquidity Pools, OHLC data of a specific pair on Solana Raydium DEX​

Video Tutorial | How to Track Add Liquidity and Remove Liquidity Transactions on Raydium DEX​