Skip to main content
WSS
/
Subscribe to real-time user account summary updates. Account-specific channel.

Example Request

{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "subscribe",
  "params": {
    "channel": "account_summary",
    "user": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
  }
}

Example Response

{
  "jsonrpc": "2.0",
  "method": "event",
  "params": {
    "channel": "account_summary@0x42C183edba036906447372a7c81Eb89D0B9f2175",
    "data": {
      "address": "0x42C183edba036906447372a7c81Eb89D0B9f2175",
      "margin_mode": "cross",
      "multi_asset_mode": false,
      "hedge_mode": false,
      "spot_collateral": {
        "USDC": {
          "balance": 2250.2685305,
          "withdrawable_balance": 2250.2685305
        },
        "USDT": {
          "balance": 2881.2922,
          "withdrawable_balance": 2881.2922
        }
      },
      "collateral": {
        "USDC": {
          "balance": 1577.138734,
          "withdrawable_balance": 1542.074016
        }
      },
      "vault_balances": {
        "0xdE66c594AF8e4AD2C62DcFadCb6714F8b176A4ef": {
          "withdrawable_shares": 0.000002,
          "total_shares": 0.000002,
          "amount": 1.3209
        }
      },
      "staked_collateral": 0,
      "perp_positions": {
        "TSLA-PERP": {
          "position_type": "oneWay",
          "legs": [
            {
              "instrument_id": 10,
              "instrument_name": "TSLA-PERP",
              "side": "BOTH",
              "size": 0.833,
              "entry_price": 420,
              "leverage": {
                "type": "isolated",
                "value": 10
              },
              "position_value": 349.86
            }
          ],
          "liquidation_price": 399,
          "mm": 17.571718,
          "im": 35.064718,
          "upnl": 2.74057
        }
      },
      "initial_margin_utilization": 0,
      "maintenance_margin_utilization": 0,
      "upnl": 2.74057,
      "total_account_equity": 6706.98644984,
      "margin_balance": 1542.074016,
      "initial_margin": 0,
      "maintenance_margin": 0,
      "total_volume": 21961028,
      "total_pnl": 50252.231826,
      "available_balance": 1542.074016,
      "withdrawable_balance_notional": 1542.074016,
      "transfer_margin_req": 0,
      "max_drawdown": 0.417427,
      "spot_account_equity": 5129.84771584,
      "derivative_account_equity": 1577.138734,
      "spot_volume": 3502,
      "perp_volume": 39187
    }
  }
}

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": "account_summary",
            "user": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
        }
    }
    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: "account_summary",
      user: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    },
  };
  ws.send(JSON.stringify(subscribeMsg));
};

ws.onmessage = function (event) {
  console.log("Received:", event.data);
};
Messages
Subscription request
type:object

Send subscribe/unsubscribe request

Channel event
type:object

Server-pushed JSON-RPC event