WebSocket Connection
Subscriptions require a WebSocket connection to the GraphQL endpoint: Mainnet:Event Subscriptions
Subscribe to All Events
Subscribe to Events by Type
Subscribe to Events from Package
Subscribe to Events from Sender
Transaction Subscriptions
Subscribe to Transaction Effects
Subscribe to Transactions by Sender
Subscribe to Transactions Affecting Address
JavaScript/TypeScript Client
Using graphql-ws
Using Apollo Client
Rust Client Example
Using thegraphql-ws-client crate:
Best Practices
Reconnection Logic
Implement automatic reconnection for WebSocket disconnects:Error Handling
Handle subscription errors gracefully:Resource Management
Always clean up subscriptions:Rate Limits
Subscriptions are subject to rate limits:- Maximum 10 concurrent subscriptions per connection
- Messages throttled to prevent flooding
- Automatic disconnection if limits exceeded
- Run your own indexer with GraphQL
- Use managed RPC providers with higher limits
- Implement client-side throttling