> For the complete documentation index, see [llms.txt](https://docs.ojolabs.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ojolabs.xyz/markets/api/orderbook.md).

# Orderbook

Retrieve the live orderbook for a market.

## Get Orderbook

Returns the current orderbook snapshot for a market.

```
GET /api/v1/orderbook/{marketId}
```

### Path Parameters

| Parameter  | Type    | Description       |
| ---------- | ------- | ----------------- |
| `marketId` | bytes32 | Market identifier |

### Query Parameters

| Parameter | Type   | Required | Description                                                                   |
| --------- | ------ | -------- | ----------------------------------------------------------------------------- |
| `outcome` | string | No       | Filter by outcome: `YES` or `0`, `NO` or `1`. If omitted, returns all orders. |

### Response

```json
{
  "marketId": "0x1234...abcd",
  "bids": [
    {
      "price": 500000,
      "size": 10000000
    },
    {
      "price": 490000,
      "size": 20000000
    }
  ],
  "asks": [
    {
      "price": 520000,
      "size": 15000000
    }
  ],
  "lastUpdate": 1735689000
}
```

| Field        | Type    | Description                                            |
| ------------ | ------- | ------------------------------------------------------ |
| `marketId`   | bytes32 | Market identifier                                      |
| `bids`       | array   | Buy orders sorted by price descending (best bid first) |
| `asks`       | array   | Sell orders sorted by price ascending (best ask first) |
| `lastUpdate` | uint64  | Unix timestamp of last orderbook update                |

### Price Level Fields

| Field   | Type   | Description                                                         |
| ------- | ------ | ------------------------------------------------------------------- |
| `price` | uint64 | Price in USDC (6 decimals). `500000` = $0.50                        |
| `size`  | uint64 | Total size at this price level (6 decimals). `10000000` = 10 shares |

### Per-Outcome Orderbooks

YES and NO each have separate orderbooks. A BUY YES order only matches against SELL YES orders, never SELL NO.

When you specify `outcome=YES`, you get the YES orderbook:

* **Bids**: Users wanting to buy YES tokens
* **Asks**: Users wanting to sell YES tokens

### Examples

```bash
# All orders (both YES and NO)
curl "https://api.turbinefi.com/api/v1/orderbook/0x1234...abcd"

# YES orderbook only
curl "https://api.turbinefi.com/api/v1/orderbook/0x1234...abcd?outcome=YES"

# NO orderbook only
curl "https://api.turbinefi.com/api/v1/orderbook/0x1234...abcd?outcome=NO"
```

If no orderbook exists for a market, an empty snapshot is returned with `bids: []` and `asks: []`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ojolabs.xyz/markets/api/orderbook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
