WebSocket API Reference
Solana WebSocket subscription methods and event formats.
The Solana WebSocket API provides real-time event subscriptions for accounts, programs, transactions, and slots. WebSocket subscriptions are simpler to implement than gRPC but have lower throughput and less filtering capability.
Connection
Connect to the WebSocket endpoint (wss://api.mainnet-beta.solana.com for public, or your provider's WebSocket URL). Send subscription requests as JSON-RPC messages.
accountSubscribe
Subscribe to changes in a specific account. Receive notifications whenever the account's data or lamport balance changes. Useful for monitoring specific program accounts, token balances, or price feeds.
programSubscribe
Subscribe to all accounts owned by a specific program. Receive notifications whenever any account owned by the program changes. Useful for monitoring DEX pool state or program-wide activity.
signatureSubscribe
Subscribe to the status of a specific transaction signature. Receive a notification when the transaction is confirmed or finalized. Use this to track transaction confirmation without polling.
slotSubscribe
Subscribe to slot progress notifications. Receive updates as new slots are processed. Useful for tracking blockchain progress and detecting network slowdowns.
logsSubscribe
Subscribe to transaction logs matching a filter. Filter by mentions (transactions that mention specific accounts) or all (all transactions). Useful for monitoring program events without parsing full transaction data.
Limitations
WebSocket subscriptions can miss events during high network activity. For production applications requiring guaranteed delivery, use gRPC streaming instead. WebSocket subscriptions also have limited server-side filtering compared to gRPC.