# Prediction Market Scraper - Kalshi + Polymarket (`oddsmith/prediction-market-scraper`) Actor

Kalshi + Polymarket in one schema: live odds, prices, volume, open interest, full order-book depth, settled results for backtesting, and Kalshi candlestick history. Keyless public APIs, no browser. Targets the most actively traded markets by default, and never charges you for empty results.

- **URL**: https://apify.com/oddsmith/prediction-market-scraper.md
- **Developed by:** [oddsmith Data](https://apify.com/oddsmith) (community)
- **Categories:** Developer tools, Business, Agents
- **Stats:** 2 total users, 1 monthly users, 92.3% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.85 / 1,000 market records

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/actors/running/actors-in-store.md#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

## Prediction Market Scraper — Kalshi + Polymarket

Pull live and settled market data from **Kalshi** and **Polymarket** in one Actor: market listings, order-book depth snapshots, settled results for backtesting, and Kalshi candlestick history. Clean JSON or CSV output, no API keys required.

### What you get

| Mode | Returns |
|------|---------|
| **Markets** | Open/closed markets with prices, bids/asks, status, close times |
| **Order book snapshots** | Full bid/ask depth, best prices, and Polymarket microstructure fields (tick size, min order size, last trade, book timestamp) |
| **Settled markets** | Resolved markets with outcomes — ready for backtests |
| **Candlesticks** | Kalshi OHLC history per market at your chosen interval |

### Why this Actor

- **Two venues, one schema.** Kalshi and Polymarket return very different payloads; this normalizes both into consistent records you can join on.
- **Order-book depth, not just prices.** Most scrapers give you a last price. This captures the full book — the data you actually need for spread, liquidity, and microstructure analysis.
- **Active markets by default.** Kalshi's raw listing is dominated by internal shard markets with no trading activity. When you don't name specific tickers, this Actor filters those out and targets the markets with the most volume and open interest, so you get data worth paying for.
- **You are never charged for nothing.** Empty candle batches and empty order books are skipped, not billed.
- **No authentication.** Uses public market-data endpoints only.
- **Polite by default.** Built-in rate limiting with exponential backoff on 429 and 5xx.

### Example input

```json
{
  "mode": "orderbook",
  "venues": ["kalshi", "polymarket"],
  "seriesTicker": "KXBTC",
  "maxItems": 50,
  "orderbookDepth": 10
}
```

Settled markets for a backtest:

```json
{ "mode": "settled", "venues": ["kalshi"], "maxItems": 500 }
```

Kalshi candlesticks for specific markets:

```json
{
  "mode": "candlesticks",
  "tickers": ["KXBTC-26JUN1314-T72299.99"],
  "periodInterval": 60
}
```

### Output

Each result is one dataset item. Export as JSON, CSV, or Excel from the run's dataset. Order-book items include normalized `yes_levels`/`no_levels` (Kalshi) or `bids`/`asks` (Polymarket), each a list of `{price, size}`.

### Pricing

Pay per record delivered. No subscription, and no platform usage charge on top.

| Event | Price | What one record is |
|---|---|---|
| `market-item` | **$1.85 / 1,000** | One market with prices, volume, open interest, liquidity, close time |
| `settled-item` | **$0.50 / 1,000** | One resolved market with its outcome |
| `orderbook-snapshot` | **$2.00 / 1,000** | One order book with full bid/ask depth |
| `candlestick-batch` | **$3.00 / 1,000** | One market's OHLC history for the window |

**You are never charged for a record you cannot use.** Settled markets that
closed without a recorded outcome, order books with no levels, and candlestick
windows with no trades are all skipped before billing, not delivered and billed.

### Output

Fields the venue does not publish come back as `null` rather than being dropped,
so columns stay stable across runs. In particular `result` is `null` for every
market that is still open — that is the normal case, not an error.

### Notes

- Kalshi prices are in dollars (e.g. `0.76` = 76¢). Polymarket prices are 0–1 probabilities.
- Kalshi market records include `volume`, `volume_24h`, `open_interest`, and `liquidity` alongside best bid/ask and last price.
- Order books for illiquid markets may return empty depth — that is the true state of the book, not an error. Those results are skipped rather than charged.
- `closeWithinDays` (default 90) bounds Kalshi discovery to markets resolving inside that window. It controls scope: a 30-day window exposes about 200 Kalshi markets, 90 days about 10,000. Set `0` to remove the window entirely, but leave **Only markets that trade** on if you do, because Kalshi's unfiltered listing is mostly internal shard markets.
- `maxItems` (default 1,000) bounds markets scanned **per venue**, so a default two-venue run returns roughly 2,000 records.
- Built and maintained by an independent quant developer. Issues and requests welcome.

# Actor input Schema

## `mode` (type: `string`):

What to pull. 'markets' lists markets; 'orderbook' captures point-in-time depth; 'settled' returns resolved markets with results; 'candlesticks' returns Kalshi OHLC history.

## `venues` (type: `array`):

Which prediction markets to query.

## `status` (type: `string`):

Which markets to return in 'markets' mode: currently tradable (Open), no longer trading but not yet resolved (Closed), or resolved with a known result (Settled).

## `closeWithinDays` (type: `integer`):

Restricts Kalshi discovery to markets closing inside this window. This controls SCOPE: a 30-day window exposes about 200 Kalshi markets, a 90-day window about 10,000. Widen it for broader coverage, narrow it for markets resolving soon. Ignored when a series ticker is given. Setting 0 removes the window, but Kalshi's unfiltered listing is dominated by internal shard markets, so leave 'Only markets that trade' on if you do.

## `onlyTraded` (type: `boolean`):

Keep only markets with non-zero volume or open interest. On by default: it is what makes the results useful, and it also filters out the internal shard markets that pad Kalshi's raw listing. Turn off to get the complete listing including untraded markets.

## `seriesTicker` (type: `string`):

Restrict Kalshi results to one series, e.g. KXBTC, KXHIGHNY, KXMLBGAME. Leave blank for all.

## `tickers` (type: `array`):

Specific Kalshi tickers or Polymarket CLOB token ids to snapshot. If empty, targets are discovered from open markets.

## `maxItems` (type: `integer`):

Upper bound on markets SCANNED PER VENUE. Delivered results can be fewer, because billing guards drop anything you should not pay for: settled markets with no recorded outcome, order books with no levels, candlestick windows with no trades. You are never charged for those. With both venues selected the default scans up to 1,000 each.

## `orderbookDepth` (type: `integer`):

How many price levels to capture per side of the Kalshi order book. Higher values give deeper liquidity detail per snapshot.

## `startTs` (type: `integer`):

Start of the candlestick window, as a Unix timestamp in seconds. Defaults to 24 hours before the run.

## `endTs` (type: `integer`):

End of the candlestick window, as a Unix timestamp in seconds. Defaults to the run start time.

## `periodInterval` (type: `integer`):

Candle size in minutes (for example 1, 60, or 1440 for daily). Applies to candlesticks mode only.

## Actor input object example

```json
{
  "mode": "markets",
  "venues": [
    "kalshi",
    "polymarket"
  ],
  "status": "open",
  "closeWithinDays": 90,
  "onlyTraded": true,
  "tickers": [],
  "maxItems": 1000,
  "orderbookDepth": 10,
  "periodInterval": 60
}
```

# Actor output Schema

## `results` (type: `string`):

All records produced by this run, in the default dataset. Export as JSON, CSV or Excel.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("oddsmith/prediction-market-scraper").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("oddsmith/prediction-market-scraper").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 '{}' |
apify call oddsmith/prediction-market-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,oddsmith/prediction-market-scraper"
        }
    }
}

```

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/LrvtLru2WFT0ty6x1/builds/r7XLk1l4nGicUX324/openapi.json
