Skip to main content
GraphQL subscriptions enable real-time updates for blockchain data. Subscribe to events, transactions, and state changes as they occur.

WebSocket Connection

Subscriptions require a WebSocket connection to the GraphQL endpoint: Mainnet:
Testnet:
Devnet:

Event Subscriptions

Subscribe to All Events

Subscribe to Events by Type

Variables:

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 the graphql-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
For production use:
  • Run your own indexer with GraphQL
  • Use managed RPC providers with higher limits
  • Implement client-side throttling