For the complete documentation index, see llms.txt. This page is also available as Markdown.

WebSocket

This page will help you get started with the Lighter WebSocket server.

Connection

Environment
URL

Lighter mainnet

wss://mainnet.zklighter.elliot.ai/stream

Lighter testnet

wss://testnet.zklighter.elliot.ai/stream

Robinhood Chain mainnet

wss://api.rh.lighter.xyz/stream

Robinhood Chain testnet

wss://api.rh-testnet.lighter.xyz/stream

You can directly connect to the WebSocket server using wscat:

wscat -c 'wss://mainnet.zklighter.elliot.ai/stream'

If you're connecting from a restricted region, you can still access read-only data:

wscat -c 'wss://mainnet.zklighter.elliot.ai/stream?readonly=true'

Message envelope

Message
Meaning

type: "connected"

The socket is connected; subscribe to the channels you need.

type: "subscribed/<channel>"

Subscription acknowledgement with the initial snapshot.

type: "update/<channel>"

A subsequent update. Apply it according to that channel's rules.

error: {code, message}

Request or subscription failed. Errors need not contain a type field; an optional id identifies the request.

Subscribe requests use slash-separated channel names; response channel values use colons. Private channels take an auth token inside the subscribe message, as shown below. This WebSocket field is separate from REST authentication, which uses the Authorization header. Public-pool data does not require authentication; see pool_data and pool_info.

Structure blocks below use placeholders such as INTEGER, STRING and FLOAT; they describe payloads and are not literal JSON. Example response blocks are JSON. transaction_time is in microseconds and may be omitted when no transaction execution time is available. See Timestamps for field-specific units.

Keepalive Requirements

Clients are responsible for keeping the connection alive by sending at least one frame every 2 minutes. This can be either:

  • A WebSocket ping frame

  • Any application-level message

Clients sending {"type":"ping"} will receive back {"type":"pong"}.

If the server receives no frames from a client within the 2-minute window, it will close the connection.

Support for permessage-deflate compression is enabled.

Writes to slow clients time out after 250 ms by default. Keep reading messages continuously; if the connection closes, reconnect and resubscribe to obtain fresh snapshots.

Send Tx

You can send transactions using the websocket as follows:

The tx_type options can be found in the SignerClient file, while tx_info can be generated using the sign methods in the SignerClient.

Send Batch Tx

You can send batch transactions to execute up to 50 transactions in a single message. Larger batches are rejected with error 21514.

The tx_type options can be found in the SignerClient file, while tx_info can be generated using the sign methods in the SignerClient.

Types

These types are shared across channels. Fields marked optional are omitted when zero or empty. Field names and numeric/string representations match the API.

Transaction JSON

To decode event_info, you can refer to Data Structures.

Example:

Used in: Account Tx.

Order JSON

Trade JSON

Example:

Position JSON

Example:

PoolShares JSON

Example:

Asset JSON

Structure (pseudocode):

Example:

PositionFunding JSON

Channels

To unsubscribe from a channel, use the following syntax:

Order Book

The order book channel sends the new ask and bid orders for the given market in batches, every 50ms. While the nonce is tied to Lighter's matching engine, the offset is tied to the API servers; hence, you can expect the offset to change drastically on reconnection if you're routed to a different server. Regardless, on each update the offset will increase, but it's not guaranteed to be continuous. Additionally, this channel sends a complete snapshot on subscription, but only state changes after that. To verify the continuity of the data, you can check that begin_nonce on the current update matches the nonce (i.e. last_nonce) of the previous update.

spinner

Example Subscription

Response Structure

Example Response

Best Bid and Offer (BBO)

Updates are triggered on every nonce update for a given market's order book.

spinner

Example subscription:

Response Structure:

Example Response:

Market Stats

market_stats and spot_market_stats exclude binary options. Use Binary options market stats for those markets.

The market stats channel sends the market stat data for a given market. current_funding_rate is an estimation of the upcoming funding payment, while funding_rate represents the last funding payment that occurred (at funding_timestamp). To fetch stats for spot markets, use spot_market_stats.

spinner

or

Example Subscription

Response Structure

Example Response

Multiple markets

To follow a chosen set of markets on one subscription, subscribe to the bare market_stats channel with market_ids, a list of up to 500 public market IDs. Duplicate IDs are ignored. Responses use channel: "market_stats" and a market_stats object keyed by market ID, as with market_stats/all.

  • Send another subscribe to market_stats with market_ids to add markets to the live subscription. The added markets' current stats arrive in an update/market_stats message. A request that would take the subscription above 500 markets is rejected and changes nothing.

  • Send unsubscribe to market_stats with market_ids to remove those markets. An unsubscribe without market_ids ends the whole subscription.

Partial updates

Add "partial": true to a market_stats/all or market_stats (with market_ids) subscription to receive only changed fields. The subscribed/market_stats snapshot, and the stats sent for markets added later, stay complete. Each later update/market_stats entry contains market_id plus the fields that changed since the previous message sent on this subscription; merge it into the stats you hold. partial is rejected on market_stats/{MARKET_INDEX}.

Binary Options Market Stats

Subscribe to bo_market_stats/{MARKET_INDEX} for one market or bo_market_stats/all for all binary options markets. The all-market response contains a bo_market_stats object keyed by market ID; a single-market response contains one stats object. The all-market stream also includes old, settled and not-yet-open markets: filter by status: "active", then check the trading window and is_frozen in events before placing orders. See Binary options WebSocket for fields and lifecycle statuses.

