Skip to main content

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;
Learn more about authentication and API key management in the Authentication guide.

Available Channels

The WebSocket offers three types of channels:
  • User Channel - Receive updates about your own orders and transactions;
  • Market Channel - Receive updates about specific markets (orderbook and trades);
  • 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

Getting Started

  1. Get your API key at Profile → Security (required only for user channel);
  2. Read the connection documentation to understand how to connect;
  3. Learn how to subscribe to channels;
  4. Explore the documentation for the specific channels you need to use;
  5. Consult the error documentation for proper error handling.

Quick Example

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);
};