/v1/prices/stream Free Price stream (SSE)
Subscribe to live price updates over Server-Sent Events.
Long-lived `text/event-stream` connection. Pushes a `price` event every time a new swap touches one of your subscribed mints, plus periodic comment-only heartbeat lines so intermediaries don't reap the connection as idle. ### Auth Either auth scheme works: - `X-API-Key: <key>` header — for HTTP clients - `?api_key=<key>` query string — for browsers using `EventSource`, which can't set custom headers ### Wire format Each `price` event is a JSON-encoded payload after `data:`: ```text event: price id: 1730500000000 data: {"mint":"EPjFW...","price_usd":"1.0001","ts":1730500000000} ``` Fields: - `mint`: SPL mint address (string) - `price_usd`: latest USD price as a decimal string — preserves precision; parse with `Decimal` rather than `Number` if you care about sub-cent precision - `ts`: epoch milliseconds at which the price was derived The `id` line is the same epoch-ms; clients should track the most recent one and pass it back as the `Last-Event-ID` header on reconnect to resume from where they were. ### Heartbeats A comment-only line (`: keepalive\n\n`) is emitted every ~15s. EventSource clients ignore comments — they exist purely to keep proxies and load balancers from closing the connection. ### Plan limits - Per-key concurrent connections: enforced via `sse_connections_max` on the API key. Excess connection attempts return `429 rate_limited`. - Per-connection mint count: enforced via `max_tokens_per_sse_conn`. Exceeding it returns `400 validation_failed`. ### Cost Currently 0 credits per message; the `prices_stream` cost is configured centrally and may change.
Request
Query parameters
tokensstringrequiredComma-separated list of mint addresses to subscribe to.
Example
curl \
-H "X-API-Key: $REALFLOW_API_KEY" \
"https://api.realflow.so/v1/prices/stream?tokens=So11111111111111111111111111111111111111112" const res = await fetch("https://api.realflow.so/v1/prices/stream?tokens=So11111111111111111111111111111111111111112", {
method: "GET",
headers: {
"X-API-Key": process.env.REALFLOW_API_KEY,
},
});
const data = await res.json();
console.log(data); import { EventSource } from "eventsource";
const es = new EventSource(
"https://api.realflow.so/v1/prices/stream?tokens=So11111111111111111111111111111111111111112",
{ fetch: (u, init) => fetch(u, { ...init, headers: { ...init.headers, "X-API-Key": process.env.REALFLOW_API_KEY } }) }
);
es.addEventListener("price", (ev) => {
const { mint, price_usd, ts } = JSON.parse(ev.data);
console.log(mint, price_usd, ts);
});