Loading the API documentation
No notifications.
Language
English
No other language is available yet.
Loading the API documentation
/v1/streamWebSocket stream of ticker, trades, and order book updates
Upgrade to a WebSocket (no compression). The server pushes the current projection state, in the same shapes as the REST responses, whenever ingest commits a change. Pushes are coalesced: at most one per channel every 250 ms. Each push is the full current state of the channel, not a delta; replace what you show with it.
Channels (symbols in path form BASE-QUOTE, case-insensitive on input, uppercased in server messages):
ticker: every pair, data like GET /v1/markets/pairs (MarketPair[]). Pushed when any market trades.trades:BASE-QUOTE: the newest 50 trades, newest first, like GET /v1/markets/{symbol}/trades (Trade[]).orderbook:BASE-QUOTE: 20 levels per side of the default venue, like GET /v1/markets/{symbol}/orderbook without venue (OrderBook, which names its venue). Pushed when any venue's book of the market changes.Client messages are JSON text frames, StreamClientMessage: {"op":"subscribe","channels":["ticker","trades:ZET-ZUSD"]}, {"op":"unsubscribe","channels":[...]}, or {"op":"ping","t":<number>}. Every subscribe is answered with a snapshot of each listed channel (also for channels already subscribed), sent within about 250 ms. Unsubscribe has no reply. A ping is answered at once with {"op":"pong","t":<same t>} so a browser, which cannot see protocol-level pings, can time the round trip with its own clock; pings count against the inbound message limit.
Server messages are JSON text frames, StreamServerMessage: {"channel": "...", "data": ...}, {"op":"pong","t":...}, or {"error": {"code", "message"}}. Error codes on an open stream: bad_request (malformed message, unknown op or channel, more than 20 subscriptions; the message is ignored and the stream stays open), not_found (market not listed; the subscription is dropped), internal (a snapshot could not be loaded; subscribe again).
Limits: 20 subscriptions per connection; inbound messages at most 4 KiB and about 5 per second (burst 10); the server pings every 25 s and closes the connection when a pong does not arrive within 5 s; each outgoing message must be written within 5 s. Open connections are capped in total (STREAM_MAX_CONNS, default 1000) and per client IP (STREAM_MAX_CONNS_PER_IP, default 10). Connection attempts are limited per client IP (1 per second, burst 10). The /v1 request rate limit, concurrency cap, and 5 second deadline do not apply to an open stream.
Close codes sent by the server:
1001 going away: server shutting down; reconnect with backoff.1008 policy violation: too many inbound messages.1009 message too big: an inbound message over 4 KiB.1013 try again later: the client did not read fast enough (more than 64 queued messages); reconnect and resubscribe.A connection that stops answering pings is dropped without a close frame. Reconnect with exponential backoff and resubscribe; subscriptions do not survive a reconnect.
| Name | In | Required | Type and limits | Description |
|---|---|---|---|---|
Origin | header | Yes | string | Must be one of the server's allowed origins (CORS_ORIGINS), compared exactly. |
| Status | Meaning | Body |
|---|---|---|
| 101 | Switched to the WebSocket protocol | None |
| 400 | Not a valid WebSocket opening handshake (GET, | Error |
| 403 | Origin missing or not allowed (code | Error |
| 429 | Too many connection attempts, or this client already holds the maximum number of open streams (code | Error |
| 503 | The stream is at its connection cap, is taking more new connections per second than its process-wide connect budget allows, or the server is shutting down (code | Error |
Connect a WebSocket client to wss://exchange.zethareum.com/v1/stream and send JSON text frames. Each subscribe is answered with a full snapshot of every channel you list, then a fresh full snapshot whenever it changes (not a delta).
op: subscribe, unsubscribe or ping; channels: 1 to 20 names. {"op":"ping","t":<number>} takes no channels and is answered with a pong carrying the same t.^(ticker|(trades|orderbook):[A-Za-z0-9]{1,12}-[A-Za-z0-9]{1,12})$^trades:[A-Z0-9]{1,12}-[A-Z0-9]{1,12}$; data array of Trade^orderbook:[A-Z0-9]{1,12}-[A-Z0-9]{1,12}$; data OrderBook{"op":"subscribe","channels":["ticker","trades:ZET-ZUSD"]}