Skip to main content

Solana Historical Data API: OHLCV, Trades and Archive

Solana history on Bitquery comes in layers. The right one depends on how far back you need to go and whether you need single trades or totals.

  • Last 30 days: start with the Trading API. It returns per-trade rows with the trader, the transaction and a USD price, plus built candles.
  • Aggregates back to June 2024: OHLCV, volume, ATH, first buyers and PnL run on the DEXTradeByTokens cube with dataset: archive or combined. This history starts on 1 June 2024.
  • Individual trades older than 30 days: these ship as Parquet exports from the Bitquery Data Store. Technical details are on the Solana exports page.
  • Transfers: SPL transfers back to the chain's genesis are on the V1 endpoint.

Every query on this page runs as written in the Bitquery IDE.

The free trial and paid self-service plans cover real-time data only. The archive and combined queries need the Solana Historical OHLCV & Token Price Data add-on from the pricing page, which covers both DEXTradeByTokens and DEXTrades.

Solana history at a glance​

LayerWhereHow far backUse it for
Trades and candles, last 30 daysTrading.Trades, with built candles in Trading.Tokens and Trading.PairsAbout the last 30 daysTrade-level rows with trader, transaction and USD price; candles down to one second
Aggregate historySolana(dataset: archive) or combined, DEXTradeByTokensFrom 1 June 2024OHLCV, volume, ATH, first buyers, trader PnL
Individual trades, older than 30 daysData Store exports: Parquet on S3, GCS, Snowflake or BigQueryFull history; ranges on requestTrade-by-trade history, backtesting and warehouses
RealtimeSolana(dataset: realtime) cubesAbout 7 days on DEXTradeByTokens, hours on the other cubesLive filters, including the USD fields the aggregate datasets reject
Transfers to genesisV1 GraphQL endpointFull chain historySPL transfer history

Retention per cube is on the data coverage and retention page.

Which one to use​

You needUseExample
Single trades of a token, wallet or DEX in the last 30 daysTrading.TradesLatest trades of a token
Candles for the last 30 daysTrading.Tokens or Trading.PairsHourly candles
Top traders, first and last price, price range in the last 30 daysTrading.Trades with aggregatesTop traders
OHLCV, volume, ATH or PnL further back, to June 2024DEXTradeByTokens on archive or combinedHistorical OHLCV
Single trades older than 30 daysBitquery Data Store exportSolana exports
Keep aggregate history queries bounded

The examples in the aggregate sections name archive; switch to combined when the range has to reach the current block.

Expect these to be slow. An unbounded ATH or all-time OHLCV scan runs for tens of seconds against the aggregate tables, and on a busy mint such as WSOL it can exceed the gateway timeout and return a 502 instead of rows. Add a Block: { Time: { since: ... } } bound whenever you do not genuinely need the full range.

note

Trade Side Account field will not be available for aggregate queries in Archive and Combined Datasets

Filter limitations on aggregate datasets​

On Solana with dataset: archive or dataset: combined, DEXTradeByTokens is served from pre-aggregated tables. USD-denominated fields and PriceAsymmetry cannot be used inside where:. A query that filters on them fails outright with an error such as no table can query DEXTradeByToken or database schema not defined for archive cube. It does not silently return different numbers. The same USD fields work normally as output measures.

FieldAs a where: filterAs a measure / projection
Trade.Amount, Trade.Side.Amountworksworks
Trade.Priceworksworks
Trade.Currency, Trade.Side.Currencyworksworks
Trade.Account.Addressworksworks
Trade.Side.Type, Trade.Dex, Block.Timeworksworks
Trade.PriceAsymmetryerrornot available
Trade.Side.AmountInUSD, Trade.AmountInUSDerrorworks, as sum(of: Trade_Side_AmountInUSD)
Trade.PriceInUSDerrorworks, as quantile(of: Trade_PriceInUSD)
Trade.Side.Accounterrorerror

All of these filters work on dataset: realtime, which covers a rolling recent window (hours). To filter by USD amount or PriceAsymmetry over history, use the Trading API, which carries USD price and supply on every row.

Historical Trades for Solana​

Trades from the last 30 days come from the Trading API. The full field list is on the Trades API page. The examples below cover one token, a list of tokens, candles, top traders and a per-DEX price range.

The Bitquery IDE: Solana trades over the last 30 days example reads per-trade rows for that window through the Trading API.

