# WebSocket Slot, Block & Root Subscriptions

> Subscribe to real-time slot, block, and root updates via WebSocket.

Canonical: https://nolimitnodes.com/docs/api-reference/websocket/slots-and-blocks

## blockSubscribe

**WebSocket** - JSON-RPC

Subscribe to receive notifications anytime a new block is confirmed or finalized.

> Warning: This is an unstable method that requires the validator to run with `--rpc-pubsub-enable-block-subscription`.

### Parameters

### `params[0]`, string | object, required

Filter - either `"all"` for all transactions, or an object:
  - `mentionsAccountOrProgram` (string) - only return transactions mentioning this public key

### `params[1]`, object

Configuration object:
  - `commitment` (string) - `finalized` or `confirmed`
  - `encoding` (string) - `json`, `jsonParsed`, `base58`, `base64`
  - `transactionDetails` (string) - `full`, `accounts`, `signatures`, `none`
  - `maxSupportedTransactionVersion` (integer)
  - `showRewards` (boolean)

### Request

```bash wscat
wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"
> {"jsonrpc":"2.0","id":1,"method":"blockSubscribe","params":["all"]}
```
```json Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "blockSubscribe",
  "params": ["all"]
}
```

#### With Filter

```bash wscat
wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"
> {"jsonrpc":"2.0","id":1,"method":"blockSubscribe","params":[{"mentionsAccountOrProgram":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"commitment":"confirmed","encoding":"base64","transactionDetails":"full","showRewards":true,"maxSupportedTransactionVersion":0}]}
```
```json Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "blockSubscribe",
  "params": [
    {
      "mentionsAccountOrProgram": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
    },
    {
      "commitment": "confirmed",
      "encoding": "base64",
      "transactionDetails": "full",
      "showRewards": true,
      "maxSupportedTransactionVersion": 0
    }
  ]
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": 0,
  "id": 1
}
```

***

## blockUnsubscribe

**WebSocket** - JSON-RPC

Cancel block notifications.

### `params[0]`, integer, required

Subscription ID returned by `blockSubscribe`.

```bash wscat
wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"
> {"jsonrpc":"2.0","id":1,"method":"blockUnsubscribe","params":[0]}
```
```json Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "blockUnsubscribe",
  "params": [0]
}
```

```json Response
{
  "jsonrpc": "2.0",
  "result": true,
  "id": 1
}
```

***

## voteSubscribe

**WebSocket** JSON-RPC

Subscribe to vote notifications observed by the validator.

**Parameters:** None

### Request

```bash wscat
wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"
> {"jsonrpc":"2.0","id":"votes","method":"voteSubscribe"}
```

```json Request
{
  "jsonrpc": "2.0",
  "id": "votes",
  "method": "voteSubscribe"
}
```

The response returns a numeric subscription ID.

### Notification

```json
{
  "jsonrpc": "2.0",
  "method": "voteNotification",
  "params": {
    "result": {
      "hash": "7bZ...",
      "slots": [357954001],
      "timestamp": 1785206400
    },
    "subscription": 42
  }
}
```

***

## voteUnsubscribe

Pass the subscription ID from `voteSubscribe`.

```json
{
  "jsonrpc": "2.0",
  "id": "stop-votes",
  "method": "voteUnsubscribe",
  "params": [42]
}
```

***

## rootSubscribe

**WebSocket** - JSON-RPC

Subscribe to receive notifications anytime a new root is set by the validator.

**Parameters:** None

### Request

```bash wscat
wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"
> {"jsonrpc":"2.0","id":1,"method":"rootSubscribe"}
```
```json Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "rootSubscribe"
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": 0,
  "id": 1
}
```

### Notification Format

Notifications contain the latest root slot number as an integer.

***

## rootUnsubscribe

**WebSocket** - JSON-RPC

Cancel root notifications.

### `params[0]`, integer, required

Subscription ID returned by `rootSubscribe`.

```bash wscat
wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"
> {"jsonrpc":"2.0","id":1,"method":"rootUnsubscribe","params":[0]}
```
```json Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "rootUnsubscribe",
  "params": [0]
}
```

```json Response
{
  "jsonrpc": "2.0",
  "result": true,
  "id": 1
}
```

***

## slotSubscribe

**WebSocket** - JSON-RPC

Subscribe to receive notifications whenever a slot is processed by the validator.

**Parameters:** None

### Request

```bash wscat
wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"
> {"jsonrpc":"2.0","id":1,"method":"slotSubscribe"}
```
```json Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "slotSubscribe"
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": 0,
  "id": 1
}
```

### Notification Format

### `result`, object

### properties

The parent slot.

    ### `root`, integer

The current root slot.

    ### `slot`, integer

The newly set slot value.

***

## slotUnsubscribe

**WebSocket** - JSON-RPC

Cancel slot notifications.

### `params[0]`, integer, required

Subscription ID returned by `slotSubscribe`.

```bash wscat
wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"
> {"jsonrpc":"2.0","id":1,"method":"slotUnsubscribe","params":[0]}
```
```json Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "slotUnsubscribe",
  "params": [0]
}
```

```json Response
{
  "jsonrpc": "2.0",
  "result": true,
  "id": 1
}
```

***

## slotsUpdatesSubscribe

**WebSocket** - JSON-RPC

Subscribe to receive notifications from the validator on a variety of updates on every slot.

> Warning: This is an unstable method. The response format may change in future releases.

**Parameters:** None

### Request

```bash wscat
wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"
> {"jsonrpc":"2.0","id":1,"method":"slotsUpdatesSubscribe"}
```
```json Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "slotsUpdatesSubscribe"
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": 0,
  "id": 1
}
```

### Notification Format

### `result`, object

### properties

The updated slot.

    ### `timestamp`, integer

Unix timestamp of the update.

    ### `err`, string | null

Error message if applicable (null otherwise).

    ### `type`, string

Update type - one of:
      - `firstShredReceived` - first shred of a new slot received
      - `completed` - slot completed receiving all shreds
      - `createdBank` - bank created for slot
      - `frozen` - slot frozen
      - `dead` - slot is dead
      - `optimisticConfirmation` - optimistically confirmed
      - `root` - slot rooted

***

## slotsUpdatesUnsubscribe

**WebSocket** - JSON-RPC

Cancel slot-update notifications.

### `params[0]`, integer, required

Subscription ID returned by `slotsUpdatesSubscribe`.

```bash wscat
wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"
> {"jsonrpc":"2.0","id":1,"method":"slotsUpdatesUnsubscribe","params":[0]}
```
```json Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "slotsUpdatesUnsubscribe",
  "params": [0]
}
```

```json Response
{
  "jsonrpc": "2.0",
  "result": true,
  "id": 1
}
```
