WebSocket

WebSocket Account & Program Subscriptions

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

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]stringrequired

Account Pubkey, base-58 encoded.

params[1]object

Configuration object:

  • encoding (string) - base58, base64, base64+zstd, jsonParsed
  • commitment (string) - commitment level

Request

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"}]}

Response

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

The result value is the subscription ID used to unsubscribe.

Notification Format

result.valueobject

lamportsinteger
Account balance in lamports.
datastring|object
Account data in requested encoding.
ownerstring
Program that owns this account.
executableboolean
Whether the account contains a program.
rentEpochinteger
Epoch at which rent is next due.

accountUnsubscribe

WebSocket - JSON-RPC

Cancel account change notifications.

params[0]integerrequired

Subscription ID returned by accountSubscribe.

wscat -c wss://ws.nln.clr3.org -H "x-api-key: YOUR_API_KEY"> {"jsonrpc":"2.0","id":1,"method":"accountUnsubscribe","params":[23784]}
Responsejson
{  "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]stringrequired

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

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"}]}

Response

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

Notification Format

result.valueobject

pubkeystring
Account public key.
accountobject

lamportsinteger
Account balance.
datastring|object
Account data in requested encoding.
ownerstring
Program that owns this account.
executableboolean
Whether account contains a program.
rentEpochinteger
Next rent-due epoch.

programUnsubscribe

WebSocket - JSON-RPC

Cancel program-owned account notifications.

params[0]integerrequired

Subscription ID returned by programSubscribe.

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