SSE streams
07 / 08

Push, don't poll

Two public SSE endpoints carry every price update and trade in real time — the same streams the site renders.

GET /tokens/stream — global ticks

One event per token that traded in an indexer sync, plus a coarse-grained refresh signal. This is the stream behind the discover and portfolio lists.

  • tick
    Fires
    Per token per sync that saw a trade
    Payload
    PriceTick — the token's latest price state
  • refresh
    Fires
    Once per sync that wrote trades
    Payload
    A signal to re-fetch /tokens — cheaper than polling the list
curl -N https://api.vectr.bot/tokens/stream

GET /tokens/:address/stream — per-token candles

Streams one token's trades as they index and maintains the candle for the requested resolution. The stream behind the token-page chart.

  • bar
    Payload
    The current bucket's OHLCV, updated in place as trades land
  • trade
    Payload
    The raw trade that moved the bar
  • reset
    Payload
    Sent on connect/resume — drop local state and rebuild from what follows
  • res
    Default
    5m
    Notes
    1m | 5m | 15m | 1h | 4h | 1d — anything else falls back to 5m
  • from
    Default
    Notes
    Unix seconds; replay bars from that point before going live
  • Last-Event-ID
    Default
    Notes
    Request header — resume a dropped connection without a gap
const es = new EventSource("https://api.vectr.bot/tokens/0x…/stream?res=1m");
es.addEventListener("bar",   (e) => {/* update the current candle */});
es.addEventListener("trade", (e) => {/* append to the tape */});
es.addEventListener("reset", (e) => {/* clear local state */});

Conventions worth knowing

Bars share the REST candle conventions: bucket = floor(ts / resolution), quiet buckets are flat at the previous close, volume is quote-asset notional. The same math serves REST, live streams and reconnect replay — a bar means the same thing on every path.

SSE, not WebSocket

These are plain server-sent events — one connection, server→client only. Any HTTP client that holds the connection open works; there is no socket protocol to implement.