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

# Introduction

> VoxFi WebSocket overview

## What is WebSocket?

The VoxFi WebSocket allows you to receive real-time updates about orders, orderbooks, and trades without needing constant polling. It's the recommended way to monitor market changes and your orders.

## Why use WebSocket?

* **Real-Time**: Receive updates instantly when changes occur;
* **Efficiency**: Avoid constant polling and reduce the number of HTTP requests;
* **Low Latency**: Bidirectional communication with minimal latency;
* **Resource Savings**: Less load on server and client.

## WebSocket URL

All WebSocket connections should be made to:

```
wss://data-ws-dev.voxfi.com.br
```

## Authentication

The WebSocket connection does not require initial authentication, but some channels require authentication when subscribing:

* **Market and Event Channels**: Do not require authentication.
* **User Channel**: Requires API key (`X-Api-Key`) in the `auth` field of the subscribe message;

<Info>
  Learn more about authentication and API key management in the [Authentication guide](/en/authentication).
</Info>

## Available Channels

The WebSocket offers three types of channels:

* **[User Channel](/en/websockets/user-channel)** - Receive updates about your own orders and transactions;
* **[Market Channel](/en/websockets/market-channel)** - Receive updates about specific markets (orderbook and trades);
* **[Event Channel](/en/websockets/event-channel)** - Receive updates about specific events (includes all markets in the event).

## Update Types

You can filter the type of update you want to receive:

* **Orderbook**: Price and market depth updates;
* **Trades**: Notifications of new executed trades;
* **All**: All updates (default).

## Documentation

* **[Connection](/en/websockets/connection)** - How to connect to WebSocket, ping/pong, available channels, use cases and best practices;
* **[Subscribe and Unsubscribe](/en/websockets/sub-unsub)** - How to subscribe and unsubscribe from channels;
* **[User Channel](/en/websockets/user-channel)** - Complete user channel documentation;
* **[Market Channel](/en/websockets/market-channel)** - Complete market channel documentation;
* **[Event Channel](/en/websockets/event-channel)** - Complete event channel documentation;
* **[Errors](/en/websockets/errors)** - Error handling and error codes.

## Getting Started

1. Get your API key at [Profile → Security](https://staging.voxfi.com.br/profile) (required only for user channel);
2. Read the [connection documentation](/en/websockets/connection) to understand how to connect;
3. Learn how to [subscribe to channels](/en/websockets/sub-unsub);
4. Explore the documentation for the specific channels you need to use;
5. Consult the [error documentation](/en/websockets/errors) for proper error handling.

## Quick Example

```javascript theme={null}
const ws = new WebSocket('wss://data-ws-dev.voxfi.com.br');

ws.onopen = () => {
  // Subscribe to a market
  ws.send(JSON.stringify({
    type: 'subscribe',
    channel: 'market',
    markets: ['market-id-1'],
    filter: 'orderbook'
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Update received:', data);
};
```
