Skip to main content

Overview

The event channel allows you to receive real-time updates about one or more specific events. Since an event can contain multiple markets, this channel is useful for monitoring all markets of an event at once.

Authentication

The event channel does not require authentication. You can subscribe without providing an API key.

Subscribe

To subscribe to the event channel:
{
  "type": "subscribe",
  "channel": "event",
  "events": ["event-id-1", "event-id-2"],
  "filter": "trades"
}

Requirements

  • events (required): Array of event IDs
  • filter (optional): Desired update type
    • "" or "all": All updates (default)
    • "orderbook": Only orderbook updates
    • "trades": Only trade updates

Examples

Receive All Updates

{
  "type": "subscribe",
  "channel": "event",
  "events": ["event-id-1"]
}

Receive Only Orderbook

{
  "type": "subscribe",
  "channel": "event",
  "events": ["event-id-1", "event-id-2"],
  "filter": "orderbook"
}

Receive Only Trades

{
  "type": "subscribe",
  "channel": "event",
  "events": ["event-id-1"],
  "filter": "trades"
}

Received Messages

The received messages are identical to those from the market channel, but include updates from all markets in the event.

Orderbook Update

Received when there are changes to the orderbook of any market in the event (when filter is "orderbook" or "all"). Structure:
{
  "msg_type": "update-orderbook",
  "event_id": "string",
  "market_id": "string",
  "orderbook": {
    // Same structure as orderbook from market channel
  }
}

New Trade

Received when a new trade is executed on any market in the event (when filter is "trades" or "all"). Structure:
{
  "msg_type": "new-trade",
  "event_id": "string",
  "market_id": "string",
  "last_trade": {
    // Same structure as trade from market channel
  }
}

Complete Update

Received when there are general updates to any market in the event (when filter is "all" or not specified). Structure:
{
  "msg_type": "update",
  "event_id": "string",
  "market_id": "string",
  "orderbook": {
    // Same structure as orderbook from market channel
  },
  "last_trade": {
    // Same structure as trade from market channel
  }
}

Difference between Market and Event Channels

  • Market Channel: Receives updates only from specified markets;
  • Event Channel: Receives updates from all markets within specified events.
If an event has multiple markets, the event channel allows you to monitor all of them with a single subscription.

Usage Example

const ws = new WebSocket('wss://data-ws.voxfi.com.br');

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

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  
  if (data.msg_type === 'update-orderbook') {
    console.log(`Orderbook updated on event ${data.event_id}, market ${data.market_id}`);
    console.log('YES price:', data.orderbook.market_price_yes);
    console.log('NO price:', data.orderbook.market_price_no);
  } else if (data.msg_type === 'new-trade') {
    console.log(`New trade on event ${data.event_id}, market ${data.market_id}`);
    console.log('Trade:', data.last_trade);
  }
};

Unsubscribe

To unsubscribe from specific events:
{
  "type": "unsubscribe",
  "channel": "event",
  "events": ["event-id-1"]
}

Use Cases

  • Complete Event Monitoring: Monitor all markets of an event with a single subscription;
  • Comparative Analysis: Compare prices and activity between different markets in the same event;
  • Event Dashboard: Create a complete dashboard showing all markets of an event;
  • Event Alerts: Set up alerts based on changes in any market of the event;
  • Correlation Analysis: Analyze correlations between different markets in the same event.

Best Practices

  • Use for Multi-Market Events: The event channel is especially useful for events with multiple markets;
  • Specific Filters: Use filters when you only need one type of update to reduce traffic;
  • Identification: Always check both event_id and market_id in messages to correctly identify the source;
  • Performance: For events with many markets, consider using filters to reduce message volume.