unsubscribe
Drop a subscription locally and tell the server to stop streaming.
Signature
def unsubscribe(self, subscription_id: int) -> boolExample
from dango.info import Info
from dango.utils.constants import MAINNET_API_URL
from dango.utils.types import PairId
info = Info(MAINNET_API_URL)
sid = info.subscribe_perps_trades(PairId("perp/ethusd"), print)
# ... later ...
ok = info.unsubscribe(sid)
print("dropped:", ok)Parameters
subscription_id — int. The id returned by a previous subscribe_* call.
Returns
bool — True if the subscription was registered and a complete frame was sent. False if the id was unknown (or no WebSocket connection was ever opened).
Notes
- Calling
unsubscribeafterdisconnect_websocketreturnsFalse. - Safe to call on shutdown even if you never opened a subscription.
See also
disconnect_websocket— close the whole connection