> ## Documentation Index
> Fetch the complete documentation index at: https://public-perps-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# WebSocket Protocol

> Hyperliquid-native WebSocket protocol, channel mapping, and rate limits

Hyperliquid exposes a native WebSocket endpoint at `wss://api.hyperliquid.xyz/ws`. The SDK discovers this URL from the `wsUrl` field in the `GET /providers` response. If you're using the SDK, see [Streaming](/sdk/streaming) instead.

For the full WebSocket protocol specification (message format, keepalive, and subscription channels), see the [Hyperliquid WebSocket documentation](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions).

## SDK Channel Mapping

The SDK maps between normalized channel names and Hyperliquid-native channels:

| SDK channel      | HL subscription type          | SDK event type                              |
| ---------------- | ----------------------------- | ------------------------------------------- |
| `orderbook`      | `l2`                          | `OrderbookResponse`                         |
| `marketsContext` | `pac`, `sac`, `fastAssetCtxs` | `Record<string, MarketContext>`             |
| `marketContext`  | `activeAssetCtx`              | `MarketContext`                             |
| `candle`         | `candle`                      | `Candle`                                    |
| `trades`         | `trades`                      | `Trade[]`                                   |
| `orderUpdates`   | `orderUpdates`                | `{ openOrders, triggerOrders, terminated }` |
| `fills`          | `userFills`                   | `Fill[]`                                    |
| `positions`      | `allDexsClearinghouseState`   | `Position[]`                                |
| `accountSummary` | `allDexsClearinghouseState`   | `AccountSummary`                            |
| `spotBalances`   | `spotState`                   | `(Balance & { locked: string })[]`          |

`marketContext` subscribes to Hyperliquid's `activeAssetCtx` feed for the requested `marketId`. Each emitted SDK event contains a normalized `MarketContext` snapshot with mark price, oracle price, previous-day price, 24h volume, open interest, and funding when the venue includes them.

`marketsContext` combines Hyperliquid's compressed asset-context feeds with `fastAssetCtxs`, so the SDK can stream the all-market context map while keeping high-frequency mid and mark prices fresh.

`positions` and `accountSummary` are two normalized views over the same `allDexsClearinghouseState` wire subscription — subscribing to both for one address opens a single upstream feed.

## Rate Limits

Hyperliquid enforces per-connection limits:

* **1000** total subscriptions per WebSocket connection
* **10** user-specific subscriptions per connection (orderUpdates, userFills, allDexsClearinghouseState, spotState)
