Home

accountSubscribe

POST
wss://sol.nownodes.io/wss/{api_key}

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

Copied!
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

Copied!
{
  "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:

Copied!
{
  "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)

Copied!
{
  "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

application/json
jsonrpcstring2.0required

JSON-RPC protocol version.

idinteger | stringrequired

Client request identifier.

methodstringaccountSubscriberequired

Solana WebSocket subscription method.

paramsArray<string | object>required

Positional parameters: account public key, then optional account subscription configuration.

Show child attributes
One of

Account public key to subscribe to.

string
encodingstringbase58base64base64+zstdjsonParsed

Account data encoding. Use base58 or base64 for sliced binary account data.

commitmentstringprocessedconfirmedfinalized

Commitment level for the subscription.

dataSliceobject

Return only a selected byte range of account data in each notification.

Show child attributes
offsetinteger>= 0required

Zero-based byte offset from which account data is returned.

lengthinteger>= 0required

Maximum number of bytes to return.

Parameters

api_keystringrequiredpath

Your NOWNodes API key.

Response

200OK

WebSocket subscription acknowledgement message. This is not the account update notification; updates arrive later as accountNotification messages.