Skip to main content
Subscribe to real-time ticker data including price, volume, and 24h change for trading instruments. WebSocket URL: wss://api.hotstuff.trade/ws Channel: ticker

Parameters

ParameterTypeRequiredDescriptionExample
jsonrpcstringYesJSON-RPC version"2.0"
idstringYesRequest identifier for tracking"1"
methodstringYesAction to perform"subscribe" or "unsubscribe"
channelstringYesChannel name"ticker"
symbolstringYesTrading symbol or “all”"BTC-PERP", "ETH-PERP", "all"

Supported Methods

  • subscribe - Subscribe to ticker updates
  • unsubscribe - Unsubscribe from ticker updates

Supported Symbols

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

Example Request

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

Example Response

{
    "jsonrpc": "2.0",
    "method": "event",
    "params": {
        "channel": "ticker:BTC-PERP",
        "data": {
            "instrument_name": "BTC-PERP",
            "instrument_id": 1,
            "symbol": "BTC-PERP",
            "mark_price": 68295,
            "mid_price": 120000,
            "index_price": 67631.049159,
            "best_bid_price": 119999,
            "best_ask_price": 120001,
            "best_bid_size": 0.001,
            "best_ask_size": 0.002,
            "funding_rate": 0.000012,
            "volume_24h": 6319.722,
            "change_24h": 341,
            "open_interest": 0.093,
            "max_trading_price": 70344.489513,
            "min_trading_price": 66246.75226,
            "premium": 0,
            "last_price": 119999
        }
    }
}

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

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