Skip to main content
Subscribe to real-time blockchain explorer data including block information, transactions, and network activity. WebSocket URL: wss://api.hotstuff.trade/ws Channel: blocks or transactions

Parameters

ParameterTypeRequiredDescriptionExample
jsonrpcstringYesJSON-RPC version"2.0"
idstringYesRequest identifier for tracking"1"
methodstringYesAction to perform"subscribe" or "unsubscribe"
channelstringYesChannel name"blocks" or "transactions"

Supported Methods

  • subscribe - Subscribe to blockchain explorer updates
  • unsubscribe - Unsubscribe from blockchain explorer updates

Channel Types

Subscribe to either "blocks" or "transactions" channel:
  • blocks - Block information including block height, hashes, transaction count, and timestamps
  • transactions - Transaction details including transaction hash, account, block information, transaction type, success status, and timestamps

Example Request

Subscribe to blocks:
{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "subscribe",
  "params": {
    "channel": "blocks"
  }
}
Subscribe to transactions:
{
  "jsonrpc": "2.0",
  "id": "2",
  "method": "subscribe",
  "params": {
    "channel": "transactions"
  }
}

Example Response

Blocks Response

{
    "jsonrpc": "2.0",
    "method": "event",
    "params": {
        "channel": "blocks",
        "data": {
            "block_height": 49639461,
            "block_hash": "0xf2908f4abba7dc26d394f559c63b12afa57904b9f71861eabbf30c63937e605a",
            "parent_hash": "0x95df533b6322f5546df823862cdd69569871b974415b80d5eebdd0023fceaee8",
            "change_log_hash": "0x12792f5ad322c03de737e3838720a0e5b8bfc7376cb332221f0389409378fab9",
            "timestamp": 1770860677971,
            "tx_count": 4,
            "created_at": 1770860678
        }
    }
}

Transactions Response

{
    "jsonrpc": "2.0",
    "method": "event",
    "params": {
        "channel": "transactions",
        "data": {
            "tx_hash": "0x37c59f8a124919fe7fd2ad96d574bb800a3653fdde0b7ca180443c4ba208b1cf",
            "account": "0x2daABa67B7c0eA90668f5eE2FB21CaA30D6bD62A",
            "block_height": 49641126,
            "block_hash": "0x9c380e17843da4a03e14c0ac39748f02a63f0d4753f03ec74943263eacd8354e",
            "tx_type": 1302,
            "success": true,
            "timestamp": 1770860765391,
            "created_at": 1770860765
        }
    }
}

WebSocket Client Examples

Python

import websocket
import json

def on_message(ws, message):
    print(f"Received: {message}")

def on_open(ws):
    # Subscribe to blocks
    subscribe_blocks = {
        "jsonrpc": "2.0",
        "id": "1",
        "method": "subscribe",
        "params": {
            "channel": "blocks"
        }
    }
    ws.send(json.dumps(subscribe_blocks))
    
    # Subscribe to transactions
    subscribe_txs = {
        "jsonrpc": "2.0",
        "id": "2",
        "method": "subscribe",
        "params": {
            "channel": "transactions"
        }
    }
    ws.send(json.dumps(subscribe_txs))

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() {
    // Subscribe to blocks
    const subscribeBlocks = {
        "jsonrpc": "2.0",
        "id": "1",
        "method": "subscribe",
        "params": {
            "channel": "blocks"
        }
    };
    ws.send(JSON.stringify(subscribeBlocks));
    
    // Subscribe to transactions
    const subscribeTxs = {
        "jsonrpc": "2.0",
        "id": "2",
        "method": "subscribe",
        "params": {
            "channel": "transactions"
        }
    };
    ws.send(JSON.stringify(subscribeTxs));
};

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