Dexploit is in public beta. Share feedback →

Skip to content
← Back to Blog
solanagraphqlohlcvtutorial

Query Solana DEX Candles with GraphQL (Copy-Paste Examples)

Dexploit Team··7 min read
Query Solana DEX Candles with GraphQL (Copy-Paste Examples)

Dexploit has a GraphQL endpoint. As of 18 November 2026 it has two root fields, candles and protocols. If you want several candle series for a Solana pool in one request, or just the exact fields you need and nothing else, it is a good fit. This tutorial runs real queries against it: find a pool, pull a window of candles, ask for two timeframes in one round-trip, and read the result without tripping over the three things that catch everyone out.

Today the GraphQL endpoint serves candles and protocols; for individual swaps, trader stats, tokens and holders use the REST routes. If you came for a "trades query", jump to what GraphQL covers today.

It uses a Free key: 10 requests per second, 10,000 requests a month, 14 days of history (authentication). I ran the examples below on a Free key. Get a key from the dashboard.

Read this first: three things that catch people out

  • Candles come back oldest first. Leave out start and you get the oldest candles first, not the latest, so limit: 60 is the start of the history, not the last hour. Always pass start for a recent window.
  • volumeSol is in lamports, despite the name. Divide by 1e9 to get SOL. Prices (open, high, low, close) are already in SOL per whole token (candle units).
  • A query error is still an HTTP 200. GraphQL puts problems in an errors array in the body, so check the body, not only the status code. A bad key is the exception: that is a normal 401.

Step 1: find the pool

Candles belong to a pool, not a token, because one token trades on several pools with different prices and volumes (pairs vs tokens). The REST pairs route lists the pools for a token, busiest first:

curl -H 'X-API-Key: ohlcv_live_sk_<your_key>' \
  'https://api.dexploit.dev/api/v1/pairs?token_address=DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263&limit=3'

That is BONK. The first row on the day I ran it was an Orca pool, 5zpyutJu9ee6jFymDGoK7F6S5Kczqtc9FomP3ueKuyA9, with protocol: "orca" and status: "active". Pools change, so run it yourself and use the first pair_address it gives you.

Step 2: your first query

The endpoint is POST https://api.dexploit.dev/graphql. The key goes in X-API-Key, or as Authorization: Bearer. There is no GraphiQL IDE; the product page runs a live query with preset controls, and for your own queries you can use curl or any GraphQL client.

query RecentCandles($pair: String!, $start: String!) {
  candles(pairAddress: $pair, timeframe: "1m", start: $start, limit: 5) {
    timestamp
    open
    high
    low
    close
    volumeSol
    tradeCount
    buyCount
    sellCount
    uniqueTraders
  }
}

Variables (start is an RFC 3339 timestamp; use a time inside the last 14 days on a Free key):

{ "pair": "5zpyutJu9ee6jFymDGoK7F6S5Kczqtc9FomP3ueKuyA9", "start": "2026-11-18T05:01:00Z" }

The first candle that came back:

{
  "timestamp": "2026-11-18T05:01:00+00:00",
  "open": 3.154806202181501e-08,
  "high": 3.156306827450098e-08,
  "low": 3.152940287109498e-08,
  "close": 3.1558860212255154e-08,
  "volumeSol": 2252195081.0,
  "tradeCount": 9,
  "buyCount": 7,
  "sellCount": 2,
  "uniqueTraders": 9
}

volumeSol of 2252195081 is 2.25 SOL. buyCount and sellCount add up to tradeCount, so a candle already tells you which way the trading leaned.

Step 3: two timeframes and the protocol list in one request

This is where GraphQL earns its place. Aliases let you ask for candles twice with different arguments, and you can add protocols to the same request:

query Overview($pair: String!, $lastHour: String!, $lastDay: String!) {
  minute: candles(pairAddress: $pair, timeframe: "1m", start: $lastHour, limit: 60) {
    timestamp close volumeSol tradeCount buyCount sellCount
  }
  hourly: candles(pairAddress: $pair, timeframe: "1h", start: $lastDay, limit: 24) {
    timestamp open high low close volumeSol
  }
  protocols
}

Here it is as a script. Save it as candles.mjs (Node 18 or newer, no dependencies):

// Usage: node candles.mjs <pair_address>
const KEY = process.env.DEXPLOIT_API_KEY;
const pair = process.argv[2];
if (!KEY || !pair) { console.error("usage: DEXPLOIT_API_KEY=... node candles.mjs <pair_address>"); process.exit(1); }

const iso = (msAgo) => new Date(Date.now() - msAgo).toISOString().slice(0, 19) + "Z";

