> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstream.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Real-time data streaming via WebSocket API

## 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
```

<Note>
  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.
</Note>

## 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:

```bash theme={null}
$ 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"}}}
```

<Warning>
  Failing to provide a valid `token` parameter will result in connection rejection or inability to receive data.
</Warning>

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