# 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, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.30 / 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-event: you are charged per item delivered (one event per market, snapshot, or candle batch). No subscription, no charge for empty runs.

### 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 30) bounds Kalshi discovery to markets resolving inside that window. Set it to `0` if you genuinely want the full unfiltered listing.
- 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 is a quality filter: Kalshi's unfiltered listing is dominated by internal shard markets with no trading activity, and the close-time window removes them. Ignored when a series ticker is given. Set 0 to disable and return everything.

## `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 results. For 'markets'/'settled' this bounds items returned directly. For 'orderbook'/'candlesticks' with self-discovered targets, this bounds how many candidate markets are scanned, not how many snapshots/batches are delivered -- billing guards skip candidates with no book or no trades, so a thin market in the scanned slice yields fewer paid results than requested.

## `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": 30,
  "tickers": [],
  "maxItems": 100,
  "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/sfDD0r6n2gmVr3HKK/openapi.json
