accountSubscribe
Subscribe to an account to receive notifications when the lamports or data for a given account public key changes.
The optional dataSlice configuration limits the account data returned in each notification to a byte range. It does not change which account is monitored.
Connection URL
wss://sol.nownodes.io/wss/{api_key}Open the WebSocket connection, then send the JSON-RPC request below as a text frame.
Subscription request example
{
"jsonrpc": "2.0",
"id": 1,
"method": "accountSubscribe",
"params": [
"SysvarRent111111111111111111111111111111111",
{
"encoding": "base64",
"commitment": "confirmed",
"dataSlice": {
"offset": 0,
"length": 8
}
}
]
}dataSlice.offset is the starting byte offset (zero-based), and dataSlice.length is the maximum number of bytes to return. In this example, each notification contains the first 8 bytes of account data.
Use a binary account-data encoding such as base58 or base64 with dataSlice. The space field, when present, describes the full account data size; it is not the length of the returned slice.
Subscription acknowledgement
After accepting the subscription, the server sends a JSON-RPC response containing the subscription ID:
{
"jsonrpc": "2.0",
"result": 23784,
"id": 1
}Notification format
Account updates are sent in a separate accountNotification message. The notification result has the same account information structure as getAccountInfo; data contains only the requested slice when dataSlice is specified.
Base64 notification example (dataSlice: offset 0, length 8)
{
"jsonrpc": "2.0",
"method": "accountNotification",
"params": {
"result": {
"context": {
"slot": 5199307
},
"value": {
"data": [
"AAAAAAAAAAA=",
"base64"
],
"executable": false,
"lamports": 33594,
"owner": "11111111111111111111111111111111",
"rentEpoch": 635,
"space": 80
}
},
"subscription": 23784
}
}The example's data value represents 8 returned bytes. The space value remains the full account data size.
Body
jsonrpcstring2.0requiredJSON-RPC protocol version.
idinteger | stringrequiredClient request identifier.
methodstringaccountSubscriberequiredSolana WebSocket subscription method.
paramsArray<string | object>requiredPositional parameters: account public key, then optional account subscription configuration.
Parameters
api_keystringrequiredpathYour NOWNodes API key.
Response
WebSocket subscription acknowledgement message. This is not the account update notification; updates arrive later as accountNotification messages.