WebSockets
The WebSocket gateway provides real-time streaming access to market data and trading updates on the Ethereal exchange. Clients subscribe to channels over a persistent connection and receive plain JSON payloads with short-form keys, optimized for low latency, minimal overhead, and fast parsing.
wss://ws2.ethereal.trade/v1/stream
Live on testnet
Native WebSocket (v2) is not yet live on mainnet. Early access is available on testnet via wss://ws2.etherealtest.net/v1/stream. Visit Socket.IO (v1) if you are looking for socket.io based websocket streams currently live on mainnet.
Subscription
The subscription gateway offers multiple data streams for real-time and periodic updates. Some channels e.g. OrderUpdate push messages immediately as they occur, while others e.g. L2Book emit messages at fixed intervals. Payload formats and message shapes are documented below.
L2Book
L2Book Provides L2 book depth updates for a specific product.
L2_BOOK events are emitted on a configurable fixed interval (as of writing, this is configured to be once every 200ms).
e- event namet- server timestamp (epoch in milliseconds)data- L2 Book price levels detailss- symbol e.g. BTCUSDt- calculated book timestamp (epoch in milliseconds)pt- previous calculated book timestamp (epoch in milliseconds) - optionalUsing both the
ptanddata.tyou can infer whether or not any events were missed during connection or during consumption
a- asks, array of[price, qty]pairsb- bids, array of[price, qty]pairs
A BookDepth message of the current book (up to 100 price levels per side) is emitted back on initial connection. Every subsequent message is a price level diff with absolute quantities. A zero quantity price diff indicates that this level has been removed.
TICKER
TICKERDelivers real-time ticker data feeds for a specified product.
TICKER events are emitted on a configurable fixed interval (currently configured to be once every second).
e- event nameTickert- server timestamp this message was emitted at (epoch in milliseconds)data- Real time ticker datas- symbol e.g. BTCUSDt- calculated best bid / ask book timestampbidPx- best bid priceaskPx- best ask pricebidAmt- total quantity at the best bidaskAmt- total quantity at the best askmarkPx- current mark pricemark24hPx- 24h mark price
In extreme cases, Ticker will skip publishing if both bidPx & askPx are not available. All values are returned as decimals (9 precision).
TRADE_FILL
TRADE_FILLProvides a stream of trades that have occurred filtered by product.
TRADE_FILL events are streamed in real-time as they occur and from the perspective of the taker (i.e. sz, sd).
e- event namet- server timestamp this message was emitted at (epoch in milliseconds)datas- symbol of product tradedt- timestamp trade fills happened (epoch in milliseconds)fills- array of fills that occurred on the products- symbol e.g. BTCUSD where the trade fill occurred onid- trade fill identifierpx- execution pricesz- quantity tradedsd- side (0=BUYor1=SELL) from the perspective of the takersids- tuple of the taker subaccount id and the maker subaccount id
SUBACCOUNT_LIQUIDATION
SUBACCOUNT_LIQUIDATIONProvides an update when a subaccount is liquidated.
When a subaccount is liquidated, all positions are transferred to the insurance fund and derisked at a later time. SubaccountLiquidation events are emitted in real-time.
e- event namet- server timestamp this message was emitted at (epoch in milliseconds)data- Liquidation subaccount datasid-idof liquidated sub-accountt- timestamp sub-account was liquidated (epoch in miliseconds)p- An array of positions liquidated (subaccount may have one or many positions at liquidation):price- mark price at the time of liquidationsz- position size at liquidation (positive of long, negative if short)
ORDER_UPDATE
ORDER_UPDATE Provides updates about order status changes for a specific subaccount.
ORDER_UPDATE events are emitted in real-time, published per-subaccount whenever an order's state changes.
e- event namet- server timestamp (epoch in milliseconds)data- order update detailst- update timestamp (epoch in milliseconds)d- array of order updatesid- order ID (UUID)cloid- client order ID - optionalotyp- order typeqty- original quantityaqty- available (remaining) quantityfill- filled amountpx- limit price - optional, omitted for market orderssd- side (BUY=0,SELL=1)s- symbol e.g. BTCUSDsid- subaccount ID (UUID)st- order statust- order created timestamp (epoch in milliseconds)ro- reduce only (boolean)cl- close (boolean)tif- time in force - optionalet- expires at (epoch in seconds) - optionalpo- post only - optionalspx- stop price - optionalstyp- stop type - optionalspxtyp- stop price type - optionaltr- triggered stategtyp- group contingency type - optionalgid- group ID (UUID) - optional
ORDER_FILL
ORDER_FILLNotifies when orders are filled for a specific subaccount.
ORDER_FILL events are emitted in real-time as they occur, published per-subaccount whenever an order is filled (both maker and taker sides receive their own event).
e- event namet- server timestamp (epoch in milliseconds)data- order fill detailst- fill timestamp (epoch in milliseconds)d- array of order fillsid- fill ID (UUID)oid- order ID (UUID)cloid- client order ID - optionalpx- fill pricesz- filled quantitytyp- order typesd- sides- symbol e.g. BTCUSDsid- subaccount ID (UUID)ro- reduce onlyfee- fee in USDm- is makert- created at timestamp (epoch in milliseconds)
TOKEN_TRANSFER
TOKEN_TRANSFERProvides updates for deposits / withdrawals for a specific subaccount.
TOKEN_TRANSFER events are published per-subaccount when a deposit or withdrawal state changes.
e- event namet- server timestamp this message was emitted at (epoch in milliseconds)data- token transfer detailsid- unique identifier of the transfert- timestamp token transfer event (epoch in miliseconds)sid- subaccount id that owns this transfertName- token nametAddr- token contract addresstyp- transfer type, one of:"DEPOSIT","WITHDRAW"st- transfer status, one of:"SUBMITTED","PENDING","COMPLETED","REJECTED"amt- transfer amountfee- transaction feeiniBk- block number when the transfer was initiated (optional)finBk- block number when the transfer was finalized (optional)iniTx- Transaction hash of the initiation transaction (optional)finTx- Transaction hash of the finalization transaction (optional)lzAddr- LayerZero destination address for cross-chain bridge transfers (optional)lzEid- LayerZero endpoint id identifying the destination chain
Unsubscribing from Channels
To unsubscribe from a channel, send the same payload used to subscribe but with unsubscribe as the event type. Alternatively, disconnecting your entire connection will end all subscriptions. Note that reconnecting will consume rate limits. See System Limits for more details.
Exception Handling
Error responses are returned directly as a reply to the originating event (e.g. subscribe, unsubscribe). They follow a unified shape:
okindicates whether the request succeededcodea machine-readable error code present whenokisfalse
unknown_product
The provided symbol does not match any known product.
validation_error
The request payload failed validation (e.g. missing or invalid fields).
subscription_failed
The server was unable to subscribe to the requested topic.
unsubscribe_failed
The server was unable to unsubscribe from the requested topic.
rate_limit
Too many requests, the client has been rate-limited.
internal_error
An unexpected server-side error occurred.
A successful response would simply just return { "ok": true, ... }
Last updated
