# Polymarket CLOB Order Book Scraper (`data_dino/polymarket-order-book`) Actor

💰 $1.00 per 1000 comments❗Collect real-time Polymarket CLOB order book data for one or more market outcome token IDs — full bid/ask depth, hashes, and timestamps.

- **URL**: https://apify.com/data\_dino/polymarket-order-book.md
- **Developed by:** [Data Dino](https://apify.com/data_dino) (community)
- **Categories:** Developer tools, Automation, News
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Polymarket CLOB Order Book Scraper

Collect full depth-of-book data from the Polymarket Central Limit Order Book (CLOB) API for one or more market-outcome token IDs. This Apify actor returns every bid and ask at every price level — not just the top-of-book best bid/ask — along with order book metadata, a deterministic content hash, and an execution timestamp.

It is the only Apify actor that surfaces complete CLOB order book depth. It is built for quants, market makers, prediction-market researchers, and data engineers who already know which token IDs they care about and want precision data without per-result charges.

### Why use this actor?

- **Full order book depth — not just the top** — every bid and ask at every price level, returned as structured arrays of `{price, size}`. No other Polymarket actor on Apify provides this data.
- **Free and open source** — no per-result pricing, no result caps, no trial limits. Use it for research, analytics, or production pipelines without a usage meter.
- **Deterministic content hash** — every output record includes a SHA-256 hash of the canonical order book JSON, computed using the same ordering logic as Polymarket's own `OrderBookSummary.dumps()`. Verify data integrity or detect changes without re-parsing the full depth.
- **Token-ID-native workflow** — works directly with Polymarket's core identifier. Input a token ID, get its order book. No market discovery, no category browsing, no noise.
- **CLOB metadata** — `tick_size`, `min_order_size`, and `neg_risk` are included in every record, giving you the trading parameters that govern the market.
- **HTTP/2 transport** — efficient API communication with the Polymarket CLOB REST endpoint.
- **Adaptive concurrency** — processes multiple token IDs in parallel with cgroup-aware memory management, adjusting throughput to the available resources.
- **Consistent dataset output** — every record follows the same predictable top-level structure, making it straightforward to ingest into downstream pipelines.

### What you can collect

Each output record includes the following fields from the Polymarket CLOB `/book` endpoint:

| Category | Fields |
|---|---|
| Market identity | `market` (hex market address), `asset_id` (token ID) |
| Order book depth | `bids[]` (array of `{price, size}` at every price level), `asks[]` (array of `{price, size}` at every price level) |
| Trading parameters | `tick_size`, `min_order_size`, `neg_risk` |
| Price reference | `last_trade_price` (null when no trades exist) |
| Data integrity | `hash` (SHA-256 of canonical order book JSON) |
| Temporal | `timestamp` (Unix milliseconds as a string) |

### Input

Provide one or more Polymarket CLOB token IDs in `tokenIds`. The field is required. An optional `host` override lets you point at a different CLOB API endpoint.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `tokenIds` | Array of strings | Yes | — | One or more Polymarket CLOB outcome token IDs. Each token ID is a long numeric string identifying a specific market outcome. |
| `host` | String | No | `https://clob.polymarket.com` | Override the CLOB API host URL. |

#### Example input

```json
{
  "tokenIds": [
    "78433024518676680431174478322854148606578065650008220678402966840627347604025"
  ]
}
```

To collect order books for multiple outcomes in a single run, add more token IDs to the array:

```json
{
  "tokenIds": [
    "78433024518676680431174478322854148606578065650008220678402966840627347604025",
    "12345678901234567890123456789012345678901234567890123456789012345678901234"
  ]
}
```

Token IDs can be obtained from market-discovery actors that surface `token_yes` / `token_no` fields, or directly from the Polymarket CLOB API.

### Output

The actor pushes one dataset item for each successfully retrieved order book. A representative result looks like this:

```json
{
  "market": "0x384e2707bbb95da4bfa6f330fe7d5ccbec1c0a85e20be900cbf599987588e1a4",
  "asset_id": "78433024518676680431174478322854148606578065650008220678402966840627347604025",
  "timestamp": "1786095435937",
  "hash": "9439526444ec82ddfca74965d5668a024c7e4ba1a3fe9e084ceb0f78b7c8303b",
  "bids": [
    { "price": "0.01", "size": "1111" },
    { "price": "0.02", "size": "6.12" },
    { "price": "0.03", "size": "120" }
  ],
  "asks": [
    { "price": "0.99", "size": "40006.78" },
    { "price": "0.97", "size": "4000" },
    { "price": "0.96", "size": "8.1" }
  ],
  "min_order_size": "5",
  "tick_size": "0.01",
  "neg_risk": false,
  "last_trade_price": "0.110"
}
```

The example is abbreviated. A real order book can contain many more price levels on each side. `last_trade_price` is `null` when no trades have occurred. The `hash` field is always present and reflects the full canonical order book, not a truncated view.

### Built for practical workflows

- **Market making and HFT signal pipelines** — consume full depth to build or calibrate pricing models.
- **Liquidity monitoring** — track bid/ask depth changes across tokens over time with scheduled runs.
- **Data integrity verification** — use the deterministic `hash` to confirm data hasn't been altered in transit or storage.
- **Prediction-market research** — collect order book snapshots for academic or industry analysis of prediction-market microstructure.
- **Arbitrage scanning** — pair with cross-platform price feeds to identify discrepancies between Polymarket CLOB pricing and other venues.
- **Complementary discovery workflow** — use a market-discovery actor to find token IDs, then feed them into this actor for depth. The `token_yes` and `token_no` fields from market-level scrapers map directly to the `tokenIds` input here.

### How to run

1. Open the actor in Apify.
2. Add one or more Polymarket CLOB token IDs to `tokenIds`.
3. Optionally override the `host` if you need a different CLOB API endpoint.
4. Start the run.
5. Review the dataset or export it as JSON, CSV, Excel, or another supported format.

### Important limitations

- **No market discovery** — this actor requires token IDs as input. It cannot search markets by keyword, browse categories, or filter by volume. Pair it with a market-discovery scraper if you need to find token IDs first.
- **No market context** — the output does not include event titles, market questions, descriptions, categories, images, or resolution criteria. It returns raw CLOB data only.
- **No volume or liquidity aggregation** — the actor does not compute or return total volume, 24-hour volume, or liquidity metrics. Those fields are available from market-level scrapers.
- **Sequential token-ID calls** — each token ID results in a separate `/book` API call. Very large batches may take proportionally longer.
- **No WebSocket streaming** — this is a snapshot actor, not a real-time stream. Each run captures the order book state at the time of the API call.
- **Public API only** — the actor uses Polymarket's public CLOB REST endpoint. No authentication or account-level data is involved.

The actor is read-only and uses only the public Polymarket CLOB API. Use the collected information in accordance with Polymarket's terms of service and your organization's data-use policies.

# Actor input Schema

## `tokenIds` (type: `array`):

One or more Polymarket CLOB token IDs for market outcomes. Each token ID is a unique numeric identifier for a specific market outcome (e.g., 78433024518676680431174478322854148606578065650008220678402966840627347604025).

## `host` (type: `string`):

Override the Polymarket CLOB API host URL. Defaults to https://clob.polymarket.com.

## Actor input object example

```json
{
  "tokenIds": [
    "78433024518676680431174478322854148606578065650008220678402966840627347604025"
  ],
  "host": "https://clob.polymarket.com"
}
```

# Actor output Schema

## `dataset` (type: `string`):

Structured Polymarket CLOB order book records collected during the run. Each record includes bids, asks, market info, timestamp, and a deterministic content hash.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "tokenIds": [
        "78433024518676680431174478322854148606578065650008220678402966840627347604025"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("data_dino/polymarket-order-book").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "tokenIds": ["78433024518676680431174478322854148606578065650008220678402966840627347604025"] }

# Run the Actor and wait for it to finish
run = client.actor("data_dino/polymarket-order-book").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "tokenIds": [
    "78433024518676680431174478322854148606578065650008220678402966840627347604025"
  ]
}' |
apify call data_dino/polymarket-order-book --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data_dino/polymarket-order-book"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/T2F6agRoioj6wDaaf/builds/S2TmOQeQJMTHaugW9/openapi.json
