Polymarket Gamma API Historical Data: What It Can and Can't Do
Use the Polymarket Gamma API for market discovery and metadata, then pair it with historical order book snapshots when you need backtesting-ready data.
The Polymarket Gamma API historical data question usually comes from developers who can fetch markets from gamma-api.polymarket.com, but then need older prices, resolved outcomes, or full order book states for backtesting.
Short Answer
Use the Gamma API to discover markets, events, slugs, condition IDs, token IDs, tags, and resolution metadata. Do not rely on Gamma as a full historical order book archive. For strategy replay, fill simulation, spread history, and resolved market research, use archived snapshots from a historical data API such as PolyHistorical.
What Gamma Is Best For
- Finding active and closed markets by keyword, tag, volume, or liquidity
- Reading market metadata such as question, slug, close time, category, and outcome tokens
- Mapping a Polymarket market to CLOB token IDs before requesting live prices or books
- Building scanners that choose which markets to track or archive going forward
Where Gamma Falls Short for Historical Research
| Need | Gamma API | Historical snapshot API |
|---|---|---|
| Market discovery | ✓ | ✓ |
| Resolved market metadata | ✓ Basic metadata | ✓ Metadata plus archived depth |
| Past full order books | ✗ | ✓ Bid/ask ladders over time |
| Spread and slippage backtests | ✗ | ✓ Replayable snapshots |
| Sub-second market replay | ✗ | ✓ 300ms snapshots on supported markets |
Developer Workflow
A practical pipeline is to use Gamma for discovery, then fetch historical snapshots for the market once you know which slug or token IDs matter.
import requests
# 1. Discover closed Polymarket BTC markets from Gamma
gamma_markets = requests.get(
"https://gamma-api.polymarket.com/markets",
params={"closed": "true", "limit": 20, "search": "bitcoin up down"}
).json()
slug = gamma_markets[0]["slug"]
# 2. Fetch backtesting-ready order book history from PolyHistorical
snapshots = requests.get(
"https://api.polyhistorical.com/v1/markets/" + slug + "/snapshots",
params={"include_orderbook": True, "limit": 1000},
headers={"X-API-Key": "YOUR_API_KEY"}
).json()
print(slug, len(snapshots["snapshots"]))
When to Use Each Polymarket Data Surface
| Question | Use |
|---|---|
| What markets exist? | Polymarket Gamma API |
| What is the current order book? | Polymarket CLOB API |
| How did the book look before resolution? | PolyHistorical snapshots |
| Can my strategy survive real spreads and depth? | Historical full-depth snapshots |
| Can I download analysis data? | PolyHistorical API or bulk export |
Why This Keyword Matters
Developers often start with the Gamma API because it is public and easy to query. The missing step is realizing that market metadata is not the same thing as historical liquidity. If your backtest depends on fills, spread, queue depth, or market state near resolution, you need archived order book snapshots rather than only Gamma metadata.