Solana Raydium API: Get Latest Liquidity Pools and Trades

·

This guide demonstrates how to retrieve real-time and historical data from Raydium DEX on Solana using Bitquery APIs. Learn how to access liquidity pool details, trade information, token prices, and more.

New Liquidity Pools on Solana Raydium DEX (WebSocket Subscription)

Subscribe to newly created Raydium liquidity pools via GraphQL WebSocket.

👉 Try the live subscription here

Extracting Pool and Token Details

Run the query here.

Pair Creation Time for a Specific Pool

Query the creation timestamp of a Raydium pair using:

query {
  solana {
    dexTrades(
      exchangeName: {is: "Raydium"}
      baseCurrency: {is: "TOKEN_A_MINT_ADDRESS"}
      quoteCurrency: {is: "TOKEN_B_MINT_ADDRESS"}
      limit: 1
    ) {
      block {
        timestamp
      }
    }
  }
}

👉 Execute this query

Historical Raydium Pool Data

Retrieve historical pair creations within a date range:

query {
  solana {
    dexTrades(
      exchangeName: {is: "Raydium"}
      date: {since: "2023-01-01", till: "2023-12-31"}
    ) {
      baseCurrency {
        symbol
        address
      }
      quoteCurrency {
        symbol
        address
      }
    }
  }
}

View full query.

Token Price Tracking

Fetch the latest price of a token:

query {
  solana {
    dexTrades(
      exchangeName: {is: "Raydium"}
      baseCurrency: {is: "TOKEN_MINT_ADDRESS"}
      limit: 1
    ) {
      price
    }
  }
}

Run live price query.

Real-Time Raydium Trades

Subscribe to live trades:

subscription {
  solana {
    dexTrades(
      exchangeName: {is: "Raydium"}
    ) {
      tradeAmount
      price
    }
  }
}

Start WebSocket stream.

Currency-Specific Trade Stream

Filter trades by token mint address (e.g., RAY token):

subscription {
  solana {
    dexTrades(
      exchangeName: {is: "Raydium"}
      baseCurrency: {is: "TOKEN_MINT_ADDRESS"}
    ) {
      side
      price
    }
  }
}

Example for RAY token.

OHLC Data for Raydium Pairs

Fetch candlestick data for a token pair:

query {
  solana {
    dexTrades(
      exchangeName: {is: "Raydium"}
      baseCurrency: {is: "TOKEN_A_MINT_ADDRESS"}
      quoteCurrency: {is: "TOKEN_B_MINT_ADDRESS"}
      interval: {in: minutes, amount: 5}
    ) {
      open: price(minimum: "first")
      high: price(minimum: "maximum")
      low: price(minimum: "minimum")
      close: price(minimum: "last")
    }
  }
}

OHLC API link.

Liquidity Transaction Tracking

Add Liquidity Events

Subscribe to real-time additions:

subscription {
  solana {
    instructions(
      programName: {is: "Raydium V4"}
      methodName: {is: "setPositionStopLoss"}
    ) {
      accounts {
        address
        mint
      }
    }
  }
}

WebSocket link.

Remove Liquidity Events

Track withdrawals via:

subscription {
  solana {
    instructions(
      programName: {is: "Raydium V4"}
      methodName: {is: "setPositionRangeStop"}
    ) {
      accounts {
        address
        mint
      }
    }
  }
}

Query link.

OpenBook-Enabled DEX Trades

Raydium integrates OpenBook’s order book protocol. Track these trades:

subscription {
  solana {
    dexTrades(
      exchangeName: {is: "Raydium"}
      protocol: {is: "OpenBook"}
    ) {
      price
      amount
    }
  }
}

Live stream.


FAQs

How do I find Raydium pool addresses?

Pool addresses are indexed under Accounts[4] in GraphQL responses.

Can I get historical liquidity pool data?

Yes, use date filters in queries to retrieve past pool creations.

What’s the difference between WebSocket and HTTP APIs?

WebSockets provide real-time streaming, while HTTP APIs fetch static data.

How accurate is Raydium’s price data?

Prices reflect the latest on-chain trades with millisecond precision.

Is OpenBook data separate from Raydium’s AMM?

OpenBook trades are integrated into Raydium but use an order book model.

How often is OHLC data updated?

Configure intervals (e.g., 5 minutes) in your query for granular updates.


👉 Explore more Solana DeFi tools