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

# Overview

> WebSocket API for real-time financial news streaming

# WebSocket API

Real-time financial news streaming through WebSocket connections.

**Endpoint:** `wss://api.byul.ai/news-v2`

## Features

* Real-time news delivery
* Event-based messaging
* Subscription filtering
* Automatic reconnection
* Error handling

## Authentication

Authenticate using your API key in the connection options:

```javascript theme={null}
const socket = io('wss://api.byul.ai/news-v2', {
  auth: { apiKey: 'byul_api_key' }
});
```

## Events

**Client to Server:**

* `news:subscribe` - Subscribe to news stream
* `news:unsubscribe` - Unsubscribe from stream
* `news:unsubscribe:all` - Unsubscribe from all

**Server to Client:**

* `auth:success` - Authentication confirmed
* `news:data` - Real-time news articles
* `news:subscribed` - Subscription confirmed
* `news:error` - Error notifications

## Plan Requirements

<Info>
  WebSocket streaming requires Pro or Enterprise plan.
</Info>

| Plan        | Support | Connections |
| ----------- | ------- | ----------- |
| Test (Free) | No      | -           |
| Starter     | No      | -           |
| Pro         | Yes     | 10          |
| Enterprise  | Yes     | 50          |

## Quick Example

```javascript theme={null}
import { io } from 'socket.io-client';

const socket = io('wss://api.byul.ai/news-v2', {
  auth: { apiKey: 'byul_api_key' }
});

socket.on('connect', () => {
  socket.emit('news:subscribe', { 
    minImportance: 8,
    startDate: '2024-01-01T00:00:00.000Z',
    endDate: '2024-01-31T23:59:59.999Z'
  });
});

socket.on('news:data', (response) => {
  response.data.news.forEach(article => {
    console.log(`${article.title} (${article.importanceScore})`);
  });
});
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Quickstart" href="/websocket/quickstart">
    Connect and start streaming
  </Card>

  <Card title="Examples" href="/websocket/examples/nodejs">
    Code examples in multiple languages
  </Card>

  <Card title="Authentication" href="/websocket/authentication">
    API key authentication setup
  </Card>

  <Card title="Connection" href="/websocket/connection">
    Connection management guide
  </Card>
</CardGroup>
