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

# Prices & Order Book Data

> Query public order books, Token prices, Ticker data, batch prices, and price history through the Prediction API.

Each Market Outcome is represented by a Token. First obtain `outcomes[].token_id` through Discover Markets or Market Details, then use the Token ID to query price and liquidity data.

All endpoints on this page are public market-data endpoints and do not require authentication. Production Base URL:

```text theme={null}
https://api.dexbuilder.com
```

## Order Book

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/tokens/<token_id>/order_book?depth=20"
```

`depth` is optional and defaults to at most 20 levels per side. You can request 1–100 levels; the actual levels are in `bids` and `asks`.

```json Example theme={null}
{
  "token_id": "token-yes",
  "condition_id": "0xabc...",
  "timestamp": null,
  "hash": null,
  "bids": [{ "price": "0.48", "size": "100.00" }],
  "asks": [{ "price": "0.52", "size": "80.00" }],
  "min_order_size": null,
  "tick_size": null,
  "neg_risk": null,
  "last_trade_price": null
}
```

| Field | Description |
| - | - |
| `token_id` | Outcome Token ID |
| `condition_id` | Market Condition ID |
| `bids`, `asks` | Bid and ask depth; each level has decimal-string `price` and `size` |
| `timestamp` | Source-provided order-book snapshot time in Unix milliseconds; `null` when unavailable |
| `hash` | Source-provided hash of the full snapshot; `null` when unavailable |
| `min_order_size`, `tick_size`, `neg_risk` | Market trading parameters; `null` when unavailable |
| `last_trade_price` | Latest trade price; `null` when unavailable |

The API does not fill `timestamp` or `hash` with response time or estimated values. When `depth` truncates the book, a returned `hash` still identifies the source's full snapshot.

The current API does not provide a batch Order Book endpoint. If you need order books for multiple Tokens, request them separately.

## Latest Token Price

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/tokens/<token_id>/price"
```

```json theme={null}
{
  "token_id": "token-yes",
  "price": "0.50",
  "side": "BUY",
  "timestamp": 1782753357257
}
```

`price` is this Outcome Token's latest trade price, not its best bid or ask. When no usable trade is available, `price` and `side` are `""`, and `timestamp` is `null`.

## Token Ticker

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/tokens/<token_id>/ticker"
```

```json theme={null}
{
  "token_id": "token-yes",
  "last_price": "0.50",
  "best_bid": "0.48",
  "best_ask": "0.52",
  "timestamp": 1782753357257
}
```

`last_price`, `best_bid`, and `best_ask` are the latest trade price, best bid, and best ask. An unavailable component is `null`. `timestamp` is the latest reliable source time among the returned prices; it is `null` when no such time exists and is not the response time.

## Batch Token Prices

Query comma-separated Token IDs. A single request supports up to 100 distinct Tokens:

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/tokens/prices?token_ids=token-yes,token-no"
```

```json theme={null}
{
  "items": [
    { "token_id": "token-yes", "price": "0.50", "timestamp": 1782753357257 },
    { "token_id": "token-no", "price": "0.50", "timestamp": 1782753357257 }
  ]
}
```

Tokens that do not exist or are not currently visible are ignored. Returned items preserve the order of valid Tokens in the request.

Batch prices are also latest trade prices. If a visible Token has no usable trade, its `price` is `""` and `timestamp` is `null`.

## Price History

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/tokens/<token_id>/price_history?interval=1h&from=1782666000000&to=1782752400000"
```

| Parameter | Description |
| - | - |
| `interval` | `5m`, `15m`, `1h`, `4h`, `1d` |
| `from` | Start time, Unix milliseconds |
| `to` | End time, Unix milliseconds |

`interval`, `from`, and `to` are required. The maximum time range for one query is 14 days. In the response, `t` is Unix milliseconds and `p` is a decimal price string.

```json theme={null}
{
  "history": [
    { "t": 1782666000000, "p": "0.485" },
    { "t": 1782669600000, "p": "0.500" }
  ]
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.