programSubscribe
POST
Subscribe to a program to receive notifications when the lamports or data for an account owned by the given program changes
Connection URL:
Copied!
wss://sol.nownodes.io/wss/{{api_key}}Open the connection, then send the message below as a text frame.
Example:
Copied!
wscat -c 'wss://sol.nownodes.io/wss/YOUR_API_KEY'
> { "jsonrpc": "2.0", "id": 1, "method": "programSubscribe", "params": [ "11111111111111111111111111111111", { "encoding": "base64", "commitment": "finalized" } ] } { "jsonrpc": "2.0", "id": 1, "method": "programSubscribe", "params": [ "11111111111111111111111111111111", { "encoding": "jsonParsed" } ] } { "jsonrpc": "2.0", "id": 1, "method": "programSubscribe", "params": [ "11111111111111111111111111111111", { "encoding": "base64", "filters": [ { "dataSize": 80 } ] } ] }Notification format
The notification format is a single program account object as seen in the getProgramAccounts RPC HTTP method.
Base58 encoding:
Copied!
{
"jsonrpc": "2.0",
"method": "programNotification",
"params": {
"result": {
"context": {
"slot": 5208469
},
"value": {
"pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq",
"account": {
"data": [
"11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR",
"base58"
],
"executable": false,
"lamports": 33594,
"owner": "11111111111111111111111111111111",
"rentEpoch": 636,
"space": 80
}
}
},
"subscription": 24040
}
}Parsed-JSON encoding:
Copied!
{
"jsonrpc": "2.0",
"method": "programNotification",
"params": {
"result": {
"context": {
"slot": 5208469
},
"value": {
"pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq",
"account": {
"data": {
"program": "nonce",
"parsed": {
"type": "initialized",
"info": {
"authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX",
"blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k",
"feeCalculator": {
"lamportsPerSignature": 5000
}
}
}
},
"executable": false,
"lamports": 33594,
"owner": "11111111111111111111111111111111",
"rentEpoch": 636,
"space": 80
}
}
},
"subscription": 24040
}
}Body
application/json
object
Parameters
api_keystringrequiredpathYour NOWNodes API key.
Response
200OK
A successful response.