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

Connecting

To connect to the WebSocket API, you must establish a WebSocket connection to the respective URL based on your desired network. 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
Connected (press CTRL+C to quit)
> { "method": "subscribe", "subscription": { "type": "trades", "coin": "SOL" } }
< {"channel":"subscriptionResponse","data":{"method":"subscribe","subscription":{"type":"trades","coin":"SOL"}}}

This documentation uses TypeScript for defining message types. For Python users, you can find equivalent types in our Python SDK.