accountUnsubscribe
Last updated:
accountUnsubscribe tears down one account-change stream that was opened with
accountSubscribe on the same WebSocket connection.
Its single parameter is the integer subscription id — the result value the
server returned in the subscribe ack. On success the server replies
result: true and stops pushing accountNotification frames for that id; the
socket itself stays open, and any other subscriptions on it keep flowing.
Use it whenever a watch outlives its usefulness while the connection does not: a user navigates away from a wallet view but keeps the app open, a deposit you were waiting for has landed, or you are rotating a large watchlist and want to swap tracked accounts without paying the cost of a reconnect. Explicitly unsubscribing keeps the server-side subscription count down, which matters on connections juggling hundreds of account watches.
Three details are worth knowing. First, the id must belong to the current
session — subscription ids are per-connection, so after a reconnect the old
ids are meaningless and unsubscribing them returns an error (-32602,
invalid subscription id); simply resubscribe instead. Second, unsubscribing is
idempotent in effect but not in response: the first call returns true, a
repeat call with the same id fails because the subscription no longer exists.
Third, you never need to unsubscribe before closing the socket — dropping the
connection frees every subscription tied to it automatically. Reserve
accountUnsubscribe for surgically stopping one stream while the rest of the
session continues.
A stray notification can still arrive in the small window between sending the unsubscribe and receiving the ack; treat unknown subscription ids in incoming frames as ignorable rather than as errors.
Parameters
This method takes no parameters.
Returns
| Field | Type |
|---|---|
| result | object |
Examples
curl https://triport.io/sol \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"id":1,"method":"accountUnsubscribe","params":[],"jsonrpc":"2.0"}'const res = await fetch("https://triport.io/sol", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"id": 1,
"method": "accountUnsubscribe",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/sol",
headers={"Authorization": "Bearer <api-key>"},
json={"id":1,"method":"accountUnsubscribe","params":[],"jsonrpc":"2.0"},
)
print(resp.json())Usage
- Transport: WebSocket.
- Networks: mainnet, devnet, testnet.
- Credit cost: 1 per call.
FAQ
- What does accountUnsubscribe do?
- Cancels an active accountSubscribe stream, identified by the subscription id returned in the subscribe ack.
- How many credits does accountUnsubscribe cost?
- accountUnsubscribe costs 1 credit(s) per call on Triport by default.
- Is accountUnsubscribe available over WebSocket?
- Yes, accountUnsubscribe supports WebSocket.