Skip to main content
Subscribe to real-time user order status updates. WebSocket URL: wss://api.hotstuff.trade/ws Channel: orders

Parameters

ParameterTypeRequiredDescriptionExample
jsonrpcstringYesJSON-RPC version"2.0"
idstringYesRequest identifier for tracking"1"
methodstringYesAction to perform"subscribe" or "unsubscribe"
channelstringYesChannel name"orders"
userstringYesUser wallet address"0xxxx"

Supported Methods

  • subscribe - Subscribe to user order updates
  • unsubscribe - Unsubscribe from user order updates

Authentication

This endpoint requires a valid user wallet address to receive account-specific order updates.

Example Request

{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "subscribe",
  "params": {
    "channel": "orders",
    "user": "0xxxx"
  }
}

Example Response

{
    "jsonrpc": "2.0",
    "method": "event",
    "params": {
        "channel": "orders@0x42C183edba036906447372a7c81Eb89D0B9f2175",
        "data": {
            "instrument_id": 1,
            "instrument": "BTC-PERP",
            "account": "0x42C183edba036906447372a7c81Eb89D0B9f2175",
            "tif": "GTC",
            "order_id": 172561523,
            "cloid": "69901641-e0ad-47eb-80bf-f285321f5bd0",
            "side": "b",
            "position_side": "BOTH",
            "limit_price": "67977",
            "size": "0.06107",
            "old_price": "67977",
            "old_size": "0.06107",
            "unfilled": "0.05737",
            "state": "open",
            "reduce_only": false,
            "post_only": false,
            "timestamp": 1770854411081
        }
    }
}

WebSocket Client Examples

Python

import websocket
import json

def on_message(ws, message):
    print(f"Received: {message}")

def on_open(ws):
    subscribe_msg = {
        "jsonrpc": "2.0",
        "id": "1",
        "method": "subscribe",
        "params": {
            "channel": "orders",
            "user": "0xxxx"
        }
    }
    ws.send(json.dumps(subscribe_msg))

ws = websocket.WebSocketApp("wss://api.hotstuff.trade/ws",
                          on_message=on_message,
                          on_open=on_open)
ws.run_forever()

JavaScript

const ws = new WebSocket('wss://api.hotstuff.trade/ws');

ws.onopen = function() {
    const subscribeMsg = {
        "jsonrpc": "2.0",
        "id": "1",
        "method": "subscribe",
        "params": {
            "channel": "orders",
            "user": "0xxxx"
        }
    };
    ws.send(JSON.stringify(subscribeMsg));
};

ws.onmessage = function(event) {
    console.log('Received:', event.data);
};