---
title: "Comment by Siebly on \"Hyperliquid API guide: WebSocket feeds and order management\" | Hashnode"
description: "Thanks for putting this together, Lucas. A quick note for readers who try the snippets: Hyperliquid's API is served from api.hyperliquid.xyz (api.hyperliquid.co"
url: "https://hashnode.com/posts/hyperliquid-api-guide-websocket-feeds-and-order-management/69ddc8588a2aa55360411862/comment/6b1232cc7a7e0e1f353693cd"
---

[Discussion](https://hashnode.com/posts/hyperliquid-api-guide-websocket-feeds-and-order-management/69ddc8588a2aa55360411862)

Comment [Hyperliquid API guide: WebSocket feeds and order management](https://hashnode.com/posts/hyperliquid-api-guide-websocket-feeds-and-order-management/69ddc8588a2aa55360411862)

[Siebly](https://hashnode.com/@siebly)

[18h ago](https://hashnode.com/posts/hyperliquid-api-guide-websocket-feeds-and-order-management/69ddc8588a2aa55360411862/comment/6b1232cc7a7e0e1f353693cd)

Thanks for putting this together, Lucas. A quick note for readers who try the snippets: Hyperliquid's API is served from api.hyperliquid.xyz (api.hyperliquid.com has no DNS record), and subscriptions use a "method"/"subscription" message. This version of the WebSocket part streams live BTC trades (I ran it this morning):

```python
import json, threading, websocket

def on_message(ws, message):
    data = json.loads(message)
    if data.get("channel") == "trades":
        for t in data["data"]:
            print(t["coin"], t["side"], t["px"], t["sz"])

def on_open(ws):
    ws.send(json.dumps({
        "method": "subscribe",
        "subscription": {"type": "trades", "coin": "BTC"}
    }))

ws = websocket.WebSocketApp("wss://api.hyperliquid.xyz/ws",
                            on_open=on_open, on_message=on_message)
threading.Timer(10, ws.close).start()
ws.run_forever(ping_interval=50, ping_payload='{"method":"ping"}')
```

Orders work a little differently from exchanges with key and secret headers: Hyperliquid has no API key. You approve an API wallet on the API page of the app, and each order is signed by that wallet and posted to the /exchange endpoint on api.hyperliquid.xyz. The Signing page in the Hyperliquid docs covers the details.

For anyone building in Node.js, our open-source Hyperliquid SDK handles the signing, heartbeats and reconnects. The same trade stream there:

```js
import { WebsocketClient } from '@siebly/hyperliquid-api';

const ws = new WebsocketClient({ connectionTimeout: 5_000 });
ws.on('message', (e) => {
  if (e.channel === 'trades') {
    for (const t of e.data) console.log(t.coin, t.side, t.px, t.sz);
  }
});
await ws.subscribe({ type: 'trades', coin: 'BTC' });
```

More examples are in the Siebly Hyperliquid SDK docs on siebly.io.

Daisy, Siebly
