> For the complete documentation index, see [llms.txt](https://docs-data.volmex.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-data.volmex.finance/data-api/websockets.md).

# Websockets

Volmex offers both public and private websocket connections for real-time index data retrieval.

### Public Websockets Realtime Data

```
const socket = io('wss://ws.volmex.finance', {transports: ['websocket']});
   socket.on('connect', function () {
     console.log('Connected');
     socket.emit('fetch-indices-messages', {});
     socket.on('indices-messages-stream', (data) => {
       console.log(data);
   });
});
```

### Private Websockets Realtime Data

Authenticate and retrieve your access token:

```
curl --request POST \
--url 'https://rest-v1.volmex.finance/auth/authorize' \
-d 'login=API_USER&password=API_PASSWORD'
```

Client sample:

```
const socket = io('wss://ws.volmex.finance', {transports: ['websocket'], query: {jwkToken: 'YOUR_JWT_TOKEN'});
   socket.on('connect', function () {
     console.log('Connected');
     socket.emit('fetch-indices-messages-private', {});
     socket.on('indices-messages-stream-private', (data) => {
       console.log(data);
   });
});
```
