> For the complete documentation index, see [llms.txt](https://docs.coinmarketman.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coinmarketman.com/websocket-streams.md). Agents can also search and read this documentation through its [MCP server](https://docs.coinmarketman.com/~gitbook/mcp).

# WebSocket Streams

Connect to live Hyperliquid fills, account events, TWAPs, and orders.

Receive live Hyperliquid fills, account events, TWAP status updates, and order events. Streams use WebSocket or SSE and are powered by [Centrifugo](https://centrifugal.dev).

Use an SDK for automatic keep-alives, reconnection, and replay. Use plain WebSocket when you need protocol-level control. Order book, trade, and mid-price streams are documented in [Order Book Data](https://docs.coinmarketman.com/order-book-data.md).

### Before you begin

Create or copy an API key from the [API Dashboard – How to Use](https://docs.coinmarketman.com/api-dashboard-how-to-use.md) page. Authentication validates your key when the connection opens. Channel authorization can then refuse individual subscriptions.

WebSocket access is included in the Surge, Flow, and Stream plans, and in Enterprise plans by contract. For details, see [Rate Limits & Pricing](https://docs.coinmarketman.com/endpoints/rate-limits-and-pricing.md).

### Endpoints

<table><thead><tr><th width="231.07421875">Purpose</th><th>URL</th></tr></thead><tbody><tr><td>WebSocket</td><td><code>wss://jp-ws.hypertracker.io/connection/websocket</code></td></tr><tr><td>SSE</td><td><code>https://jp-ws.hypertracker.io/connection/sse</code></td></tr><tr><td>SSE command emulation</td><td><code>https://jp-ws.hypertracker.io/emulation</code></td></tr></tbody></table>

The SDK uses the emulation endpoint for SSE. Do not call it directly.

### Available streams

| Data           | Channel             | Filter field | Replay        | Details                                                                                               |
| -------------- | ------------------- | ------------ | ------------- | ----------------------------------------------------------------------------------------------------- |
| Trade fills    | `rooms:fills`       | `tf`         | Yes           | [Fills](https://docs.coinmarketman.com/websocket-streams/stream-reference/fills.md)                   |
| Account events | `rooms:misc_events` | `tf`         | Yes           | [Account Events](https://docs.coinmarketman.com/websocket-streams/stream-reference/account-events.md) |
| TWAPs          | `rooms:twaps`       | `tf`         | Yes           | [TWAPs](https://docs.coinmarketman.com/websocket-streams/stream-reference/twaps.md)                   |
| Orders         | `orders:feed`       | `data`       | No, live only | [Orders](https://docs.coinmarketman.com/websocket-streams/stream-reference/orders.md)                 |

{% hint style="danger" %}
`orders:feed` requires an `address` filter. Without one, the subscription is rejected with `1084`.
{% endhint %}

### Choose a connection method

The SDK is the recommended option. It manages reconnects, pings, and short-window replay.

* Use [Connecting with the SDK](https://docs.coinmarketman.com/websocket-streams/connecting-with-the-sdk.md) for JavaScript, TypeScript, or supported Python workflows.
* Use [Connecting with a Plain WebSocket](https://docs.coinmarketman.com/websocket-streams/connecting-with-a-plain-websocket.md) for any language or full protocol control.

### Quick start

**JavaScript — plain WebSocket, Node 22 or later**

```js
const API_KEY = process.env.API_KEY;
const ws = new WebSocket('wss://jp-ws.hypertracker.io/connection/websocket', {
  headers: { Authorization: `Bearer ${API_KEY}` },
});
ws.onopen = () => ws.send(JSON.stringify({ id: 1, connect: {} }));
ws.onmessage = ({ data }) => {
  for (const line of String(data).split('\n')) {
    if (!line) continue;
    const msg = JSON.parse(line);
    if (Object.keys(msg).length === 0) { ws.send('{}'); continue; }
    if (msg.id === 1) {
      ws.send(JSON.stringify({ id: 2, subscribe: { channel: 'rooms:fills' } }));
    } else if (msg.push?.pub) console.log(msg.push.pub.data);
  }
};
```

**Python — `websockets`**

```python
import asyncio, json, os, websockets

async def main():
    async with websockets.connect(
        "wss://jp-ws.hypertracker.io/connection/websocket",
        additional_headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    ) as ws:
        await ws.send(json.dumps({"id": 1, "connect": {}}))
        async for frame in ws:
            for line in frame.split("\n"):
                if not line: continue
                msg = json.loads(line)
                if msg == {}: await ws.send("{}")
                elif msg.get("id") == 1:
                    await ws.send(json.dumps({"id": 2, "subscribe": {"channel": "rooms:fills"}}))
                elif msg.get("push", {}).get("pub"):
                    print(msg["push"]["pub"]["data"])
asyncio.run(main())
```

### Next steps

* [Key Concepts](https://docs.coinmarketman.com/websocket-streams/key-concepts.md)
* [Authentication](https://docs.coinmarketman.com/websocket-streams/authentication.md)
* [Filtering](https://docs.coinmarketman.com/websocket-streams/filtering.md)
* [Replaying Missed Data](https://docs.coinmarketman.com/websocket-streams/replaying-missed-data.md)
* [Stream Reference](https://docs.coinmarketman.com/websocket-streams/stream-reference.md)
* [Troubleshooting](https://docs.coinmarketman.com/websocket-streams/troubleshooting.md)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.coinmarketman.com/websocket-streams.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
