OHLCV candles API
Open, high, low, close and volume for a token or a pool, from 1 minute to 1 day, built from every indexed swap.
Get a token's candles
GET /tokens/:chain/:address/candles answers from the pool that charts the token, and names that pool. A pool's own candles are at GET /pools/:chain/:address/candles.
Hourly candles in USD:
curl -s -H 'Authorization: Bearer <key>' 'https://app.aurelia.build/api/tokens/solana/So11111111111111111111111111111111111111112/candles?res=1h¤cy=usd'
| Parameter | Values | Default |
|---|---|---|
res | 1m, 5m, 15m, 1h, 4h, 1d | 1m |
from, to | Unix seconds, at most 5,000 bars apart | The last 500 bars, up to now |
currency | usd, or quote for the pool's quote token | usd |
fill | 1 repeats the previous close through empty intervals | Off |
What a bar holds
| Field | What it is |
|---|---|
t | The bar's start, unix seconds |
o, h, l, c | Open, high, low and close |
v | Volume in USD |
n | Number of trades: the priced ones in usd, all of them in quote |
Draw a chart
The bars map directly onto a candlestick series in a charting library. A price history is the bars' closes.
Bars for a candlestick chart:
const res = await fetch(
"https://app.aurelia.build/api/tokens/solana/So11111111111111111111111111111111111111112/candles?res=1h",
{ headers: { Authorization: "Bearer <key>" } },
);
const { bars } = await res.json();
const candles = bars.map(({ t, o, h, l, c }) => ({ time: t, open: o, high: h, low: l, close: c }));
Keep the last bar live
- Subscribe to the candles channel with
tokenorpool,resandcurrency, and wait forsubscribed, which names the pool. - Load the bars so far from
GET /pools/:chain/:address/candlesfor that pool. - Apply each
candlemessage by itst: it replaces the bar with thatt, or adds it.
Subscribe:
{"op":"subscribe","id":"c","channel":"candles","chain":"solana","token":"So11111111111111111111111111111111111111112","res":"1m","currency":"usd"}
Related
- Token candles reference.
- Live candles: ordering and gaps.
- Token price API: the latest price alone.
Free to start: 10,000 credits, with no card and no subscription.