> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hotstuff.trade/llms.txt
> Use this file to discover all available pages before exploring further.

# explorer

Subscribe to real-time blockchain explorer data including block information, transactions, and network activity.

## 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:

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "subscribe",
  "params": {
    "channel": "blocks"
  }
}
```

Subscribe to transactions:

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "2",
  "method": "subscribe",
  "params": {
    "channel": "transactions"
  }
}
```

## Example Response

### Blocks Response

```json theme={null}
{
  "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

```json theme={null}
{
  "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

```python theme={null}
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

```javascript theme={null}
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);
};
```


## AsyncAPI

````yaml asyncapi/ws-subscriptions.json explorer
id: explorer
title: Explorer
description: ''
servers:
  - id: production
    protocol: wss
    host: api.hotstuff.trade/ws
    bindings: []
    variables: []
address: /
parameters: []
bindings: []
operations:
  - &ref_5
    id: explorer_sendSubscribe
    title: Explorer_send subscribe
    type: receive
    messages:
      - &ref_7
        id: a_subscribeRequest
        contentType: application/json
        payload:
          - name: Subscription request
            description: Send subscribe/unsubscribe request
            type: object
            properties:
              - name: jsonrpc
                type: string
                description: JSON-RPC version
                examples: &ref_0
                  - '2.0'
                required: true
              - name: id
                type: integer
                description: Client request identifier
                examples: &ref_1
                  - 1
                required: true
              - name: method
                type: string
                description: Subscription action
                enumValues:
                  - subscribe
                  - unsubscribe
                examples: &ref_2
                  - subscribe
                required: true
              - name: params
                type: object
                description: Channel subscription parameters
                required: true
                properties:
                  - name: channel
                    type: string
                    enumValues:
                      - blocks
                      - transactions
                    examples: &ref_3
                      - blocks
                      - transactions
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            jsonrpc:
              type: string
              default: '2.0'
              examples: *ref_0
              description: JSON-RPC version
              x-parser-schema-id: <anonymous-schema-110>
            id:
              type: integer
              default: 1
              examples: *ref_1
              description: Client request identifier
              x-parser-schema-id: <anonymous-schema-111>
            method:
              type: string
              enum:
                - subscribe
                - unsubscribe
              default: subscribe
              examples: *ref_2
              description: Subscription action
              x-parser-schema-id: <anonymous-schema-112>
            params:
              type: object
              properties:
                channel:
                  type: string
                  enum:
                    - blocks
                    - transactions
                  default: blocks
                  examples: *ref_3
                  x-parser-schema-id: <anonymous-schema-114>
              required:
                - channel
              description: Channel subscription parameters
              x-parser-schema-id: <anonymous-schema-113>
          required:
            - jsonrpc
            - id
            - method
            - params
          x-parser-schema-id: <anonymous-schema-109>
        title: Subscription request
        description: Send subscribe/unsubscribe request
        example: |-
          {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "subscribe",
            "params": {
              "channel": "blocks"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: a_subscribeRequest
    bindings: []
    extensions: &ref_4
      - id: x-parser-unique-object-id
        value: explorer
  - &ref_6
    id: explorer_receiveEvent
    title: Explorer_receive event
    type: send
    messages:
      - &ref_8
        id: event
        contentType: application/json
        payload:
          - name: Channel event
            description: Server-pushed JSON-RPC event
            type: object
            properties:
              - name: jsonrpc
                type: string
                required: false
              - name: method
                type: string
                required: false
              - name: params
                type: object
                required: false
                properties:
                  - name: channel
                    type: string
                    required: false
                  - name: data
                    type: object
                    required: false
                    properties:
                      - name: block_height
                        type: integer
                        required: false
                      - name: block_hash
                        type: string
                        required: false
                      - name: parent_hash
                        type: string
                        required: false
                      - name: change_log_hash
                        type: string
                        required: false
                      - name: timestamp
                        type: integer
                        required: false
                      - name: tx_count
                        type: integer
                        required: false
                      - name: created_at
                        type: integer
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            jsonrpc:
              type: string
              x-parser-schema-id: <anonymous-schema-116>
            method:
              type: string
              x-parser-schema-id: <anonymous-schema-117>
            params:
              type: object
              properties:
                channel:
                  type: string
                  x-parser-schema-id: <anonymous-schema-119>
                data:
                  type: object
                  properties:
                    block_height:
                      type: integer
                      x-parser-schema-id: <anonymous-schema-121>
                    block_hash:
                      type: string
                      x-parser-schema-id: <anonymous-schema-122>
                    parent_hash:
                      type: string
                      x-parser-schema-id: <anonymous-schema-123>
                    change_log_hash:
                      type: string
                      x-parser-schema-id: <anonymous-schema-124>
                    timestamp:
                      type: integer
                      x-parser-schema-id: <anonymous-schema-125>
                    tx_count:
                      type: integer
                      x-parser-schema-id: <anonymous-schema-126>
                    created_at:
                      type: integer
                      x-parser-schema-id: <anonymous-schema-127>
                  x-parser-schema-id: <anonymous-schema-120>
              x-parser-schema-id: <anonymous-schema-118>
          x-parser-schema-id: <anonymous-schema-115>
        title: Channel event
        description: Server-pushed JSON-RPC event
        example: |-
          {
            "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
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: event
    bindings: []
    extensions: *ref_4
sendOperations:
  - *ref_5
receiveOperations:
  - *ref_6
sendMessages:
  - *ref_7
receiveMessages:
  - *ref_8
extensions:
  - id: x-parser-unique-object-id
    value: explorer
securitySchemes: []

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.