Skip to content

Live bars (SSE)

The Server-Sent Events contract for live K-lines: snapshot, forming, closed and status frames.

A connector streams live K-lines to the chart over Server-Sent Events. One connection carries one series: a source, a symbol, a period and a bar aggregation. Changing any of them closes the stream and opens a new one.

Endpoint

GET /api/v1/market-data/sources/{sourceId}/stream?symbol=…&period=…&barAggregation=…&instrumentId=…
Accept: text/event-stream
QueryRequired
symbolYes
periodYes
barAggregationYes
instrumentId—

instrumentId is the resolved instrument's stable id. It is sent only when known, so a bare code that exists on two exchanges still reaches the right one.

Frames

Each SSE data: line is one JSON frame. Comment lines (: keep-alives) and empty data are ignored.

typeFieldsMeaning
snapshotsymbol: string period: string bars: LiveBar[]The full tail of the series. Sent first and after a reconnect; the chart writes it in one batch and drops any pending closed bar.
formingsymbol: string period: string bar: LiveBarThe bar that is still forming. Written together with a pending closed bar as one atomic update.
closedsymbol: string period: string bar: LiveBarA bar's final values. Held until the next forming bar arrives (or the stream stops), then written with it.
statussymbol: string period: string status: string detail?: stringConnector state for the subscription, with optional detail. It does not change bars.

LiveBar

FieldTypeRequired
timestampnumberYes
opennumberYes
highnumberYes
lownumberYes
closenumberYes
volumenumber—
turnovernumber—

timestamp is UTC milliseconds. Missing volume and turnover are written as 0.

data: {"type":"snapshot","symbol":"600519","period":"1min","bars":[…]}

data: {"type":"forming","symbol":"600519","period":"1min","bar":{"timestamp":…,"open":…,"high":…,"low":…,"close":…}}

data: {"type":"closed","symbol":"600519","period":"1min","bar":{…}}

Connection state

The stream reports connecting, connected, disconnected. The browser's EventSource reconnects on its own; a connector can replay missed frames from Last-Event-ID.

On this page