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

# WebSocket

> Real-time data feeds for Bayse Markets

## Overview

The Bayse Markets WebSocket API provides real-time streaming data for market activity, price changes, order book updates, and live asset prices.

**Base URL:** `wss://socket.bayse.markets`

## Endpoints

| Endpoint          | Auth        | Description                                                     |
| ----------------- | ----------- | --------------------------------------------------------------- |
| `/ws/v1/markets`  | None        | Market activity feeds, price updates, and order book snapshots. |
| `/ws/v1/user`     | Per-message | Fill updates for your orders.                                   |
| `/ws/v1/realtime` | None        | Live asset prices (crypto and FX).                              |

## Quick example

Connect to the markets endpoint and subscribe to price updates:

```javascript theme={null}
const ws = new WebSocket("wss://socket.bayse.markets/ws/v1/markets");

ws.addEventListener("open", () => {
  ws.send(JSON.stringify({
    type: "subscribe",
    channel: "prices",
    eventId: "EVENT_ID"
  }));
});

ws.addEventListener("message", (event) => {
  for (const line of event.data.split("\n")) {
    if (line.trim()) {
      const msg = JSON.parse(line);
      console.log(msg.type, msg.data);
    }
  }
});
```

<Note>
  The server may batch multiple JSON messages into a single WebSocket frame separated by newlines. Always split on `\n` before parsing. See [Connection](/websocket/connection) for details.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Connection" icon="plug" href="/websocket/connection">
    Message format, keepalive, and reconnection.
  </Card>

  <Card title="Market data" icon="chart-line" href="/websocket/market-data">
    Activity feeds, price updates, and order book snapshots.
  </Card>

  <Card title="User orders" icon="bell" href="/websocket/user-orders">
    Real-time fill updates for your orders.
  </Card>

  <Card title="Asset prices" icon="bitcoin-sign" href="/websocket/crypto-prices">
    Live crypto and FX price feeds.
  </Card>

  <Card title="Errors" icon="triangle-exclamation" href="/websocket/errors">
    Error handling and rate limits.
  </Card>
</CardGroup>
