Skip to main content

Overview

The /ws/v1/markets endpoint streams real-time market data. No authentication is required.
wss://socket.bayse.markets/ws/v1/markets
Three subscription types are available:
SubscriptionChannelServer event typeDescription
Activity feedactivitybuy_order, sell_orderBuy and sell order activity for an event.
Price updatespricesprice_updateMarket price changes for an event.
Orderbookorderbookorderbook_updateOrder book snapshots for a market.

Activity feed

Subscribe to trade activity for a prediction event. Optionally filter by a specific market.

Subscribe

{
  "type": "subscribe",
  "channel": "activity",
  "eventId": "EVENT_ID"
}
To filter activity to a specific market within the event:
{
  "type": "subscribe",
  "channel": "activity",
  "eventId": "EVENT_ID",
  "marketId": "MARKET_ID"
}
Room names: activity:<eventId> or activity:<eventId>:<marketId>

Events received

buy_order — A buy order was filled.
{
  "type": "buy_order",
  "data": {
    "user": {
      "id": "usr_8b5c3c3a",
      "tag": "prediction_pro",
      "imageUrl": "https://cdn.bayse.markets/users/8b5c3c3a.png"
    },
    "order": {
      "id": "ord_7f5e2a1c",
      "amount": 100.00,
      "quantity": 150.0,
      "price": 0.65,
      "status": "FILLED",
      "type": "BUY",
      "outcome": "YES",
      "outcomeLabel": "Yes",
      "currency": "USD",
      "createdAt": "2026-02-17T10:30:00Z",
      "updatedAt": "2026-02-17T10:30:01Z"
    },
    "event": {
      "id": "evt_123",
      "slug": "us-fed-rate-cut-2026",
      "title": "Will the Fed cut rates in 2026?",
      "type": "SINGLE_MARKET",
      "createdAt": "2026-01-10T09:00:00Z",
      "imageUrl": "https://cdn.bayse.markets/events/fed.png"
    },
    "market": {
      "id": "mkt_456",
      "title": "Yes or No",
      "imageUrl": null
    }
  },
  "timestamp": 1700000000000
}
sell_order — A sell order was filled.
{
  "type": "sell_order",
  "data": {
    "user": { "id": "usr_9a1d2f4b", "tag": null, "imageUrl": null },
    "order": {
      "id": "ord_aa12bb34",
      "amount": 50.00,
      "quantity": 80.0,
      "price": 0.70,
      "status": "FILLED",
      "type": "SELL",
      "outcome": "YES",
      "outcomeLabel": "Yes",
      "currency": "USD",
      "createdAt": "2026-02-17T10:35:00Z",
      "updatedAt": "2026-02-17T10:35:01Z"
    },
    "event": { "id": "evt_123", "slug": "us-fed-rate-cut-2026", "title": "Will the Fed cut rates in 2026?", "type": "SINGLE_MARKET", "createdAt": "2026-01-10T09:00:00Z", "imageUrl": "https://cdn.bayse.markets/events/fed.png" },
    "market": { "id": "mkt_456", "title": "Yes or No", "imageUrl": null }
  },
  "timestamp": 1700000000000
}
quantity is floored. createdAt and updatedAt are ISO 8601 strings.

Unsubscribe

{ "type": "unsubscribe", "room": "activity:EVENT_ID" }
For a market-specific subscription:
{ "type": "unsubscribe", "room": "activity:EVENT_ID:MARKET_ID" }

Price updates

Subscribe to price changes for all markets in a prediction event.

Subscribe

{
  "type": "subscribe",
  "channel": "prices",
  "eventId": "EVENT_ID"
}
Room name: prices:<eventId>

Events received

price_update — A market price changed. The data field contains the full event snapshot. Example (trimmed):
{
  "type": "price_update",
  "data": {
    "id": "evt_123",
    "slug": "us-fed-rate-cut-2026",
    "title": "Will the Fed cut rates in 2026?",
    "status": "open",
    "type": "SINGLE_MARKET",
    "markets": [
      {
        "id": "mkt_456",
        "question": "Yes or No?",
        "outcomes": ["Yes", "No"],
        "engine": "CLOB",
        "prices": { "YES": 0.65, "NO": 0.35 }
      }
    ]
  },
  "timestamp": 1700000000000
}

Unsubscribe

{ "type": "unsubscribe", "room": "prices:EVENT_ID" }

Orderbook updates

Subscribe to order book snapshots for specific markets. Snapshots reflect the current state of bids and asks.

Subscribe

{
  "type": "subscribe",
  "channel": "orderbook",
  "marketIds": ["MARKET_ID"]
}
To receive orderbook data in a specific currency:
{
  "type": "subscribe",
  "channel": "orderbook",
  "marketIds": ["MARKET_ID"],
  "currency": "NGN"
}
marketIds supports up to 10 markets per subscription. The currency field accepts USD or NGN.
Room names: orderbook:<marketId> or orderbook:<marketId>:<currency>

Events received

orderbook_update — The order book snapshot was updated.
{
  "type": "orderbook_update",
  "data": {
    "orderbook": {
      "marketId": "mkt_456",
      "outcomeId": "out_789",
      "timestamp": "2026-02-17T10:40:00Z",
      "bids": [
        { "price": 0.60, "quantity": 500, "total": 300.0 },
        { "price": 0.55, "quantity": 300, "total": 165.0 }
      ],
      "asks": [
        { "price": 0.65, "quantity": 200, "total": 130.0 },
        { "price": 0.70, "quantity": 400, "total": 280.0 }
      ],
      "lastTradedPrice": 0.65,
      "lastTradedSide": "BUY"
    }
  },
  "timestamp": 1700000000000
}

Unsubscribe

For USD (default):
{ "type": "unsubscribe", "room": "orderbook:MARKET_ID" }
For NGN:
{ "type": "unsubscribe", "room": "orderbook:MARKET_ID:NGN" }

Full example

const ws = new WebSocket("wss://socket.bayse.markets/ws/v1/markets");

ws.addEventListener("open", () => {
  // Subscribe to multiple channels
  ws.send(JSON.stringify({
    type: "subscribe",
    channel: "activity",
    eventId: "EVENT_ID"
  }));

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

  ws.send(JSON.stringify({
    type: "subscribe",
    channel: "orderbook",
    marketIds: ["MARKET_ID"],
    currency: "USD"
  }));
});

ws.addEventListener("message", (event) => {
  for (const line of event.data.split("\n")) {
    if (!line.trim()) continue;
    const msg = JSON.parse(line);

    switch (msg.type) {
      case "buy_order":
      case "sell_order":
        console.log("Trade:", msg.data);
        break;
      case "price_update":
        console.log("Price:", msg.data);
        break;
      case "orderbook_update":
        console.log("Orderbook:", msg.data);
        break;
    }
  }
});