Skip to main content

Overview

WebSocket endpoints are available for real-time data streaming and as an alternative to HTTP request sending on the ChainStream exchange. The WebSocket URLs by network are:
  • Mainnet: wss://realtime-dex.chainstream.io/connection/websocket

Authentication

WebSocket connections require authentication via the token query parameter in the URL:
wss://realtime-dex.chainstream.io/connection/websocket?token=YOUR_ACCESS_TOKEN
If you are using our Go SDK or JavaScript SDK, authentication is built-in and handled automatically. You only need to manually append the token parameter when using native WebSocket libraries or other third-party libraries.

Connecting

To connect to the WebSocket API, you must establish a WebSocket connection to the respective URL based on your desired network, with the token parameter in the URL. Once connected, you can start sending subscription messages to receive real-time data updates.

Command Line Example

Using wscat to test the connection:
$ wscat -c "wss://realtime-dex.chainstream.io/connection/websocket?token=YOUR_ACCESS_TOKEN"
Connected (press CTRL+C to quit)
> { "method": "subscribe", "subscription": { "type": "trades", "coin": "SOL" } }
< {"channel":"subscriptionResponse","data":{"method":"subscribe","subscription":{"type":"trades","coin":"SOL"}}}
Failing to provide a valid token parameter will result in connection rejection or inability to receive data.
This documentation uses TypeScript for defining message types. For Python users, you can find equivalent types in our Python SDK.