const query = `
query Overview($pair: String!, $lastHour: String!, $lastDay: String!) {
  minute: candles(pairAddress: $pair, timeframe: "1m", start: $lastHour, limit: 60) {
    timestamp close volumeSol tradeCount buyCount sellCount
  }
  hourly: candles(pairAddress: $pair, timeframe: "1h", start: $lastDay, limit: 24) {
    timestamp open high low close volumeSol
  }
  protocols
}`;

const res = await fetch("https://api.dexploit.dev/graphql", {
  method: "POST",
  headers: { "Content-Type": "application/json", "X-API-Key": KEY },
  body: JSON.stringify({
    query,
    variables: { pair, lastHour: iso(3_600_000), lastDay: iso(86_400_000) },
  }),
});
const body = await res.json();

// GraphQL reports query errors with HTTP 200, so check the body, not just res.ok.
if (body.errors) { console.error(JSON.stringify(body.errors, null, 2)); process.exit(1); }

const { minute, hourly, protocols } = body.data;
const sol = (lamports) => lamports / 1e9; // volumeSol is lamports, despite the name

console.log(`${protocols.length} protocols: ${protocols.join(", ")}\n`);
console.log("last hours (1h candles)");
for (const c of hourly.slice(-6)) {
  console.log(`${c.timestamp.slice(0, 16)}  close ${c.close.toExponential(3)} SOL  volume ${sol(c.volumeSol).toFixed(2)} SOL`);
}
const buys = minute.reduce((n, c) => n + c.buyCount, 0);
const sells = minute.reduce((n, c) => n + c.sellCount, 0);
const vol = minute.reduce((n, c) => n + sol(c.volumeSol), 0);
console.log(`\nlast ${minute.length} minutes: ${buys} buys, ${sells} sells, ${vol.toFixed(2)} SOL traded`);
export DEXPLOIT_API_KEY=your-key-here
node candles.mjs 5zpyutJu9ee6jFymDGoK7F6S5Kczqtc9FomP3ueKuyA9

A real run (the numbers will differ for you):

10 protocols: pumpfun, pumpswap, raydium_amm, raydium_clmm, raydium_cpmm, orca, meteora_damm_v2, meteora_dbc, meteora_dlmm, meteora_pools

last hours (1h candles)
2026-11-18T01:00  close 3.191e-8 SOL  volume 34.50 SOL
2026-11-18T02:00  close 3.171e-8 SOL  volume 56.60 SOL
2026-11-18T03:00  close 3.182e-8 SOL  volume 43.99 SOL
2026-11-18T04:00  close 3.155e-8 SOL  volume 35.93 SOL
2026-11-18T05:00  close 3.166e-8 SOL  volume 46.69 SOL
2026-11-18T06:00  close 3.178e-8 SOL  volume 42.10 SOL

last 53 minutes: 65 buys, 171 sells, 52.45 SOL traded

Notice the last line says 53 minutes, not 60. A minute with no trades has no candle: Dexploit does not carry the previous close forward (no phantom bars). So do not assume one row per minute: use minute.length, and work from each row's timestamp. A gap means nothing traded in that minute.

Limits worth knowing

  • Timeframes: 1s, 30s, 1m, 5m, 15m, 1h, 4h, 1d.
  • limit defaults to 1000 and is at most 10,000. Going over is refused with limit must be <= 10000.
  • One request reads about 10,000 candles in total. That is the sum of limit across every candles in it, aliases included, so two aliases of 6000 are refused as one request.
  • Free keys see the last 14 days. Asking for an older start returns an error with the code HISTORY_WINDOW_EXCEEDED, and its extensions carry oldest_allowed (the earliest time you can ask for) and window_days (quotas and errors). Paid keys are not windowed.
  • Over the rate limit you get a 429. Free allows 10 requests in any one second (authentication).
  • stale and pricedAt. Ask for them on candles and you learn whether the pool's price is current: stale is true when its last priced trade is more than 600 seconds old (or there is none in the last hour), and pricedAt is that trade's time. Both are null when you pass end, because a window in the past says nothing about now (stale prices).

What GraphQL covers today

The schema is the whole story, and you can print it yourself because introspection is on. This is what it returned on 18 November 2026:

curl -X POST -H 'X-API-Key: ohlcv_live_sk_<your_key>' \
  -H 'Content-Type: application/json' \
  https://api.dexploit.dev/graphql \
  -d '{"query":"{ __schema { queryType { fields { name } } } }"}'

It returned two fields: candles and protocols, with no mutations and no subscriptions. For individual swaps, trader stats, tokens and holders, use the REST routes today, and live updates come from the WebSocket rather than from GraphQL subscriptions (GraphQL reference).

You wantUse
Several candle series (and the protocol list) in one requestGraphQL
One resource, paginated, easy to cacheREST
Individual swaps, one trade per row (today)REST swaps routes
Live trades as they happenWebSocket

Next