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

# WebSocket API

> Real-time data streams for market data and account updates

The Tide WebSocket API provides real-time updates for market data and account information. Connect to receive live order book updates, trade executions, position changes, and more.

## Connection

### WebSocket Endpoint

```
wss://api.tide.ag/ws
```

### Connection Example

```javascript theme={null}
const WebSocket = require('ws');

const ws = new WebSocket('wss://api.tide.ag/ws');

ws.on('open', function open() {
  console.log('Connected to Tide WebSocket');
});

ws.on('message', function message(data) {
  const update = JSON.parse(data);
  console.log('Received:', update);
});
```

## Authentication

Public streams work without Tide API credentials. Private streams may require an authentication message after connect when signing is enforced—check stream documentation for your use case.

When auth is required, send the message below immediately after connection.

### Authentication Message

```json theme={null}
{
  "method": "auth",
  "params": {
    "apiKey": "your_api_key",
    "timestamp": 1698765432000,
    "signature": "hmac_sha256_signature"
  }
}
```

## Public Streams

### Order Book Updates

**Topic**: `orderbook:{symbol}`

Subscribe to real-time order book updates for a specific symbol.

```json theme={null}
{
  "method": "subscribe",
  "params": {
    "topic": "orderbook:BTC-USD",
    "exchanges": ["hyperliquid", "aster"],
    "depth": 20
  }
}
```

### Trade Updates

**Topic**: `trades:{symbol}`

Subscribe to real-time trade executions for a specific symbol.

```json theme={null}
{
  "method": "subscribe",
  "params": {
    "topic": "trades:BTC-USD",
    "exchanges": ["hyperliquid", "aster"]
  }
}
```

## Private Streams

### Order Updates

**Topic**: `orders`

Subscribe to real-time updates for your orders.

```json theme={null}
{
  "method": "subscribe",
  "params": {
    "topic": "orders",
    "symbols": ["BTC-USD", "ETH-USD"]
  }
}
```

### Position Updates

**Topic**: `positions`

Subscribe to real-time position updates.

```json theme={null}
{
  "method": "subscribe",
  "params": {
    "topic": "positions",
    "symbols": ["BTC-USD", "ETH-USD"]
  }
}
```

## Rate Limits

* **Connections**: 5 simultaneous connections per client
* **Subscriptions per connection**: 50 topics
* **Messages per second**: 100 outbound messages

<Note>
  For complete WebSocket documentation including authentication, error handling, and reconnection strategies, see our comprehensive WebSocket guide.
</Note>
