Hyperliquid WebSocket API: Subscriptions, Limits and Reconnects
Hyperdash explains the Hyperliquid WebSocket API: the URL, every subscription type, the limits and what breaks in production, plus Hyperdash streams that resume from a cursor.
, 9 min read

The Hyperliquid WebSocket API lives at wss://api.hyperliquid.xyz/ws. You open a connection, send a subscribe message for a feed such as trades, l2Book, candle or userFills, and the server pushes updates until you unsubscribe or the connection drops. It is free and needs no key to read data. Each IP address gets 10 connections and 1,000 subscriptions, and user feeds can follow at most 10 wallets.
Our pick: the Hyperdash Data API. For a production app, Hyperdash Data API streams at wss://data.hyperdash.com/v1/stream handle the recovery that the public socket leaves to the client. Each batch carries a cursor, so a client that reconnects resumes where it stopped, and a gap message names any range it cannot replay, so you backfill it over REST. Streams cover trades with taker and maker wallets, books, liquidations across every market and per-wallet fills and orders. They run on every plan, from $20 a month.
Get started in about 2 minutes: create your Hyperdash account and pick a plan from $20 a month, then connect the Hyperdash MCP server to Claude or ChatGPT. You sign in with your Hyperdash account, so no API key is needed.
For whether a job needs a stream or a REST call on a timer, read Hyperliquid Data API vs Streams.
How do you connect to the Hyperliquid WebSocket?
Open a WebSocket to the mainnet URL, or to wss://api.hyperliquid-testnet.xyz/ws on testnet, and send one JSON message per feed. This one subscribes to BTC trades:
{"method": "subscribe", "subscription": {"type": "trades", "coin": "BTC"}}The server first answers on the subscriptionResponse channel, echoing your subscription. Then data arrives on a channel named after the feed, here trades, with an array of trades in data. Each trade carries the side, price, size, time, a trade id and the two wallets, buyer first. To stop a feed, send the same object with "method": "unsubscribe".
Two details trip up first clients:
- Keep the connection alive. The server closes any connection it has not sent a message to in the last 60 seconds. On a quiet feed, send
{"method": "ping"}and the server replies on thepongchannel (timeouts and heartbeats). - Use the account's own address. Wallet feeds need the master or sub-account address. Subscribing with an agent wallet's address returns an empty result.
Which subscription types does the Hyperliquid WebSocket offer?
The subscriptions page lists 27 types. They fall into three groups.
| Group | Subscription types | Keyed by |
|---|---|---|
| Market data | `trades`, `l2Book`, `l2`, `bbo`, `candle`, `activeAssetCtx` | `coin` (`c` on `l2`) |
| All-market data | `fastAssetCtxs`, `pac`, `sac`, `outcomeMetaUpdates`, plus the deprecated `allMids` and `allDexsAssetCtxs` | None |
| Wallet data | `userFills`, `orderUpdates`, `userEvents`, `userFundings`, `userNonFundingLedgerUpdates`, `openOrders`, `clearinghouseState`, `allDexsClearinghouseState`, `spotState`, `activeAssetData`, `twapStates`, `userTwapSliceFills`, `userTwapHistory`, `notification`, `webData3` | `user` |
A few of them need more than a coin:
candletakes aninterval:1m,3m,5m,15m,30m,1h,2h,4h,8h,12h,1d,3d,1wor1M.l2Bookpushes full book snapshots and takes optionalnSigFigsandmantissato group price levels. The newerl2feed sends one snapshot of up to 20 levels per side, then diffs. Each diff removes levels by their position in the previous book and adds or replaces levels by price.fastAssetCtxs,pacandsacsend prices and asset contexts for every market as base64-encoded raw DEFLATE. In Python that iszlib.decompress(base64.b64decode(data), wbits=-15). Plainzliborgzipdecoding fails.userFillstakes an optionalaggregateByTimeto merge partial fills of one crossing order.
What are the Hyperliquid WebSocket limits?
These limits apply per IP address (rate limits and user limits):
- 10 WebSocket connections at once.
- 30 new connections per minute.
- 1,000 subscriptions.
- 10 unique users across all wallet subscriptions.
- 2,000 messages sent to Hyperliquid per minute, across all connections.
- 100
postrequests in flight at once.
The wallet limit shapes most designs. A copy-trading monitor, a wallet tracker or a leaderboard that follows 50 wallets cannot do it from one IP, because the socket stops at 10 users no matter how many subscriptions are left. REST calls share a separate budget of 1,200 weight per minute, which is what a backfill spends.
What goes wrong with the Hyperliquid WebSocket in production?
Hyperliquid's docs tell automated users to expect the server to disconnect them "periodically and without announcement" and to reconnect on their own (WebSocket). A client that runs for days has to handle four things.
- Reconnects. Detect the close, reconnect with backoff, and send every subscription again. Stay under the cap of 30 new connections a minute, which a tight reconnect loop can hit.
- Snapshots on resubscribe. For time series feeds such as
userFills, the first message after a subscribe is a snapshot of earlier data taggedisSnapshot: true. Hyperliquid's docs say it carries what you missed. It also repeats what you already have, so the handler has to skip duplicates. For trades, the unique key is block time, coin andtidtogether. - Gaps longer than the snapshot. Anything else you missed comes from the matching info request, and the info endpoint has limits of its own.
userFillsByTimereturns at most 2,000 fills per response and only the 10,000 most recent fills of a wallet.candleSnapshotreturns only the most recent 5,000 candles. If your client was offline for a day, a busy wallet can run past those limits. - Book state. On the
l2diff feed every update depends on the one before it. After any reconnect, drop your copy of the book and rebuild it from the new snapshot.
How do Hyperdash streams handle reconnects and gaps?
Hyperdash streams build resume and gap detection into the protocol (streams). Connect to wss://data.hyperdash.com/v1/stream with your key in the Authorization header (it needs the streams:read scope). Wait for ready, then subscribe:
{"op": "subscribe", "channel": "fills", "address": "0x...", "cursor": "<last cursor>"}Events arrive in data batches of up to 100, each with a cursor. Process the batch, save the cursor, then send {"op": "ack", "sub": ..., "batch": ...}. The next batch waits for that ack, and a batch left unacknowledged for 10 seconds ends the subscription with ack_timeout. After a disconnect, subscribe again with your last cursor and the stream continues after the last batch you acknowledged. Events stay available for about 15 minutes, or about 5 minutes on mids and markets. If what you need is older, or was lost in an ingest outage, a gap message names the missing range. You fill it from the matching REST endpoint, for example one wallet's fills over the last hour:
curl "https://data.hyperdash.com/v1/accounts/0xADDRESS/fills?start_time=$(( ($(date +%s) - 3600) * 1000 ))" -H "Authorization: Bearer $HYPERDASH_API_KEY"Each request covers up to 7 days, within your plan's history depth.
Live now:
- Per-wallet:
fills,orders(open, fill, cancel, trigger and reject),ledgerandtwap. - Per-market:
tradeswith taker and maker wallets,book(full 20-level snapshots),bbo,ctx(mark, oracle, mid, funding rate, open interest and 24-hour volume),liquidation-levelsandstop-levels. - Liquidations: one market, or every market with
"coin": "*". - All markets:
midsandmarkets. - Candles: the
5minterval.
Not live yet: the per-wallet funding and account (positions and margin) channels, and the 1m, 15m, 1h, 4h and 1d candle intervals. Subscribing to them returns unavailable until Hyperdash switches them on. Until then, read positions from GET /v1/accounts/{address}/positions and candles from the candles endpoint over REST.
Each acknowledged event costs 1 credit, or 5 on markets, and replays of events you already paid for cost nothing. A connection carries 20 subscriptions. Connections per workspace run from 2 on Hobby to 50 on Scale, and the orders channel follows 3 wallets on Hobby up to 200 on Scale (plans). Streams read Hyperdash's own nodes, so they do not use your IP's Hyperliquid connection or wallet limits.
Hyperliquid WebSocket vs Hyperdash streams
| Hyperdash streams | Hyperliquid WebSocket | |
|---|---|---|
| URL | `wss://data.hyperdash.com/v1/stream` | `wss://api.hyperliquid.xyz/ws` |
| Access | API key, plans from $20 a month | No key to read data, free |
| Cost | 1 credit per acknowledged event, 5 on `markets` | Free |
| Connections | 2 to 50 per workspace, by plan | 10 per IP |
| Wallet feeds | `orders` on 3 to 200 wallets, by plan | 10 unique users per IP |
| After a disconnect | Resume from your cursor for about 15 minutes, 5 on `mids` and `markets` | Snapshot on resubscribe, then info requests |
| Missed data | `gap` message names the range | Not flagged |
| Liquidations | Per market or every market with `"coin": "*"` | Inside one wallet's fills and events |
| Live wallet positions | Not live yet: use REST | `clearinghouseState` |
Hyperliquid's socket works well for a handful of wallets or markets on one server. When a stream feeds an app other people depend on, Hyperdash's cursors, acks and gap messages replace recovery code you would otherwise write and maintain. Teams that need a feed the public channels do not carry, such as L4 order book updates every block, can have it added to their plan by Hyperdash's integration team.
Ask your AI agent to build a Hyperliquid stream client
Give an agent the Hyperdash docs and ask: "Write a Node client that streams one wallet's fills from Hyperdash, saves the cursor after each batch, and backfills any gap over REST."
- Connect the MCP server: the Hyperdash MCP server works with Claude, ChatGPT, Claude Code, Codex or Cursor; setup takes about 2 minutes and you sign in with your Hyperdash account.
- Install the skills: Hyperdash skills give Claude Code, Codex or Cursor working knowledge of the API with one command; in Claude or ChatGPT, paste the skill link. The Build skill covers live streams, cursors and retries.
- Ask your agent: The Data API guides answer questions like this with one prompt, including Copy trading, Trader analysis and Liquidation heatmaps.
- Read the docs: the Data API docs, the streams reference, and the endpoint index for agents.
Further reading: Hyperliquid API Explained for the REST side, and the Hyperliquid Order Book API for what book streams cost.
FAQ
What is the Hyperliquid WebSocket URL?
Mainnet is wss://api.hyperliquid.xyz/ws and testnet is wss://api.hyperliquid-testnet.xyz/ws. Hyperdash streams, with resume cursors and gap messages, are at wss://data.hyperdash.com/v1/stream.
How many WebSocket connections does Hyperliquid allow?
10 connections per IP address, with at most 30 new connections a minute and 1,000 subscriptions in total. On Hyperdash, connections are counted per workspace instead, from 2 on Hobby to 50 on Scale, with 20 subscriptions each.
Why does my Hyperliquid WebSocket disconnect after 60 seconds?
The server closes a connection it has not sent a message to in 60 seconds. On quiet feeds, send {"method": "ping"} regularly. Hyperdash streams send their own ping every 5 seconds.
Why is my Hyperliquid userFills subscription empty?
A common cause is subscribing with an agent wallet's address. Wallet feeds need the master account or sub-account address that holds the positions.
Can I stream liquidations for every Hyperliquid market?
On Hyperdash, yes: subscribe to the liquidations channel with "coin": "*", or with one coin. Hyperliquid's own socket reports liquidations inside a single wallet's fills and events.
Can I place orders over the Hyperliquid WebSocket?
Yes. Wrap a signed exchange action in a post message with "type": "action", and the result returns on the post channel under your request id.
Get started with Hyperdash
- Create your Hyperdash account and get your first API key. Plans start at $20 a month.
- Connect the Hyperdash MCP server to Claude, ChatGPT, Claude Code, Codex or Cursor in about 2 minutes, with no API key.
- Make your first request with the Quickstart.
Need full history, an SLA or Hyperliquid Peering in Tokyo or Frankfurt? Talk to the Hyperdash team.
Start trading
Trade 600+ markets 24/7 with live position, order flow and liquidation data.