Skip to main content
GET
TypeScript

Authorizations

Authorization
string
header
required

The Trading API key (trdrs_sk_…), for market data, orders and account state on the accounts its owner holds. Use it server-to-server, and keep it on your server. Its scope is named trading in the API.

Query Parameters

instrument
string
required

The symbol, or a spread expression as /api/market/history accepts. If any symbol in a spread is refused, the spread is refused.

tf
string
required

The timeframe, such as 1m.

Response

An open event stream. The events are:

  • snapshot { bars: WireBar[] }: the whole current window.
  • bar { bar: WireBar }: a bar that is forming or finished. The same t updates the forming bar, and a new t opens the next one.
  • quote { bid: { price, size }, ask: { price, size } }: the real top of the book, only where the feed has one.
  • mark { instrument, price }: the exchange's own mark price as it moves, only where the exchange publishes one. A perpetual's open position, its P&L and its account's rules are measured at its mark, which can carry a decimal its trades can't.
  • session { instrument, last, open, high, low, prevClose, volume, change, changePct, spark }: the session values GET /api/market/quotes would answer for the instrument, sent after the snapshot, again whenever a bar moves them (at most once a second), and read again each minute. A board with the instrument charted needs no poll for it.
  • error { code }: the stream is ending. The codes are unknown_instrument, not_entitled, feed_down, session_displaced (another application signed in on the login that serves the data and took its market data session) and session_expired (your own session ended: while you are signed in, the stream can't outlive your session). Sign in again before you reconnect, rather than retrying blind.

A dropped connection carries no event, and the browser reconnects on its own.

The stream may end with a reconnect event, { code, afterMs }: the engine serving it is restarting for a release, or the trader it serves moved to another engine, and the stream closes right after the event. code is engine_draining. Open the stream again after afterMs milliseconds, which is never more than 1,000: another engine serves it, and it opens as any connection does. It is not an error, so keep what you show until the new stream's first events arrive. The event sets the stream's retry: to afterMs too, so an EventSource that reconnects on its own follows it.

The response is of type string.