Links

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):
from bxcommon.rpc.provider.ws_provider import WsProvider
ws_uri = "ws://127.0.0.1:28333/ws"
async with WsProvider(ws_uri) as ws:
subscription_id = await ws.subscribe("newTxs", {"include": ["tx_hash"]})
await ws.unsubscribe(subscription_id)
Unsubscribe call example for the Cloud-API in Python (line 9 cancels the subscription):
from bxcommon.rpc.provider.ws_provider import WsProvider
async with WsProvider(
uri="wss://virginia.eth.blxrbdn.com/ws",
headers={"Authorization": <YOUR-AUTHORIZATION-HEADER>},
# Add the following line if you work with IP instead of DNS
# skip_ssl_cert_verify=True
) as ws:
subscription_id = await ws.subscribe("newTxs", {"include": ["tx_hash"]})
await ws.unsubscribe(subscription_id)
Unsubscribe call example for the Cloud-API in Python (line 9 cancels the subscription):
from bxcommon.rpc.provider.ws_provider import WsProvider
async with WsProvider(
uri="wss://api.blxrbdn.com/ws",
headers={"Authorization": <YOUR-AUTHORIZATION-HEADER>},
# Add the following line if you work with IP instead of DNS
# skip_ssl_cert_verify=True
) as ws:
subscription_id = await ws.subscribe("newTxs", {"include": ["tx_hash"]})
await ws.unsubscribe(subscription_id)