Skip to main content

Overview

The user channel allows you to receive real-time updates about your own orders and transactions. This channel is useful for monitoring your order status, receiving execution notifications, and tracking your transactions.

Authentication

The user channel requires authentication using your API key (X-Api-Key). The key must be provided in the auth field of the subscribe message.

Subscribe

To subscribe to the user channel:
{
  "type": "subscribe",
  "channel": "user",
  "auth": "your-api-key-here"
}

Requirements

  • auth (required): Your API key (X-Api-Key)
Keep your API key secure and never expose it in client code or public repositories.

Received Messages

User Update

Received when there are changes to your orders or transactions. Structure:
{
  "trade_type": "LIMIT_BUY",
  "user_id": "string",
  "event_id": "string",
  "market_id": "string",
  "side": "BUY",
  "contract_type": "YES",
  "price": 40,
  "quantity": 10,
  "transaction_fee": 10
}

Fields

  • trade_type: Type of executed order (LIMIT_BUY, LIMIT_SELL, MARKET_BUY_VALUE, MARKET_BUY_QTY, MARKET_SELL);
  • user_id: Your user ID;
  • event_id: Related event ID;
  • market_id: Related market ID;
  • side: Order side (BUY or SELL);
  • contract_type: Contract type (YES or NO);
  • price: Transaction price in ticks;
  • quantity: Number of contracts;
  • transaction_fee: Transaction fee in cents.

Usage Example

const ws = new WebSocket('wss://data-ws.voxfi.com.br');
const API_KEY = 'your-api-key-here';

ws.onopen = () => {
  // Subscribe to user channel
  ws.send(JSON.stringify({
    type: 'subscribe',
    channel: 'user',
    auth: API_KEY
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  
  if (data.user_id) {
    console.log('User update received:', data);
    
    // Process update
    if (data.side === 'BUY') {
      console.log(`Buy executed: ${data.quantity} ${data.contract_type} contracts at ${data.price} ticks`);
    } else {
      console.log(`Sell executed: ${data.quantity} ${data.contract_type} contracts at ${data.price} ticks`);
    }
  }
};

Unsubscribe

To unsubscribe from the user channel:
{
  "type": "unsubscribe",
  "channel": "user"
}

Use Cases

  • Order Monitoring: Receive instant notifications when your orders are executed;
  • Transaction Tracking: Track all your transactions in real-time;
  • Portfolio Management: Update your local portfolio as transactions occur;
  • Execution Alerts: Implement alerts when specific orders are filled;
  • Performance Analysis: Collect data about your transactions for later analysis.

Best Practices

  • Security: Never expose your API key in client code. Use environment variables or backend services to manage authentication;
  • Validation: Always validate received messages before processing them;
  • Logging: Log all received updates for auditing and debugging;
  • Error Handling: Handle authentication errors properly and implement reconnection when necessary.