accountSubscribe

WSSSubscriptionsOperator+

Emits a notification each time a single account's lamports or data change.

WSSwss://ws-newyork.constant-k.com:1337/ws?api-key=YOUR_API_KEY

accountSubscribe opens a live feed for one account as an alternative to polling getAccountInfo. Each time the account's data or lamport balance changes at or above the requested commitment, constant-k's node emits one accountNotification carrying the account's new state and the slot the change landed in.

encoding controls how the data field is serialized in each notification, dataSlice shrinks the payload to a byte window for part of a large account, and commitment trades notification latency against the chance of the change being rolled back. The stream stays open until accountUnsubscribe is called or the socket closes.

PlansOperator and above
FreeNot included
OperatorIncluded
Blade RunnerIncluded
NexusIncluded

Parameters

params is a JSON array, with values in this order: pubkey, config.

1pubkeystringrequired

Base58-encoded public key of the account to watch.

Example:SysvarC1ock11111111111111111111111111111111
2configobject

Optional subscription settings.

Show propertiesProperties
encodingstringdefault: "base58"

Format for the returned account data. base58 is the legacy default (also accepted under its old name binary) and is slow for large accounts; jsonParsed asks the node to run a program-specific parser and silently falls back to base64 when no parser exists for the account's owner.

Allowed values:base58base64base64+zstdjsonParsed
commitmentstringdefault: "finalized"

How settled the account/transaction state must be before the node acts on it. processed is fastest and can roll back; finalized is slowest and never rolls back.

Allowed values:processedconfirmedfinalized
dataSliceobject | null

Returns only a byte range of data instead of the whole payload. Not compatible with jsonParsed encoding.

Show propertiesProperties
offsetintegerrequired

Byte offset to start the slice at.

Minimum: 0
lengthintegerrequired

Number of bytes to return.

Minimum: 0
minContextSlotinteger

Minimum slot the node must have reached before it will process the subscription. Accepted for parity with the HTTP RpcAccountInfoConfig struct; Agave's pubsub handler does not currently gate notifications on it.

Minimum: 0

Result

resultinteger

The subscription id, returned once in the initial RPC response. Passed to accountUnsubscribe, it cancels the stream.

Notifications

Updates arrive as accountNotification messages on the same socket. result.context.slot is the slot the change was observed in; result.value is the account's new state, shaped like the value of getAccountInfo (lamports, data, owner, executable, rentEpoch, space), with data encoded per the requested encoding.

params.resultobject

Notification payload.

Show propertiesProperties
contextobject

Response context, including the slot the data was read at.

Show propertiesProperties
slotinteger

Slot number this applies to.

valueobject

The requested data; see the fields below.

Show propertiesProperties
lamportsinteger

Account balance, in lamports.

dataany

Account data, shaped by the requested encoding (an object for jsonParsed, a [string, encoding] tuple otherwise).

ownerstring

Base58 address of the program (or, for a token account, the wallet) that owns this account.

executableboolean

Whether this account is a program.

rentEpochinteger

Legacy rent-exemption epoch; not meaningful for accounts created after rent-exempt minimums became mandatory.

spaceinteger

Size of the account's data, in bytes.

Unsubscribe

accountUnsubscribe, called with the subscription id, stops the notifications and returns true once the subscription is removed.

accountUnsubscribe request
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "accountUnsubscribe",
  "params": [26917684]
}

Notes

  • WebSocket access is included on the Operator plan and above; it is not available on Free.
  • Concurrent connections are capped per API key: 10 on Operator, 50 on Blade Runner, 100 on Nexus.
  • Subscribe and unsubscribe calls draw from the same global per-plan request-rate limit as HTTP calls: 50 req/s on Operator, 200 req/s on Blade Runner, 500 req/s on Nexus.
  • Only subscription methods (the *Subscribe / *Unsubscribe family) are accepted on the WebSocket endpoint; standard request/response RPC methods must go over HTTPS instead.
  • A getHealth request sent over the open socket on a regular interval serves as a keepalive; connections that go quiet can be dropped by intermediate load balancers.
  • Each region has its own WebSocket hostname, for example wss://ws-newyork.constant-k.com:1337/ws?api-key=YOUR_API_KEY; every region is listed on the Endpoints page.
  • Captured live from wss://api.mainnet-beta.solana.com against the Clock sysvar, which updates every slot, useful for confirming a subscription is alive.