Skip to main content
WSS
wss://api.hotstuff.trade/ws
/
Subscribe to real-time mid prices (average of best bid and ask) for trading instruments.

Supported Symbols

  • Individual markets: BTC-PERP, ETH-PERP, etc.
  • All markets: "all"

Example Request

{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "subscribe",
  "params": {
    "channel": "mids",
    "symbol": "BTC-PERP" // support "all" or "BTC-PERP"
  }
}

Example Response

{
  "jsonrpc": "2.0",
  "method": "event",
  "params": {
    "channel": "mids:BTC-PERP",
    "data": {
      "symbol": "BTC-PERP",
      "mid_price": 67887
    }
  }
}

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": "mids",
            "symbol": "BTC-PERP"  # or "all"
        }
    }
    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: "mids",
      symbol: "BTC-PERP", // or "all"
    },
  };
  ws.send(JSON.stringify(subscribeMsg));
};

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

Send subscribe/unsubscribe request

Mids channel event
type:object

Server-pushed JSON-RPC event