Aurelia

Live candles over WebSocket

The candles channel: a pool's or a token's bar in progress, at any resolution, in USD or the quote token, and each bar as it closes.

Subscribe to candles with pool, or token (charted in the chart pool its page names when you subscribe), res (1m by default: 1m, 5m, 15m, 1h, 4h, 1d) and currency (usd by default, or quote). The server builds the bars from each indexed swap by the rules of the candles, so a chart needs no folding of its own.

Subscribe:

{"op":"subscribe","id":"c","channel":"candles","chain":"solana","token":"So11111111111111111111111111111111111111112","res":"1m","currency":"usd"}
typeWhendata
subscribedOnceNames the pool, with res, currency, and token when you gave one
candleRight after subscribed when the pool has a bar; then whenever the bar in progress changes, at most 4 a secondThe bar, closed: false
candleWhen a trade opens the next bar: the previous bar's final values, just before the new barThe bar, closed: true

A bar is t (its start, unix seconds), o, h, l, c, v (USD volume) and n (trades: the priced ones in usd, all of them in quote). Keep bars by t: a message replaces the bar with its t, or adds it. In usd, only a priced swap opens a bar, and a swap worth under $0.01 never counts.

  1. Subscribe and wait for subscribed, which names the pool.
  2. Load the bars so far with GET /pools/:chain/:address/candles for that pool, with the same res and currency.
  3. Apply each candle by its t, those that arrived while the history loaded included. The REST page holding now can be a minute old; the channel's bars are not.
  4. On resubscribed, load the bars again: a bar that closed during the outage may not be sent.

Captured on a test instance: the bar in progress, then its final values when the next minute's first trade lands:

{"type":"subscribed","id":"c1","channel":"candles","chain":"evm:56","token":"0xa9fcda9bd321adeb7cbbbd30ef2dd0ed1d657777","pool":"0x702e6533e0182381606adbe3ccbb77f682ccc58b","res":"1m","currency":"usd"}
{"id":"c1","type":"candle","data":{"t":1790618520,"o":0.006,"h":0.006,"l":0.006,"c":0.006,"v":600,"n":2,"closed":false}}
{"id":"c1","type":"candle","data":{"t":1790618520,"o":0.006,"h":0.006,"l":0.006,"c":0.006,"v":600,"n":2,"closed":true}}

Captured on a test instance: a refused subscription:

{"op":"subscribe","id":"x1","channel":"candles","chain":"evm:56","pool":"0x702e…c58b","res":"2m"}
{"id":"x1","type":"error","status":400,"error":"res must be one of 1m, 5m, 15m, 1h, 4h, 1d"}

Errors: 400 (a bad res or currency, or not exactly one of pool and token), 404 (unknown pool, unknown token, no pool charts this token), 503 candles unavailable.

Try it in the interactive docsCreate a free account