# WebSocket Account & Program Subscriptions

> Subscribe to real-time account and program-owned account changes via WebSocket.

Canonical: https://nolimitnodes.com/docs/api-reference/websocket/accounts

## accountSubscribe

**WebSocket** - JSON-RPC

Subscribe to an account to receive notifications when the lamports or data for a given account public key changes.

### Parameters

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

Account Pubkey, base-58 encoded.

### `params[1]`, object

Configuration object:
  - `encoding` (string) - `base58`, `base64`, `base64+zstd`, `jsonParsed`
  - `commitment` (string) - commitment level

### Request

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

### Response

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

The `result` value is the subscription ID used to unsubscribe.

### Notification Format

### `result.value`, object

### properties

Account balance in lamports.

    ### `data`, string|object

Account data in requested encoding.

    ### `owner`, string

Program that owns this account.

    ### `executable`, boolean

Whether the account contains a program.

    ### `rentEpoch`, integer

Epoch at which rent is next due.

***

## accountUnsubscribe

**WebSocket** - JSON-RPC

Cancel account change notifications.

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

Subscription ID returned by `accountSubscribe`.

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

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

***

## programSubscribe

**WebSocket** - JSON-RPC

Subscribe to a program to receive notifications when the lamports or data for an account owned by the given program changes.

### Parameters

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

Program ID, base-58 encoded.

### `params[1]`, object

Configuration object:
  - `encoding` (string) - `base58`, `base64`, `base64+zstd`, `jsonParsed`
  - `commitment` (string) - commitment level
  - `filters` (array) - filter results using `memcmp` or `dataSize`

### Request

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

### Response

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

### Notification Format

### `result.value`, object

### properties

Account public key.

    ### `account`, object

        Account balance.

        ### `data`, string|object

Account data in requested encoding.

        ### `owner`, string

Program that owns this account.

        ### `executable`, boolean

Whether account contains a program.

        ### `rentEpoch`, integer

Next rent-due epoch.

    
  

***

## programUnsubscribe

**WebSocket** - JSON-RPC

Cancel program-owned account notifications.

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

Subscription ID returned by `programSubscribe`.

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

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