getblock_unsubscribe - EVM Data Stream
getblock_unsubscribe cancels a subscription created with getblock_subscribe. Delivery for that subscription stops and it no longer counts toward your 15-subscription limit. Other subscriptions on the same socket are unaffected.
WebSocket-only method. Send it on the same connection that owns the subscription.
Parameters
params is an array containing exactly one object:
| Parameter | Type | Required | Description |
|---|---|---|---|
subscription | string | Yes | The subscription ID returned by getblock_subscribe. |
Wrap the subscription ID in an object: [{"subscription": "0x…"}]. A bare string, as eth_unsubscribe accepts, fails with getblock_unsubscribe params must contain one object.
Request Example
bashwscat -c 'wss://stream.eu-central-1.getblock.io/v1/eth-mainnet/stream' -H 'Authorization: Bearer <API-KEY>'
# WebSocket-only. On the connection that owns the subscription, send:
{"jsonrpc":"2.0","id":2,"method":"getblock_unsubscribe","params":[{"subscription":"0x573e3382e8ea7d534f267b232aae22dd"}]}javascriptws.send(JSON.stringify({
jsonrpc: '2.0',
id: 2,
method: 'getblock_unsubscribe',
params: [{ subscription: subscriptionId }]
}));pythonawait ws.send(json.dumps({
"jsonrpc": "2.0",
"id": 2,
"method": "getblock_unsubscribe",
"params": [{"subscription": subscription_id}]
}))Response Example
json{
"jsonrpc": "2.0",
"id": 2,
"result": true
}Response Parameters
| Field | Type | Description |
|---|---|---|
result | boolean | true when the subscription was cancelled. false when no active subscription with that ID exists on this connection, for example because it was already cancelled. |
An event that was already in flight can still arrive shortly after you unsubscribe. Drop notifications whose params.subscription you no longer track.
Use Cases
- Switching a wallet view from one address to another without dropping the socket
- Freeing a slot when you approach the 15-subscription limit
- Replacing a subscription with one that has different filters (subscriptions cannot be modified in place)
- Tearing down cleanly when a component unmounts
Error Handling
| Code | Message | Cause |
|---|---|---|
-32602 | getblock_unsubscribe params must contain one object | params was empty, held more than one entry, or the entry was not an object, such as a bare ID string. |
-32602 | subscription is required | The object has no subscription field. id is not an accepted alias. |