program Subscribe
Streams an update for every account owned by a program, one notification per changed account.
wss://ws-newyork.constant-k.com:1337/ws?api-key=YOUR_API_KEYprogramSubscribe replaces opening one accountSubscribe per account when a whole program's account set is being watched: each notification names the pubkey that changed alongside its new state, equivalent to a single row of getProgramAccounts pushed as it happens.
filters (dataSize and/or memcmp) apply server-side, limiting notifications from a busy program to relevant accounts; encoding, dataSlice and commitment behave exactly as they do for accountSubscribe. Pubsub notifications always carry context, so withContext has no effect here; it exists only for shape-compatibility with the HTTP getProgramAccounts config.
Parameters
params is a JSON array, with values in this order: programId, config.
Base58-encoded public key of the program whose owned accounts to watch.
Optional subscription settings.
Show propertiesProperties
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.
base58base64base64+zstdjsonParsedHow 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.
processedconfirmedfinalizedUp to 4 server-side filters; an account must match all of them to be included.
Show one ofOne of
Account data must be exactly this many bytes.
Show propertiesProperties
Required exact size of the account's data, in bytes.
0Account data at offset must match bytes.
Show propertiesProperties
Compare bytes at a fixed offset within the account's data.
Show propertiesProperties
Byte offset.
0Encoded bytes to compare against.
Encoding used for bytes (base58 by default).
base58base64Returns only a byte range of data instead of the whole payload. Not compatible with jsonParsed encoding.
Show propertiesProperties
Byte offset to start the slice at.
0Number of bytes to return.
0Pubsub notifications always carry context, so withContext has no effect here; it is accepted only for shape-compatibility with the HTTP getProgramAccounts config.
Result
The subscription id, returned once in the initial RPC response. Passed to programUnsubscribe, it cancels the stream.
Notifications
Updates arrive as programNotification messages on the same socket. result.value.pubkey is the account that changed; result.value.account is its new state, shaped like a single entry of getProgramAccounts (lamports, data, owner, executable, rentEpoch, space).
Notification payload.
Show propertiesProperties
Response context, including the slot the data was read at.
Show propertiesProperties
Slot number this applies to.
The requested data; see the fields below.
Show propertiesProperties
Base58 public key of the account.
The account's on-chain state.
Show propertiesProperties
Account balance, in lamports.
Account data, shaped by the requested encoding.
Base58 address of the program (or, for a token account, the wallet) that owns this account.
Whether this account is a program.
Legacy rent-exemption epoch; not meaningful for accounts created after rent-exempt minimums became mandatory.
Size of the account's data, in bytes.
Unsubscribe
programUnsubscribe, called with the subscription id, stops the notifications and returns true once the subscription is removed.
{
"jsonrpc": "2.0",
"id": 2,
"method": "programUnsubscribe",
"params": [26917954]
}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/*Unsubscribefamily) are accepted on the WebSocket endpoint; standard request/response RPC methods must go over HTTPS instead. - A
getHealthrequest 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. - The example follows the shape of a bonding-curve account update from the pump.fun program, which changes often enough to produce a notification within seconds of subscribing. Addresses in it are synthetic.
- A program with a very large or very active account set (the SPL Token program, for example) can produce far more notifications than a single connection can usefully process;
filtersnarrow the set for a program that busy.