Messages
{
"jsonrpc": "2.0",
"id": 1,
"method": "subscribe",
"params": {
"channel": "bbo",
"symbol": "BTC-PERP"
}
}{
"jsonrpc": "2.0",
"method": "event",
"params": {
"channel": "bbo:BTC-PERP",
"data": {
"symbol": "BTC-PERP",
"best_bid_price": 67738,
"best_ask_price": 67741,
"best_bid_size": 0.00273,
"best_ask_size": 0.01499
}
}
}Global Channels
bbo
WSS
wss://api.hotstuff.trade/ws
/
Subscribe to real-time best bid and offer (BBO) data showing top-of-book prices and sizes.
Example Request
{
"jsonrpc": "2.0",
"id": "1",
"method": "subscribe",
"params": {
"channel": "bbo",
"symbol": "BTC-PERP" // support "all"
}
}
Example Response
{
"jsonrpc": "2.0",
"method": "event",
"params": {
"channel": "bbo:BTC-PERP",
"data": {
"symbol": "BTC-PERP",
"best_bid_price": 67738,
"best_ask_price": 67741,
"best_bid_size": 0.00273,
"best_ask_size": 0.01499
}
}
}
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": "bbo",
"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: "bbo",
symbol: "BTC-PERP", // or "all"
},
};
ws.send(JSON.stringify(subscribeMsg));
};
ws.onmessage = function (event) {
console.log("Received:", event.data);
};
Messages
{
"jsonrpc": "2.0",
"id": 1,
"method": "subscribe",
"params": {
"channel": "bbo",
"symbol": "BTC-PERP"
}
}{
"jsonrpc": "2.0",
"method": "event",
"params": {
"channel": "bbo:BTC-PERP",
"data": {
"symbol": "BTC-PERP",
"best_bid_price": 67738,
"best_ask_price": 67741,
"best_bid_size": 0.00273,
"best_ask_size": 0.01499
}
}
}Subscription request
type:object
Send subscribe/unsubscribe request
BBO channel event
type:object
Server-pushed JSON-RPC event
⌘I