accountUnsubscribe

accountUnsubscribe WebSocket Method

post

Unsubscribe from account change notifications. This method cancels an existing account subscription identified by the subscription ID that was returned from a previous accountSubscribe call. Once unsubscribed, you will no longer receive accountNotification messages for the specified subscription.

Authorizations
Body

Request object for unsubscribing from account change notifications

jsonrpcstring · enumRequired

JSON-RPC protocol version

Example: 2.0Possible values:
idone ofRequired

Request identifier that will be returned in the response

Example: 1
stringOptional
or
numberOptional
methodstring · enumRequired

The WebSocket method name

Example: accountUnsubscribePossible values:
paramsinteger[] · min: 1 · max: 1Required

Method parameters array containing the subscription ID to cancel

Example: [23784]
Responses
200

Unsubscription successful

application/json
post
const ws = new WebSocket('wss://public.rpc.solanavibestation.com');
let subscriptionId = 23784; // From previous accountSubscribe call

ws.onopen = function() {
  // Unsubscribe from account changes
  ws.send(JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'accountUnsubscribe',
    params: [subscriptionId]
  }));
};

ws.onmessage = function(event) {
  const data = JSON.parse(event.data);
  
  if (data.result === true) {
    console.log('Successfully unsubscribed from subscription:', subscriptionId);
  } else if (data.error) {
    console.error('Unsubscribe failed:', data.error);
  }
};
{
  "jsonrpc": "2.0",
  "result": true,
  "id": 1
}

Last updated