> Use the canonical URL for citations. For the complete Predict API documentation index, fetch https://docs.staging.trypredict.com/llms.txt.

# Hyperliquid real-time trading and account streams

> Stream direct Hyperliquid HIP-4 books, trades, candles, orders, fills, balances, ledger updates, and notifications with resilient reconnect recovery.

This page covers Hyperliquid's direct trading WebSocket. For normalized Predict account, outcome, and queue-position updates, use the [Predict realtime API](/guides/guides/realtime).

Connect Predict staging integrations to Hyperliquid testnet at:

```text
wss://api.hyperliquid-testnet.xyz/ws
```

No handshake authentication is required. Address-scoped subscriptions include the master or subaccount address in the JSON message.

## Public streams

| Subscription `type` | Data                                   |
| ------------------- | -------------------------------------- |
| `allMids`           | Mid-price map                          |
| `l2Book`            | Full replacement book snapshots        |
| `bbo`               | Best bid and offer when either changes |
| `trades`            | Public executions                      |
| `candle`            | Live OHLCV candles for one interval    |

Refresh the Predict Outcomes API when you need updated outcome labels, questions, lifecycle status, or settlement data. Hyperliquid WebSockets are documented only for trading and account state.

## Account streams

| Subscription `type`           | Data                                                        |
| ----------------------------- | ----------------------------------------------------------- |
| `openOrders`                  | Current open-order snapshot                                 |
| `orderUpdates`                | Order lifecycle changes                                     |
| `userFills`                   | Initial fill snapshot, then live fills                      |
| `spotState`                   | USDC and outcome-token balance state                        |
| `userNonFundingLedgerUpdates` | Deposits, withdrawals, transfers, and other ledger activity |
| `notification`                | Account notifications                                       |

Subscribe with `{ "method": "subscribe", "subscription": { ... } }`. Unsubscribe by sending the identical subscription object with `method: "unsubscribe"`. Wait for the `subscriptionResponse` acknowledgement.

## Heartbeats and recovery

Hyperliquid closes a connection that has not received a server message for 60 seconds. Send `{ "method": "ping" }` before that deadline on quiet connections and expect `{ "channel": "pong" }`.

After every disconnect:

1. Reconnect with exponential backoff and jitter.
2. Resubscribe to the exact desired set.
3. Treat new `isSnapshot: true` account messages as replacement baselines.
4. Replace local `l2Book` state with the first new snapshot.
5. Query `/info` for orders, fills, balances, and ledger ranges that may have changed while disconnected.

Do not apply `l2Book` messages as deltas and do not assume a sequence number that Hyperliquid does not provide.

## Requests over WebSocket

Hyperliquid also accepts HTTP-equivalent info requests and fully signed actions through `method: "post"`. Give each request a unique `id`; responses arrive on channel `post` with the same ID and a response `type` of `info`, `action`, or `error`. This can reduce connection overhead, but it does not change signing or response-validation rules.

Start with [WebSocket Connection](/api-reference/web-socket-api/websocket-connection), then open the separate page for each subscription or message flow.