Client
Session
- Context manager
- Manual
Managing Webhooks
Subscriptions
A boundTonapiWebhook manages subscriptions without requiring an explicit webhook ID.
Account transactions
Other subscriptions
Deleting a webhook
Event Handling
The dispatcher manages handler registration, webhook lifecycle, and event routing.Registering handlers
account_tx, opcode_msg, new_contracts accept *accounts for local filtering. All accept path for custom URL paths. Default paths: /account-tx, /mempool-msg, /opcode-msg, /new-contracts.
Without decorators:
Lifecycle
setup() opens a session, creates webhooks per event type, subscribes, and stores tokens.
teardown(cleanup) closes the session. When cleanup=True, unsubscribes from all events first. Subscriptions persist across restarts — on next setup(), existing webhooks are reused via ensure().
Processing events
Dependencies
Pass default dependencies via**kwargs in the constructor. Handlers receive only parameters they declare in their signature:
process() take priority over constructor defaults. Handlers can be async or sync — the dispatcher awaits async results automatically.
Models
WebhookInfo
WebhookInfo
AccountSubscription
AccountSubscription