Messages
{
"jsonrpc": "2.0",
"id": 1,
"method": "subscribe",
"params": {
"channel": "positions",
"user": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
}
}{
"jsonrpc": "2.0",
"method": "event",
"params": {
"channel": "positions@0x42C183edba036906447372a7c81Eb89D0B9f2175",
"data": {
"account": "0x42C183edba036906447372a7c81Eb89D0B9f2175",
"instrument_id": 10,
"instrument": "TSLA-PERP",
"position_type": "oneWay",
"old_position": {
"size": 0.833,
"entry_price": 420
},
"position_side_updated": "BOTH",
"realized_pnl": 0,
"legs": [
{
"side": "BOTH",
"size": 0.833,
"entry_price": 420,
"leverage": {
"type": "isolated",
"value": 10,
"margin": "53.477383"
},
"position_value": 349.86
}
],
"block_timestamp": 1770853898179
}
}
}Accounts Channels
positions
WSS
wss://api.hotstuff.trade/ws
/
Subscribe to real-time user position updates. Account-specific channel.
Example Request
{
"jsonrpc": "2.0",
"id": "1",
"method": "subscribe",
"params": {
"channel": "positions",
"user": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
}
}
Example Response
{
"jsonrpc": "2.0",
"method": "event",
"params": {
"channel": "positions@0x42C183edba036906447372a7c81Eb89D0B9f2175",
"data": {
"account": "0x42C183edba036906447372a7c81Eb89D0B9f2175",
"instrument_id": 10,
"instrument": "TSLA-PERP",
"position_type": "oneWay",
"old_position": {
"size": 0.833,
"entry_price": 420
},
"position_side_updated": "BOTH",
"realized_pnl": 0,
"legs": [
{
"side": "BOTH",
"size": 0.833,
"entry_price": 420,
"leverage": {
"type": "isolated",
"value": 10,
"margin": "53.477383"
},
"position_value": 349.86
}
],
"block_timestamp": 1770853898179
}
}
}
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": "positions",
"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: "positions",
user: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
},
};
ws.send(JSON.stringify(subscribeMsg));
};
ws.onmessage = function (event) {
console.log("Received:", event.data);
};
Messages
{
"jsonrpc": "2.0",
"id": 1,
"method": "subscribe",
"params": {
"channel": "positions",
"user": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
}
}{
"jsonrpc": "2.0",
"method": "event",
"params": {
"channel": "positions@0x42C183edba036906447372a7c81Eb89D0B9f2175",
"data": {
"account": "0x42C183edba036906447372a7c81Eb89D0B9f2175",
"instrument_id": 10,
"instrument": "TSLA-PERP",
"position_type": "oneWay",
"old_position": {
"size": 0.833,
"entry_price": 420
},
"position_side_updated": "BOTH",
"realized_pnl": 0,
"legs": [
{
"side": "BOTH",
"size": 0.833,
"entry_price": 420,
"leverage": {
"type": "isolated",
"value": 10,
"margin": "53.477383"
},
"position_value": 349.86
}
],
"block_timestamp": 1770853898179
}
}
}Subscription request
type:object
Send subscribe/unsubscribe request
Channel event
type:object
Server-pushed JSON-RPC event
⌘I