Live prices over SSE
GET /v1/prices/stream opens a long-lived
text/event-stream connection. We push a price
event every time a new swap touches one of your subscribed mints, plus
a comment-only heartbeat every ~15 seconds so intermediaries don't reap
the connection as idle.
Subscribe
Specify mints with the tokens query param — comma-separated:
curl -N \
-H "X-API-Key: $REALFLOW_API_KEY" \
"https://api.realflow.so/v1/prices/stream?tokens=So111...,EPjFW..." // Browser EventSource can't set headers, so pass api_key= in the query.
const es = new EventSource(
"https://api.realflow.so/v1/prices/stream?tokens=So111...,EPjFW...&api_key=" + KEY
);
es.addEventListener("price", (ev) => {
const { mint, price_usd, ts } = JSON.parse(ev.data);
console.log(mint, price_usd, ts);
}); import { EventSource } from "eventsource";
const es = new EventSource(
"https://api.realflow.so/v1/prices/stream?tokens=So111...,EPjFW...",
{ 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);
}); Wire format
Each price event:
event: price
id: 1730500000000
data: {"mint":"EPjFW...","price_usd":"1.0001","ts":1730500000000}
mint— SPL mint address.price_usd— decimal string; parse withDecimalif you care about sub-cent precision.ts— epoch milliseconds at which the price was derived.id— same epoch-ms; clients should track the most recent one and pass it back asLast-Event-IDon reconnect.
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
- Concurrent SSE connections per key — enforced via the key's
sse_connections_max. Excess attempts →429 rate_limited. - Mints per connection — enforced via
max_tokens_per_sse_conn. Exceeding →400 validation_failed.
Reconnect handling
SSE clients reconnect automatically (per the spec). When they do, they
include Last-Event-ID; we use that to resume from the last
event you saw, so you don't miss prices during transient drops or our
blue/green deploys.
Pricing
During launch, per-message cost is 0 credits — you only
pay for the connection slot (counted against your plan's
sse_connections_max). The current per-message cost is
visible at /docs/rate-limits and via
GET /v1/meta/credit-costs.