Cancelling a Subscription
If you need to cancel a subscription, pass the subscription ID to the unsubscribe call.

Example

Gateway
Cloud-API (Enterprise)
Cloud-API (Non-Enterprise)
Unsubscribe call example for the Gateway in Python (line 5 cancels the subscription):
1
from bloxroute_cli.provider.ws_provider import WsProvider
2
ws_uri = "ws://127.0.0.1:28333"
3
async with WsProvider(ws_uri) as ws:
4
subscription_id = await ws.subscribe("newTxs", {"include": ["tx_hash"]})
5
await ws.unsubscribe(subscription_id)
6
Copied!
Unsubscribe call example for the Cloud-API in Python (line 6 cancels the subscription):
1
from bloxroute_cli.provider.cloud_wss_provider import CloudWssProvider
2
async with CloudWssProvider(
3
ssl_dir="/usr/bloxroute/certificate/external_gateway/registration_only"
4
) as ws:
5
subscription_id = await ws.subscribe("newTxs", {"include": ["tx_hash"]})
6
await ws.unsubscribe(subscription_id)
7
Copied!
​
Unsubscribe call example for the Cloud-API in Python (line 7 cancels the subscription):
1
from bloxroute_cli.provider.ws_provider import WsProvider
2
async with WsProvider(
3
uri="wss://api.blxrbdn.com/ws",
4
headers={"Authorization": <YOUR-AUTHORIZATION-HEADER>}
5
) as ws:
6
subscription_id = await ws.subscribe("newTxs", {"include": ["tx_hash"]})
7
await ws.unsubscribe(subscription_id)
8
​
Copied!
​
Last modified 10mo ago
Copy link