> ## 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.

# Order book

> Get the live order book for one or more outcomes (CLOB markets only)

## Authentication

No authentication required.

## Query parameters

<ParamField query="outcomeId[]" type="array" required>
  One or more outcome UUIDs to fetch order books for (comma-separated). Outcome IDs are returned by [List events](/api-reference/pm/list-events) and [Get event](/api-reference/pm/get-event).
</ParamField>

<ParamField query="depth" type="integer" default="10">
  Number of price levels to return on each side of the book.
</ParamField>

<ParamField query="currency" type="string" default="USD">
  Currency for price display: `USD` or `NGN`.
</ParamField>

## Example request

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://relay.bayse.markets/v1/pm/books?outcomeId[]=c3d4e5f6-a7b8-9012-cdef-123456789012&depth=5&currency=USD"
  ```

  ```javascript Node.js theme={null}
  const params = new URLSearchParams();
  params.append('outcomeId[]', 'c3d4e5f6-a7b8-9012-cdef-123456789012');
  params.append('outcomeId[]', 'd4e5f6a7-b8c9-0123-defa-234567890123');
  params.append('depth', '5');

  const response = await fetch(
    `https://relay.bayse.markets/v1/pm/books?${params}`
  );
  const books = await response.json();
  ```

  ```python Python theme={null}
  import requests

  resp = requests.get(
      'https://relay.bayse.markets/v1/pm/books',
      params={
          'outcomeId[]': [
              'c3d4e5f6-a7b8-9012-cdef-123456789012',
              'd4e5f6a7-b8c9-0123-defa-234567890123',
          ],
          'depth': 5,
          'currency': 'USD',
      },
  )
  books = resp.json()
  ```

  ```go Go theme={null}
  req, _ := http.NewRequest("GET", "https://relay.bayse.markets/v1/pm/books", nil)
  q := req.URL.Query()
  q.Add("outcomeId[]", "c3d4e5f6-a7b8-9012-cdef-123456789012")
  q.Add("outcomeId[]", "d4e5f6a7-b8c9-0123-defa-234567890123")
  q.Add("depth", "5")
  q.Add("currency", "USD")
  req.URL.RawQuery = q.Encode()
  resp, _ := http.DefaultClient.Do(req)
  ```
</CodeGroup>

## Response

Returns an array of order books, one per requested outcome. Each book contains the top bids (buy orders) and asks (sell orders) at the requested depth.

<ResponseField name="marketId" type="string">
  The market ID this order book belongs to.
</ResponseField>

<ResponseField name="outcomeId" type="string">
  The outcome ID this order book is for.
</ResponseField>

<ResponseField name="timestamp" type="string">
  ISO 8601 timestamp of the order book snapshot.
</ResponseField>

<ResponseField name="bids" type="array">
  Buy orders sorted by price (highest first). Each entry has `price`, `quantity`, and `total`.
</ResponseField>

<ResponseField name="asks" type="array">
  Sell orders sorted by price (lowest first). Each entry has `price`, `quantity`, and `total`.
</ResponseField>

<ResponseField name="lastTradedPrice" type="number">
  The last traded price for this outcome (if available).
</ResponseField>

<ResponseField name="lastTradedSide" type="string">
  The side of the last trade: `BUY` or `SELL` (if available).
</ResponseField>

<ResponseExample>
  ```json 200 OK theme={null}
  [
    {
      "marketId": "660e8400-e29b-41d4-a716-446655440001",
      "outcomeId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "timestamp": "2025-01-15T10:30:00Z",
      "bids": [
        { "price": 0.70, "quantity": 200, "total": 140.0 },
        { "price": 0.69, "quantity": 450, "total": 310.5 },
        { "price": 0.68, "quantity": 300, "total": 204.0 },
        { "price": 0.67, "quantity": 600, "total": 402.0 },
        { "price": 0.65, "quantity": 1000, "total": 650.0 }
      ],
      "asks": [
        { "price": 0.72, "quantity": 150, "total": 108.0 },
        { "price": 0.73, "quantity": 300, "total": 219.0 },
        { "price": 0.74, "quantity": 250, "total": 185.0 },
        { "price": 0.75, "quantity": 500, "total": 375.0 },
        { "price": 0.77, "quantity": 800, "total": 616.0 }
      ],
      "lastTradedPrice": 0.71,
      "lastTradedSide": "BUY"
    }
  ]
  ```
</ResponseExample>

<Note>
  This endpoint is only meaningful for CLOB markets. AMM markets do not have an order book.
</Note>
