The Streaming API supports GraphQL subscriptions over WebSocket, using the GraphQL over WebSocket protocol.The recommended approach is to use the official TypeScript Client SDK which supports the Streaming API and manages all WebSocket connections.
Copy
Ask AI
npm install @covalenthq/client-sdk
You can also use a GraphQL over WebSocket protocol npm package like graphql-ws.
If you’re not using the graphql-ws package, you must set the WebSocket protocol header:"Sec-WebSocket-Protocol" : "graphql-transport-ws"This header is required for the server to properly recognize and handle your GraphQL subscription requests.
The following examples show how to connect and subscribe to the OHLCV Token stream using your preferred language or tool. Each sample connects to the WebSocket endpoint, authenticates with your API key, and streams real-time OHLCV updates for a token on Base Mainnet.