VeztaVezta
WebSocket Reference

WebSocket Overview

Socket.IO connection, authentication, and channel architecture

Vezta provides real-time data through a Socket.IO WebSocket server. All market data, order updates, portfolio changes, and platform signals are delivered through 8 channels using a consistent subscribe/unsubscribe pattern.

Connection

Connect using the Socket.IO client library. The server runs at the /ws namespace:

import { io } from 'socket.io-client';

const socket = io('wss://backend.vezta.io/ws', {
  transports: ['websocket'],
  auth: {
    token: '<your-jwt-access-token>',
  },
  reconnection: true,
  reconnectionDelay: 1000,
  reconnectionDelayMax: 30000,
});

socket.on('connect', () => {
  console.log('Connected:', socket.id);
});

socket.on('disconnect', (reason) => {
  console.log('Disconnected:', reason);
});

For local development, connect to ws://localhost:3001/ws.

Authentication

Pass your JWT access token in the auth.token field during connection. Public channels (market:*, monitor:signals) work without authentication. User-specific channels (user:*) require a valid token.

Subscribe to a Channel

Send a subscribe event with the channel name:

socket.emit('subscribe', { channel: 'market:prices' });

The server responds with a confirmation:

{ "event": "subscribed", "data": { "channel": "market:prices" } }

Unsubscribe from a Channel

socket.emit('unsubscribe', { channel: 'market:prices' });

Response:

{ "event": "unsubscribed", "data": { "channel": "market:prices" } }

Receiving Data

All channel broadcasts arrive on the data event with a consistent envelope:

socket.on('data', (message) => {
  // message.channel — the channel name (e.g., "market:prices")
  // message.data    — the payload
  console.log(`[${message.channel}]`, message.data);
});

Route messages by inspecting message.channel:

socket.on('data', (message) => {
  switch (message.channel) {
    case 'market:prices':
      updatePrices(message.data);
      break;
    case 'market:orderbook':
      updateOrderbook(message.data);
      break;
    case 'user:orders':
      handleOrderUpdate(message.data);
      break;
    // ... handle other channels
  }
});

Available Channels

ChannelAuthDescription
market:pricesNoReal-time YES/NO price updates
market:orderbookNoOrder book depth snapshots
market:tradesNoLive trade feed from exchanges
user:ordersYesOrder status changes and fills
user:notificationsYesIn-app notification delivery
user:portfolioYesPortfolio value and position updates
user:copy-tradeYesCopy trade execution events
monitor:signalsNoNews signals and whale activity

Full Example

import { io } from 'socket.io-client';

const socket = io('wss://backend.vezta.io/ws', {
  transports: ['websocket'],
  auth: { token: accessToken },
});

socket.on('connect', () => {
  // Subscribe to channels
  socket.emit('subscribe', { channel: 'market:prices' });
  socket.emit('subscribe', { channel: 'user:orders' });
  socket.emit('subscribe', { channel: 'monitor:signals' });
});

socket.on('data', (message) => {
  switch (message.channel) {
    case 'market:prices':
      console.log('Price update:', message.data);
      break;
    case 'user:orders':
      console.log('Order update:', message.data);
      break;
    case 'monitor:signals':
      console.log('Signal:', message.data);
      break;
  }
});

socket.on('disconnect', () => {
  console.log('Disconnected from WebSocket');
});

The web client uses exponential backoff reconnection starting at 1 second and capping at 30 seconds. The mobile client additionally handles AppState transitions, disconnecting when the app goes to background and reconnecting on foreground.

On this page