> For the complete documentation index, see [llms.txt](https://exliquid.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://exliquid.gitbook.io/docs/developers/websocket.md).

# WebSocket

The WebSocket API provides low-latency market and account updates.

The versioned endpoint path is:

```
/ws/v1
```

The public `wss://` base URL is published in [Networks and versions](/docs/reference/networks-and-versions.md) when available.

## Connection flow

A client should expect this lifecycle:

```
connect
→ hello
→ authenticate if account channels are needed
→ subscribe
→ snapshot
→ ordered delta updates
→ resume or resynchronize after reconnect/gap
```

## Core messages

| Message                     | Direction       | Purpose                             |
| --------------------------- | --------------- | ----------------------------------- |
| `hello`                     | server → client | Connection/version information      |
| `ping` / `pong`             | both            | Heartbeat                           |
| `auth` / `auth_ack`         | client/server   | Authenticate account streams        |
| `subscribe` / `sub_ack`     | client/server   | Subscribe to channels               |
| `unsubscribe` / `unsub_ack` | client/server   | Remove subscriptions                |
| `resume` / `resume_ack`     | client/server   | Resume from a supported prior state |
| `snapshot`                  | server → client | Initial channel state               |
| `delta`                     | server → client | Incremental update                  |
| `error`                     | server → client | Protocol error                      |

## Public market channels

The current versioned schema defines public channels including:

| Channel           | Purpose                         |
| ----------------- | ------------------------------- |
| `books.{market}`  | Order-book updates              |
| `trades.{market}` | Trade updates                   |
| `prices`          | Oracle/index/mark price updates |
| `blocks`          | New block notifications         |
| `service.status`  | Public service-status updates   |

## Authenticated account channels

After authentication, account-specific subscriptions can include:

| Channel                                 | Purpose                    |
| --------------------------------------- | -------------------------- |
| `account.{address}.orders`              | Order updates              |
| `account.{address}.positions`           | Position updates           |
| `account.{address}.balances`            | Balance updates            |
| `account.{address}.margin`              | Margin updates             |
| `account.{address}.fills`               | Fill updates               |
| `account.{address}.conditional-intents` | Conditional-intent updates |
| `account.{address}.liquidations`        | Liquidation updates        |
| `account.{address}.transactions`        | Transaction updates        |

Authentication must authorize the address used by the account channel.

## Snapshot and delta handling

After subscribing, initialize local state from the provided snapshot before applying deltas.

Each delta includes ordering information. If the expected sequence does not match, stop applying deltas blindly and recover through resume or a fresh snapshot.

## Reconnect behavior

A production client must assume that updates can occur while its connection is down.

Recommended behavior:

1. reconnect;
2. attempt resume when a valid resume token is available;
3. if resume is unavailable, obtain a new snapshot;
4. replace local channel state;
5. continue applying ordered deltas.

## Limits and backpressure

The current protocol schema defines connection/subscription/message limits. Deployment policy can further constrain rate limits.

Clients should handle explicit rate-limit or channel-limit errors and avoid treating reconnect loops as a retry strategy without backoff.

## Important consistency rule

WebSocket is optimized for timely delivery, not as the only source for final account reconciliation.

For actions affecting balances, positions or liquidation risk, use committed REST/transaction confirmation state when final correctness matters.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://exliquid.gitbook.io/docs/developers/websocket.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