query MyQuery {
Trading {
Trades(
where: {Pair: {Market: {Network: {is: "Solana"}}}, Block: {Date: {before_relative: {days_ago: 25}, after_relative: {days_ago: 27}}}}
orderBy: {ascending: Block_Date}
limit: {count: 100}
) {
Amounts {
Base
Quote
}
AmountsInUsd {
Base
Quote
}
Block {
Time
}
Pair {
Market {
Address
Program
}
Pool {
Address
Id
}
QuoteToken {
Name
Symbol
Address
}
Token {
Name
Symbol
Address
}
}
Price
PriceInUsd
Ranking {
Position
Weight
}
Side
Supply {
MarketCap
FullyDilutedValuationUsd
CirculatingSupply
}
Trader {
Address
}
TransactionHeader {
Fee
Hash
}
}
}
}

The example asks for a two-day slice at the far end of the window and caps the rows with limit. An unbounded request over the whole month can time out.

Latest trades of a token​

This query returns the newest trades of one token with the trader, the transaction signature, the DEX and the USD price. Pair.Token.Address is the mint. since_relative: { days_ago: 30 } means from 30 days ago until now, so the query covers the whole window the Trading API holds. For the oldest trades in the window instead, change the order to ascending: Block_Time.

{
Trading {
Trades(
where: {
Pair: {
Market: { Network: { is: "Solana" } }
Token: { Address: { is: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" } }
}
Block: { Date: { since_relative: { days_ago: 30 } } }
}
orderBy: { descending: Block_Time }
limit: { count: 50 }
) {
Block {
Time
}
Side
Price
PriceInUsd
Amounts {
Base
Quote
}
AmountsInUsd {
Base
}
Trader {
Address
}
TransactionHeader {
Hash
}
Pair {
Market {
Protocol
Program
}
QuoteToken {
Symbol
Address
}
}
}
}
}

Trades of several tokens in a time window​

This query reads the trades of a list of mints inside a two-day slice, oldest first. Use it to replay a period for a watchlist. Keep the slice narrow and page with limit and offset.

{
Trading {
Trades(
where: {
Pair: {
Market: { Network: { is: "Solana" } }
Token: {
Address: {
in: [
"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"
"JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN"
]
}
}
}
Block: {
Date: {
after_relative: { days_ago: 29 }
before_relative: { days_ago: 27 }
}
}
}
orderBy: { ascending: Block_Time }
limit: { count: 100 }
) {
Block {
Time
}
Side
PriceInUsd
Amounts {
Base
}
AmountsInUsd {
Base
}
Trader {
Address
}
TransactionHeader {
Hash
}
Pair {
Token {
Symbol
Address
}
Market {
Protocol
}
}
}
}
}

Hourly candles for a token​

This query returns built hourly candles in USD for one token across all its pairs, newest first. Duration is the candle size in seconds and must be set. The 720 rows are 30 days of hours.

{
Trading {
Tokens(
where: {
Token: {
Network: { is: "Solana" }
Address: { is: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" }
}
Interval: { Time: { Duration: { eq: 3600 } } }
Block: { Date: { since_relative: { days_ago: 30 } } }
}
orderBy: { descending: Interval_Time_Start }
limit: { count: 720 }
) {
Interval {
Time {
Start
}
}
Price {
Ohlc {
Open
High
Low
Close
}
}
Volume {
Usd
}
}
}
}

Top traders of a token​

This query ranks the wallets that traded a token over the last 7 days by USD volume, with the bought and sold amounts split out. The query reads every trade of the token in the window, so start with 7 days and widen it only for tokens with light trading.

{
Trading {
Trades(
where: {
Pair: {
Market: { Network: { is: "Solana" } }
Token: { Address: { is: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" } }
}
Block: { Date: { since_relative: { days_ago: 7 } } }
}
orderBy: { descendingByField: "volume_usd" }
limit: { count: 100 }
) {
Trader {
Address
}
volume_usd: sum(of: AmountsInUsd_Base)
bought_usd: sum(of: AmountsInUsd_Base, if: { Side: { is: "Buy" } })
sold_usd: sum(of: AmountsInUsd_Base, if: { Side: { is: "Sell" } })
trades: count
}
}
}

First price, last price and range per token on one DEX​

This query lists the most traded tokens on one DEX program in the last hour, with the first and last USD price, the high and the low, and the time of the first trade. The example program is Meteora Dynamic Bonding Curve. PriceInUsd(minimum: Block_Time) is the price of the earliest trade and PriceInUsd(maximum: Block_Time) is the price of the latest one.

{
Trading {
Trades(
where: {
Pair: {
Market: {
Network: { is: "Solana" }
Program: { is: "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN" }
}
}
Block: { Time: { since_relative: { hours_ago: 1 } } }
}
orderBy: { descendingByField: "trades" }
limit: { count: 20 }
) {
Pair {
Token {
Symbol
Address
}
}
first_price: PriceInUsd(minimum: Block_Time)
last_price: PriceInUsd(maximum: Block_Time)
high: PriceInUsd(maximum: PriceInUsd)
low: PriceInUsd(minimum: PriceInUsd)
first_trade: Block {
Time(minimum: Block_Time)
}
trades: count
}
}
}

Errors on history queries and the fix​

These messages come back when a query asks an aggregate dataset for single trades. Each has a working query above.

Error message containsWhat the query asked forUse instead
no table can query DEXTradeByToken with field Block.Slot, Transaction.Signer or Trade.AccountSingle trades from DEXTradeByTokens on archive or combinedLatest trades of a token
no API tables for cube DEXTradeByTokenaggregates: no on archiveTrades of several tokens in a time window
metric 'minimum' has no columns on this table for Trade.PriceInUSDFirst price by time on archive or combinedFirst price, last price and range
needs a filter on Block_Time or Block_SlotDEXTrades on archive or combined with no time rangeLatest trades of a token, or add a Block.Time range
no table can query DEXTradeByToken with a USD field in whereA USD filter on archive or combinedFilter limitations

For single trades older than 30 days, order a Bitquery Data Store export.

Historical OHLCV candles for a Solana token pair​

This query returns daily open, high, low and close prices for a pair, with volume and trade count per candle. Trade.Currency is the token by mint address, Trade.Side.Currency is the quote token, and Time(interval: ...) sets the candle size in seconds, minutes, hours or days. The example is USDC against WSOL, a pair that will still be trading when you run it. For one token across every pair, drop the Side filter.

{
Solana(dataset: archive) {
DEXTradeByTokens(
orderBy: { descendingByField: "Block_Timefield" }
where: {
Block: { Date: { since_relative: { days_ago: 10 } } }
Trade: {
Currency: { MintAddress: { is: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" } }
Side: {
Currency: {
MintAddress: { is: "So11111111111111111111111111111111111111112" }
}
}
}
}
limit: { count: 10 }
) {
Block {
Timefield: Time(interval: { in: days, 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
}
}
}

Export the candles to CSV​

The same query from a script, written to a CSV file. Only the Python standard library is used; set BITQUERY_TOKEN to your access token first.

import csv, json, os, urllib.request

TOKEN = os.environ["BITQUERY_TOKEN"] # your Bitquery access token
QUERY = """
{
Solana(dataset: archive) {
DEXTradeByTokens(
orderBy: { descendingByField: "Block_Timefield" }
where: {
Trade: {
Currency: { MintAddress: { is: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" } }
Side: { Currency: { MintAddress: { is: "So11111111111111111111111111111111111111112" } } }
}
}
limit: { count: 365 }
) {
Block { Timefield: Time(interval: { in: days, 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
}
}
}
"""
req = urllib.request.Request(
"https://streaming.bitquery.io/graphql",
data=json.dumps({"query": QUERY}).encode(),
headers={"Content-Type": "application/json", "Authorization": f"Bearer {TOKEN}"},
)
rows = json.load(urllib.request.urlopen(req))["data"]["Solana"]["DEXTradeByTokens"]
with open("usdc_wsol_daily.csv", "w", newline="") as f:
w = csv.writer(f)
w.writerow(["time", "open", "high", "low", "close", "volume", "trades"])
for r in rows:
t = r["Trade"]
w.writerow([r["Block"]["Timefield"], t["open"], t["high"], t["low"], t["close"], r["volume"], r["count"]])
print(f"wrote {len(rows)} candles")

Swap the mint addresses, the interval and the limit for other pairs and candle sizes. For whole-history exports across many tokens, Data Store exports deliver the same data as Parquet.

Important Considerations
  • Each OHLC data point is calculated independently per time interval (e.g., daily). There’s no enforcement to make the Close of one candle match the Open of the next.

  • Gaps are possible: Since the data is based on actual trades, if no trades occur exactly at the start or end of a day, the nearest trades before and after those timestamps will define the open and close. For instance:

    • Last trade on April 14: 23:58:12
    • First trade on April 15: 00:03:45
      These would represent the close of April 14 and open of April 15 respectively, leaving a gap in between.
  • Derived from block time: All time-based grouping (daily, hourly, etc.) depends on block timestamps.

  • No PriceAsymmetry filter on archive/combined: this query cannot exclude asymmetric prints, so high and low take raw extremes and may include outlier trades. For cleaner candles over the last ~30 days use the Trading API, which serves USD OHLC directly. See Filter limitations.

Alternative approach: You can get all trades and calculate OHLC locally in your own system. Complete guide here

First 24 Hours Trade Volume for a Solana Token​

This query returns the trade volume for a Solana Token in the first 24 hours of its launch. We are using 13WvP5LC5ETUpFipYM2f9AQzg6QA9S5opxGp2Scpump in this case.

query MyQuery {
Solana(dataset: archive, aggregates: yes) {
DEXTradeByTokens(
orderBy: { ascendingByField: "Block_TimeFeild" }
limit: { count: 1 }
where: {
Trade: {
Currency: {
MintAddress: { is: "13WvP5LC5ETUpFipYM2f9AQzg6QA9S5opxGp2Scpump" }
}
}
}
) {
Block {
TimeFeild: Time(interval: { count: 24, in: hours })
}
sum(of: Trade_Side_AmountInUSD)
}
}
}

Top 100 traders of a token​

This query returns the top token traders for a specific token by USD volume over a date range. The example uses token mint 98sMhvDwXj1RQi5c5Mndm3vPe9cBqPrbLaufMXFNMh5g paired with SOL (So11111111111111111111111111111111111111112) and the combined dataset for 2026-01-01 to 2026-01-02. You get trader address (Owner), buy/sell counts, buy/sell volume, total volume, and trade count per trader.

{
Solana(dataset: archive) {
DEXTradeByTokens(
where: {
Trade: {
Currency: {
MintAddress: { is: "98sMhvDwXj1RQi5c5Mndm3vPe9cBqPrbLaufMXFNMh5g" }
}
Side: {
Currency: {
MintAddress: { is: "So11111111111111111111111111111111111111112" }
}
}
}
Transaction: { Result: { Success: true } }
Block: { Date: { since: "2026-01-01", till: "2026-01-02" } }
}
orderBy: { descendingByField: "volume" }
limit: { count: 100 }
) {
Trade {
Currency {
Name
Symbol
MintAddress
}
Account {
Owner
}
}
buys: count(if: { Trade: { Side: { Type: { is: buy } } } })
sells: count(if: { Trade: { Side: { Type: { is: sell } } } })
buy_volume: sum(
of: Trade_Side_AmountInUSD
if: { Trade: { Side: { Type: { is: buy } } } }
)
sell_volume: sum(
of: Trade_Side_AmountInUSD
if: { Trade: { Side: { Type: { is: sell } } } }
)
volume: sum(of: Trade_Side_AmountInUSD)
trades: count
}
}
}

Tokens Traded by an Account​

This query returns the list of tokens traded by the wallet address over the last 7 days. Keep a Block.Date bound on archive queries like this one: without it the query reads the wallet's whole history and can time out. The list is sorted by the amount of tokens traded, and returns token info such as mint address, name and symbol along with the total amount of tokens traded and the number of trades involving that token.

query MyQuery {
Solana(dataset: archive) {
DEXTradeByTokens(
orderBy: { descendingByField: "tokens" }
limit: { count: 20 }
where: {
Block: { Date: { since_relative: { days_ago: 7 } } }
Trade: {
Account: {
Owner: { is: "3CgvbiM3op4vjrrjH2zcrQUwsqh5veNVRjFCB9N6sRoD" }
}
}
}
) {
Trade {
Currency {
MintAddress
Name
Symbol
}
}
tokens: sum(of: Trade_Amount)
trades: count
}
}
}

Change in Liquidity Over a Month​

This query returns the change in liquidity for a particular token pair over the last 30 days. For this example the parameters listed below are used.

  1. Primary Token - EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v (USDC).
  2. Secondary Token - So11111111111111111111111111111111111111112 (WSOL),
  3. Pool Address - Czfq3xZZDmsdGdUyrNLtRhGc47cXcZtLG4crryfu44zE (the USDC/WSOL Orca Whirlpool)
query MyQuery {
Solana(dataset: archive) {
DEXTradeByTokens(
where: {
Block: { Date: { since_relative: { days_ago: 30 } } }
Trade: {
Currency: { MintAddress: { is: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" } }
Side: {
Currency: {
MintAddress: { is: "So11111111111111111111111111111111111111112" }
}
}
Market: {
MarketAddress: {
is: "Czfq3xZZDmsdGdUyrNLtRhGc47cXcZtLG4crryfu44zE"
}
}
}
}
orderBy: { descendingByField: "Block_Timefield" }
limit: { count: 1 }
) {
tokenLiquidity: sum(
of: Trade_Amount
if: { Trade: { Side: { Type: { is: buy } } } }
)
wsolLiquidity: sum(
of: Trade_Side_Amount
if: { Trade: { Side: { Type: { is: sell } } } }
)
Block {
Timefield: Time(interval: { in: months, count: 1 })
}
Trade {
Market {
MarketAddress
}
}
}
}
}

Get ATH (All-Time High) of a Token​

In this query we use the 95th percentile (level: 0.95) to find the highest price of a token. The 95th percentile is itself outlier-resistant, which matters here because PriceAsymmetry and AmountInUSD cannot be used as filters on aggregate datasets. See Filter limitations on aggregate datasets. On dataset: realtime you can add both filters for stricter outlier control.

Read more about quantiles here You can run the query here

{
Solana(dataset: archive) {
DEXTradeByTokens(
where: {Trade: {Side: {Currency: {MintAddress: {in: ["11111111111111111111111111111111", "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", "So11111111111111111111111111111111111111112"]}}}, Currency: {MintAddress: {is: "2tnA2ZmwmgUZLyYLi97zbwsFBXAqpMEcHu9Cv9JW6m26"}}}}
limit: {count: 1}
orderBy: {descendingByField: "aATH"}
) {
aATH: quantile(of: Trade_PriceInUSD, level: 0.95)
}
}
}

Get ATH Price, ATH Date, Price Change percentage in 24h, 7d, 30d​

Fetches a Solana token’s ATH price, ATH date, and price change percentages over the past 24h, 7d, and 30d using Bitquery Solana APIs. Try the query to get ATH price, ATH date, price change.

query ($token: String) {
Solana(dataset: archive) {
DEXTradeByTokens(
where: {Trade: {Side: {Currency: {MintAddress: {in: ["11111111111111111111111111111111", "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", "So11111111111111111111111111111111111111112"]}}}, Currency: {MintAddress: {is: $token}}}, Transaction: {Result: {Success: true}}}
limit: {count: 1}
) {
Trade {
Price_24h_ago: PriceInUSD(
minimum: Block_Slot
if: {Block: {Time: {since_relative: {hours_ago: 24}}}}
)
Price_7d_ago: PriceInUSD(
minimum: Block_Slot
if: {Block: {Time: {since_relative: {days_ago: 7}}}}
)
Price_30d_ago: PriceInUSD(
minimum: Block_Slot
if: {Block: {Time: {since_relative: {days_ago: 30}}}}
)
CurrentPrice: PriceInUSD(maximum: Block_Slot)
}
change24hr: calculate(
expression: "(($Trade_CurrentPrice - $Trade_Price_24h_ago) / $Trade_Price_24h_ago) * 100"
)
change7d: calculate(
expression: "(($Trade_CurrentPrice - $Trade_Price_7d_ago) / $Trade_Price_7d_ago) * 100"
)
change30d: calculate(
expression: "(($Trade_CurrentPrice - $Trade_Price_30d_ago) / $Trade_Price_30d_ago) * 100"
)
aATH: quantile(of: Trade_PriceInUSD, level: 0.95)
Block {
Time
}
}
}
}

Variables:

{
"token": "2tnA2ZmwmgUZLyYLi97zbwsFBXAqpMEcHu9Cv9JW6m26"
}

Get First 100 buyers of a Token​

This API returns the first 100 buyers for a particular token.

{
Solana(dataset: archive) {
DEXTradeByTokens(
orderBy: { ascending: Block_Time }
limit: { count: 100 }
limitBy: { count: 1, by: Trade_Account_Owner }
where: {
Block: { Date: { since: "2025-07-13", till: "2025-07-14" } }
Trade: {
Side: { Type: { is: sell } }
Currency: {
MintAddress: { is: "pumpeALaQHVP7mCdjmhFkAnesZj3vXMJhD4rFffYDfn" }
}
}
}
) {
Trade {
Account {
Owner
}
}
}
}
}

The window is the token's launch day. Scanning from an arbitrary earlier date makes the request time out, so find the first trade date first (Block { Time(minimum: Block_Time) } on the same cube) and bound the window to it.

Get ATH of Multiple Tokens​

You can run it here

{
Solana(dataset: archive) {
DEXTradeByTokens(
where: {
Trade: {
Currency: {
MintAddress: {
in: ["token mint address-1", "token mint address-2"]
}
}
}
}
limit: { count: 2 }
orderBy: { descendingByField: "aATH" }
limitBy: { by: Trade_Currency_MintAddress, count: 1 }
) {
Trade {
Currency {
Name
}
}
aATH: quantile(of: Trade_PriceInUSD, level: 0.99)
}
}
}

Get ATH Market Cap of Tokens​

This query returns the ATH (All-Time High) market cap, starting market cap, and related price metrics for multiple tokens. It calculates market cap using a 1 billion token supply and uses quantile to find the ATH price.

You can run it here

query GetAthMarketCap($tokens: [String!]!) {
Solana(dataset: archive) {
DEXTradeByTokens(
limitBy: { by: Trade_Side_Currency_MintAddress, count: 1 }
where: {
Trade: {
Currency: { MintAddress: { in: $tokens } }
}
}
) {
Trade {
Currency {
MintAddress
Name
Symbol
}
PriceInUSD(maximum: Trade_PriceInUSD)
Starting_Price: PriceInUSD(minimum: Block_Slot)
Side {
Currency {
Name
Symbol
MintAddress
}
}
}
max: quantile(of: Trade_PriceInUSD, level: 0.98)
quantile_price_ATH_Marketcap: calculate(expression: "$max * 1000000000")
Real_maximum_price_ATH_Marketcap: calculate(
expression: "$Trade_PriceInUSD_maximum * 1000000000"
)
Starting_Marketcap: calculate(
expression: "$Trade_Starting_Price * 1000000000"
)
}
}
}
{
"tokens": ["8SAwv8EKMKaKnupTsYjoQdgBuWxJdo3ouA178UU7pump"]
}

Realised PnL, avg buy price, buy volume, sell volume​

Get realised PnL, average buy price, buy volume, and sell volume for a token on Solana of a trader trader for over a time window.

Run in Bitquery IDE

{
Solana(dataset: archive) {
DEXTradeByTokens(
where: {
Trade: {
Currency: {
MintAddress: { is: "4iLKj7fkZF2rSpgSD8W6UFq4fkKXkkbJMGXMz3B8pump" }
}
Account: {
Owner: { is: "2vqBfRdhX8sHmVFo1TY1yBdFXkHMe4LgifrxvHBpXUAK" }
}
Dex: { ProtocolName: { notIn: ["jupiter", "dex_solana_v3"] } }
}
Transaction: { Result: { Success: true } }
Block: { Date: { since: "2026-03-11", till: "2026-03-13" } }
}
) {
Trade {
Currency {
Name
Symbol
MintAddress
}
Account {
Owner
}
}
buys: count(if: { Trade: { Side: { Type: { is: buy } } } })
sells: count(if: { Trade: { Side: { Type: { is: sell } } } })
buy_volume_usd: sum(
of: Trade_Side_AmountInUSD
if: { Trade: { Side: { Type: { is: buy } } } }
)

buy_volume_usd: sum(
of: Trade_Side_AmountInUSD
if: { Trade: { Side: { Type: { is: buy } } } }
)
sell_volume_usd: sum(
of: Trade_Side_AmountInUSD
if: { Trade: { Side: { Type: { is: sell } } } }
)
buy_volume: sum(
of: Trade_Amount
if: { Trade: { Side: { Type: { is: buy } } } }
)
sell_volume: sum(
of: Trade_Amount
if: { Trade: { Side: { Type: { is: sell } } } }
)
RealizedPnL: calculate(expression: "$sell_volume_usd - $buy_volume_usd")
trades: count
avg_buy_price: calculate(expression: "$buy_volume_usd / $buy_volume")
}
}
}

How far back does Bitquery's Solana historical data go on Solana?​

It depends on the kind of data:

  • Aggregates: DEXTradeByTokens on Solana(dataset: archive) or combined starts on 1 June 2024. That is not the chain's genesis.
  • Individual trades, last 30 days: the Trading API.
  • Individual trades, older: a Data Store export.
  • SPL transfers and older history: the V1 Solana examples.

Other chains mostly have archive history from genesis for the core cubes. Depth varies by chain and cube: see the Data Coverage & Retention matrix.

What fields are available in Solana DEXTradeByTokens with dataset: combined?​

DEXTradeByTokens on Solana(dataset: archive) supports the fields that aggregate well. combined is the same, with the realtime tail added.

  • Available: time and intervals, amounts, prices, trade counts, Trade.Currency, Trade.Side.Currency, Dex, and the pool and market identifiers shown in the examples on this page.
  • Not available: per-account fields on the trade side, such as Trade Side Account. The API answers "columns not available".

When you build a query, add fields one at a time in the IDE. For single trades with the trader and the transaction, use the Trading API examples on this page.

See also combined vs realtime on Solana and the Pump.fun combined note.

CoinGecko OHLC compared with Bitquery​

CoinGecko coin OHLC endpointBitquery
ScopeCoins listed on CoinGecko, by coin id (chart endpoints also accept a token address)Any Solana mint or pair, listed or not
Candle sizeAutomatic: 30 minutes for 1 to 2 days, 4 hours for 3 to 30 days, 4 days beyond; daily and hourly intervals on paid plans over fixed rangesAny interval in seconds, minutes, hours or days
HistoryThe range you pass in the days parameterAggregates from 1 June 2024, per-trade rows for about 30 days, transfers to genesis on V1
FieldsOpen, high, low, closeOpen, high, low, close, volume, trade count, plus any aggregate you add (makers, buys, sells)
AccessAPI key headerAccess token; archive and combined aggregates need a Solana archive pack (the trial is real-time only)

Frequently Asked Questions

How far back does Solana historical data go on Bitquery?

Aggregate trade history on DEXTradeByTokens with dataset archive or combined starts on 1 June 2024. The Trading API holds about the last 30 days of per-trade rows, realtime cubes hold hours to about a week, and SPL transfers back to genesis are on the V1 endpoint.

How do I get OHLCV candles for a Solana token by mint address?

Filter DEXTradeByTokens by Trade.Currency.MintAddress, add Trade.Side.Currency for the quote token if you want one pair, and aggregate with Time(interval) for the candle size, as in the OHLCV section. For the last month, Trading.Tokens and Trading.Pairs return built candles down to one second.

Can I export Solana historical price data to CSV?

Yes. Call the GraphQL endpoint from a script and write the rows to CSV; the OHLCV section has a Python example that uses only the standard library. For bulk history, Data Store exports deliver Parquet to S3, GCS, Snowflake or BigQuery.

Is Solana historical data included in the free trial, and what does it cost after?

No. The seven-day trial covers real-time data only, and so do paid self-service plans; Solana history is sold as archive packs, one for OHLCV and price data and one for token transfers and balances, listed on the pricing page.

Why does my archive query fail with 'no table can query DEXTradeByToken'?

The aggregate datasets hold totals, not single trades. A query that asks them for a slot, a signer or a trade account, or that filters on a USD field or PriceAsymmetry, gets this error. For single trades in the last 30 days use Trading.Trades; for older single trades use a Data Store export; USD fields work as measures.

How do I get a Solana token's all-time high price?

Query DEXTradeByTokens on dataset combined with PriceInUSD(maximum: Trade_PriceInUSD), or a 0.95 quantile for outlier resistance, as shown in the ATH sections of this page.

Can I backtest a Solana trading strategy with this data?

Yes. Pull candles, first-24-hours volume or first-buyer sets from the archive dataset over the API, or use Parquet exports from the Bitquery Data Store for full-history backtests in a warehouse.

Video Tutorial for Querying Historical Solana Data​

Build with Bitquery

Ready to run this in production?

Get an API key and run these queries in minutes, or talk to us about plans and enterprise delivery.