spinner

Trade

The trade channel sends the new trade data for the given market.

spinner

Example Subscription

Response Structure

Example Response

Candlesticks

Real-time candlestick (OHLCV) updates via WebSocket. Subscribe to any market and resolution to receive live candle data as trades occur. Supported resolutions: 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d. The candles[] array allows up to 2 candles to be sent in a single update when a candle period closes (rolls over). If so, candles[0] will be the oldest, just closed candle.

spinner

Example Subscription

Response Structure (Subscribe)

Response Structure (Updates)

Example Response (Subscribe)

Returns the current live candle.

Example Response (Updates)

Returns the latest candle state, whenever a trade occurs, with a 500ms batching.

Up/Down Candlesticks

Subscribe to up_down_candle/{SYMBOL}/{DURATION}/{RESOLUTION} for the underlying price of an Up/Down series, for example up_down_candle/eth/15m/1s. Resolutions are 1s and 30s. The initial snapshot contains up to 300 candles. See Binary options WebSocket for the payload and upDownCandles for REST history.

spinner

Mark Price Candlesticks

Real-time mark price candlestick (OHLC) updates via WebSocket. Subscribe to any market and resolution to receive live candle data as mark price samples arrive. Supported resolutions: 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d. The candles[] array allows up to 2 candles to be sent in a single update when a candle period closes (rolls over). If so, candles[0] will be the oldest, just closed candle.

spinner

Example Subscription

Response Structure (Subscribe)

Response Structure (Updates)

Example Response (Subscribe)

Returns the current live candle.

Example Response (Updates)

Returns the latest candle state, as mark price samples arrive, batched every 500 ms.

Account All

Binary options positions appear separately in bo_positions (also in account_all_positions); account_market uses the singular bo_position. See Binary options positions.

The account all channel sends specific account market data for all markets. Each new subscribe message returns a fresh snapshot; it does not reconnect the socket. Updates contain changed data: assets may be null when nothing changed, and daily/weekly/monthly/total trade statistics are snapshot-only fields.

spinner

Example Subscription

Response Structure

Example Response

Mainnet snapshot captured on 2026-10-22, with the positions map shortened to one entry. Empty funding and trade maps are valid.

Account Market

The account market channel sends specific account market data for a market. If {MARKET_ID} is a perpetual market, assets will return null, if {MARKET_ID} is a spot market, funding_history will return null.

spinner

Example Subscription

Response Structure

assets and funding_history may be null in the initial snapshot when not applicable, and empty collections on updates. position and bo_position are single objects or null, not arrays.

Account Stats

The account stats channel sends account stats data for the specific account.

spinner

Example Subscription

Response Structure

Example Response

Account Tx

This channel sends transactions related to a specific account.

spinner

Response Structure

Account All Orders

The account all orders channel sends data about all the orders of an account.

spinner

Response Structure

Height

Blockchain height updates

spinner

Response Structure

Pool data

Provides data about pool activities: trades, orders, positions, shares and funding histories.

spinner

Response Structure

Pool info

Provides information about pools.

spinner

Response Structure

Notification

Provides notifications received by an account. Notifications can be of three kinds: liquidation, deleverage, or announcement. Each kind has a different content structure.

spinner

Response Structure

Liquidation Notification Content

Deleverage Notification Content

Announcement Notification Content

Example response

Account Orders

The account orders channel sends data about the orders of an account on a certain market.

spinner

Response Structure

Account All Trades

The account all trades channel sends data about all the trades of an account.

spinner

Response Structure

Account All Positions

The account all positions channel sends data about all the positions of an account.

spinner

Response Structure

Spot Market Stats

The spot market stats channel sends the market stat data for the given spot market.

spinner

or

Example Subscription

spot_market_stats supports the same market_ids list subscription and partial updates as market_stats, using the bare spot_market_stats channel and the spot_market_stats payload key.

Response Structure using all

Example Response using all

Response Structure using MARKET_INDEX

Example Response using MARKET_INDEX

Account All Assets

The account all assets channel sends specific account market data for all spot markets for a specific account. balance is in coin terms, not USDC (unless asset_index=3, in which case they coincide).

spinner

Example Subscription

Response Structure

Example Response

Average Entry Prices

Updates on the account_spot_avg_entry_prices channel are triggered whenever an event occurs for a given spot asset. Each event is accounted for as a buy or sell executed at the index price. Events include trades, deposits, withdrawals, transfers, and staking. The last_trade_id field confirms the validity of the data returned up to that trade_id.

spinner

Example subscription:

Response Structure:

Example Response:

Request for Quote (RFQ)

This channel allows you to receive all currently open RFQs, followed by live updates as new ones arrive. RFQ responses are hidden if you're not the requester, so you will only see the market and its size. API endpoints to create, respond, update, get, and list RFQs are available here. Currently, this program is whitelist-only.

spinner

Response Structure

Example Response

Live points (Lighter on Robinhood Chain only)

This channel returns the total live points accrued to an account index. Updates are triggered as the total changes. You can confirm you have the latest value by fetching livePoints/total via REST.

spinner

Example Subscription:

Response Structure

Example Response

Last updated

Was this helpful?