Skip to content

Commit f445bd7

Browse files
committed
chore: merge main and refresh generated docs
2 parents b98e7d3 + f3cd6bb commit f445bd7

11 files changed

Lines changed: 582 additions & 1490 deletions

File tree

core/api-doc-config.generated.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"_generated": "Auto-generated by extract-jsdoc.js on 2026-06-08T07:59:06.055Z. Do not edit manually.",
2+
"_generated": "Auto-generated by extract-jsdoc.js on 2026-06-08T08:01:55.819Z. Do not edit manually.",
33
"methods": {
44
"has": {
55
"summary": "HTTP verb for the endpoint (e.g. GET, POST). */",

docs/api-reference/fetch-order-book.mdx

Lines changed: 66 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ openapi: GET /api/{exchange}/fetchOrderBook
77

88
### Live order book
99

10-
Fetch the current L2 order book for an outcome. If you already have an outcome token ID, pass it directly:
10+
Fetch the current L2 order book for an outcome from the exchange's live order book endpoint. For Polymarket this is a live CLOB call: pass the outcome token ID directly and omit historical params.
11+
12+
<Warning>
13+
`poly.fetch_order_book(token_id)` without `params.since` or `params.until` is live-only. It does not read PMXT Archive data and may fail for closed, resolved, or otherwise inactive Polymarket markets with an error such as `No orderbook exists`.
14+
</Warning>
1115

1216
<CodeGroup>
1317
```python Python
@@ -28,28 +32,25 @@ console.log(`${book.bids.length} bids, ${book.asks.length} asks`);
2832

2933
```bash curl
3034
curl "https://api.pmxt.dev/api/polymarket/fetchOrderBook?outcomeId=104932610032177696635191871147557737718087870958469629338467406422339967452218" \
31-
-H "Authorization: Bearer $PMXT_API_KEY"
35+
-H "Authorization: Bearer ***"
3236
```
3337
</CodeGroup>
3438

3539
### Historical snapshot
3640

37-
Get the order book at a specific point in time. Pass `since` as a Unix timestamp in milliseconds — returns the nearest snapshot at or before that time.
41+
Get the order book at a specific point in time by passing `since` as a Unix timestamp in milliseconds. Historical Polymarket queries are served from the PMXT Archive and return the nearest reconstructed snapshot at or before that time.
3842

39-
For binary markets, you can pass the market ID and choose the side with `params.outcome`. Use `"yes"` or `"no"` instead of copying the long outcome token ID:
43+
For binary markets, you can pass the Polymarket condition ID as the first argument and choose the side with `params.outcome`. Use `"yes"` or `"no"` instead of copying the long outcome token ID.
4044

4145
<CodeGroup>
4246
```python Python
4347
import pmxt
4448

4549
poly = pmxt.Polymarket(pmxt_api_key="pmxt_...")
4650

47-
market = poly.fetch_market(
48-
slug="will-spacex-starship-flight-test-12-launch-by-may-22-354-721"
49-
)
50-
51+
# Historical lookup against PMXT Archive, not the live CLOB.
5152
book = poly.fetch_order_book(
52-
market.market_id,
53+
"0xc704f74e2f9dfae70f770cb253ffadde10768eeab41233098bf5ac67995a94b5",
5354
params={"since": 1779487200000, "outcome": "yes"},
5455
)
5556

@@ -63,12 +64,9 @@ import { Polymarket } from "pmxtjs";
6364

6465
const poly = new Polymarket({ pmxtApiKey: "pmxt_..." });
6566

66-
const market = await poly.fetchMarket({
67-
slug: "will-spacex-starship-flight-test-12-launch-by-may-22-354-721",
68-
});
69-
67+
// Historical lookup against PMXT Archive, not the live CLOB.
7068
const book = await poly.fetchOrderBook(
71-
market.marketId,
69+
"0xc704f74e2f9dfae70f770cb253ffadde10768eeab41233098bf5ac67995a94b5",
7270
undefined,
7371
{ since: 1779487200000, outcome: "yes" }
7472
);
@@ -79,34 +77,75 @@ console.log(` best ask: ${Math.min(...book.asks.map((a) => a.price)).toFixed(3)
7977

8078
```bash curl
8179
curl -X POST "https://api.pmxt.dev/api/polymarket/fetchOrderBook" \
82-
-H "Authorization: Bearer $PMXT_API_KEY" \
80+
-H "Authorization: Bearer ***" \
81+
-H "Content-Type: application/json" \
82+
-d '{"args":["0xc704f74e2f9dfae70f770cb253ffadde10768eeab41233098bf5ac67995a94b5", null, {"since": 1779487200000, "outcome": "yes"}]}'
83+
```
84+
</CodeGroup>
85+
86+
### Historical crypto 5m events
87+
88+
Polymarket crypto 5-minute slugs such as `btc-updown-5m-1779481500` are event slugs. Use `fetch_event(slug=...)`, then select the nested market you want. Do not use `fetch_market(slug=...)` for these event-level slugs.
89+
90+
<CodeGroup>
91+
```python Python
92+
import pmxt
93+
94+
poly = pmxt.Polymarket(pmxt_api_key="pmxt_...")
95+
event = poly.fetch_event(slug="btc-updown-5m-1779481500")
96+
market = event.markets[0]
97+
98+
book = poly.fetch_order_book(
99+
market.market_id,
100+
params={"since": 1779487200000, "outcome": "yes"},
101+
)
102+
print(f"{market.title}: {book.dt}")
103+
```
104+
105+
```javascript JavaScript
106+
import { Polymarket } from "pmxtjs";
107+
108+
const poly = new Polymarket({ pmxtApiKey: "pmxt_..." });
109+
const event = await poly.fetchEvent({ slug: "btc-updown-5m-1779481500" });
110+
const market = event.markets[0];
111+
112+
const book = await poly.fetchOrderBook(
113+
market.marketId,
114+
undefined,
115+
{ since: 1779487200000, outcome: "yes" }
116+
);
117+
console.log(`${market.title}: ${book.datetime}`);
118+
```
119+
120+
```bash curl
121+
curl -X POST "https://api.pmxt.dev/api/polymarket/fetchEvent" \
122+
-H "Authorization: Bearer ***" \
83123
-H "Content-Type: application/json" \
84-
-d '{"args":["61b0ed20-7f42-41fd-af15-7b86153f6bb7", null, {"since": 1779487200000, "outcome": "yes"}]}'
124+
-d '{"kwargs":{"slug":"btc-updown-5m-1779481500"}}'
85125
```
86126
</CodeGroup>
87127

88128
### Historical range (reconstructed L2 books)
89129

90130
Pass both `since` and `until` to get an array of fully reconstructed L2 order book snapshots. Each snapshot is a complete book at that moment in time — not deltas.
91131

92-
Default 100 snapshots per request, max 1000.
132+
The API returns up to `limit` snapshots from the PMXT Archive. Defaults to 100 snapshots per request, max 1000. For raw bulk downloads, use the Parquet files in the [PMXT Archive](https://archive.pmxt.dev) instead of trying to stream bulk data through the live order book endpoint.
93133

94134
<CodeGroup>
95135
```python Python
96136
import pmxt
97137

98138
poly = pmxt.Polymarket(pmxt_api_key="pmxt_...")
99-
100-
market = poly.fetch_market(
101-
slug="will-spacex-starship-flight-test-12-launch-by-may-22-354-721"
102-
)
139+
event = poly.fetch_event(slug="btc-updown-5m-1779481500")
140+
market = event.markets[0]
103141

104142
books = poly.fetch_order_book(
105143
market.market_id,
106144
params={
107145
"since": 1779480000000,
108146
"until": 1779487200000,
109147
"outcome": "yes",
148+
"limit": 100,
110149
}
111150
)
112151
print(f"{len(books)} snapshots")
@@ -118,15 +157,13 @@ for ob in books[:3]:
118157
import { Polymarket } from "pmxtjs";
119158

120159
const poly = new Polymarket({ pmxtApiKey: "pmxt_..." });
121-
122-
const market = await poly.fetchMarket({
123-
slug: "will-spacex-starship-flight-test-12-launch-by-may-22-354-721",
124-
});
160+
const event = await poly.fetchEvent({ slug: "btc-updown-5m-1779481500" });
161+
const market = event.markets[0];
125162

126163
const books = await poly.fetchOrderBook(
127164
market.marketId,
128165
undefined,
129-
{ since: 1779480000000, until: 1779487200000, outcome: "yes" }
166+
{ since: 1779480000000, until: 1779487200000, outcome: "yes", limit: 100 }
130167
);
131168
console.log(`${books.length} snapshots`);
132169
books.slice(0, 3).forEach((ob) =>
@@ -136,12 +173,12 @@ books.slice(0, 3).forEach((ob) =>
136173

137174
```bash curl
138175
curl -X POST "https://api.pmxt.dev/api/polymarket/fetchOrderBook" \
139-
-H "Authorization: Bearer $PMXT_API_KEY" \
176+
-H "Authorization: Bearer ***" \
140177
-H "Content-Type: application/json" \
141-
-d '{"args":["61b0ed20-7f42-41fd-af15-7b86153f6bb7", null, {"since": 1779480000000, "until": 1779487200000, "outcome": "yes"}]}'
178+
-d '{"args":["0xc704f74e2f9dfae70f770cb253ffadde10768eeab41233098bf5ac67995a94b5", null, {"since": 1779480000000, "until": 1779487200000, "outcome": "yes", "limit": 100}]}'
142179
```
143180
</CodeGroup>
144181

145182
<Info>
146-
Historical order book data is backed by the [PMXT Archive](https://archive.pmxt.dev) — the same tick-level data available as Parquet files, but queryable directly from the API without downloading or parsing files. Supports Polymarket, Kalshi, Limitless, and Opinion.
183+
Historical order book data is backed by the [PMXT Archive](https://archive.pmxt.dev) — the same tick-level data available as Parquet files, but queryable directly from the API without downloading or parsing files. Historical `fetchOrderBook` supports Polymarket, Kalshi, Limitless, and Opinion.
147184
</Info>

0 commit comments

Comments
 (0)