Overview: From “Does Polymarket Have an API?” to a Live Analytics Dashboard
Polymarket absolutely has an API—several, in fact—and you can use them today to power a production‑grade prediction market analytics dashboard.
This tutorial walks product and engineering teams through:
- How Polymarket’s APIs are structured (Gamma, CLOB, Data, WebSockets)
- How to fetch Polymarket data API endpoints in a sane, scalable way
- How to normalize Gamma API Polymarket feeds for analytics
- How to expose insight‑ready metrics to frontend teams
- Where Codex’s prediction market API fits in as a normalization layer
It’s designed as a step‑by‑step implementation guide you can follow or hand to an AI assistant, one step at a time.
For deeper conceptual context and API comparisons, see the related pillar article: “Prediction Market APIs Deep Dive: Polymarket Data, Gamma API and Analytics.”
Prerequisites
Before you start integrating Polymarket’s APIs into your analytics stack, make sure you have:
- A backend environment (Node.js, Python, Go, etc.) with HTTP and WebSocket client libraries
- A database or warehouse for analytics (Postgres, ClickHouse, BigQuery, Snowflake, etc.)
- Basic familiarity with REST APIs and JSON
- Optional but recommended: access to Codex’s Growth or Enterprise plan for prediction market endpoints
We’ll assume you’re building a dashboard that shows:
- Market discovery lists (e.g., “Top 2026 predictions”)
- Per‑market analytics (liquidity, volume, open interest, price history)
- Trader analytics (volume, P&L, win rates)
- Real‑time price and order book updates
Step 1: Understand Polymarket’s API Surfaces
Polymarket’s answer to “does Polymarket have an API?” is: yes, multiple APIs, each for a specific job.
Polymarket’s docs describe four main surfaces:
-
Gamma API (Discovery & Metadata)
- Use for events and markets: titles, descriptions, categories, liquidity, volume, open interest.
- Rate limits: general Gamma up to 4,000 requests / 10s, with tighter caps on
/eventsand/markets.
-
CLOB API (Market State & Trading)
- Central limit order book (CLOB V2, live since April 28, 2026 with pUSD collateral).
- Endpoints for books, prices history, last trade prices, and trading operations like
POST /order. - Example limit:
/bookat 1,500 requests / 10s,/prices-historyat 1,000 requests / 10s.
-
Data API (Activity & Positions)
- Trades, positions, account stats, and participation metrics.
- Rate limits: core surface 1,000 requests / 10s with sub‑limits, e.g.
/tradesat 200 / 10s,/positionsat 150 / 10s.
-
WebSockets & RTDS (Realtime Feeds)
- Public market WebSocket for order books and lifecycle updates.
- User WebSocket for authenticated order/trade updates.
- RTDS streams for reference prices, comments, trade activity.
Polymarket recommends a clear workflow:
- Discover Markets → Market Details → Prices and Order Books → Real‑Time Data.
We’ll follow that sequence in the next steps.
Step 2: Plan Your Analytics Data Model
Before hitting the APIs, design the data model your dashboard needs. You want analytics‑friendly tables, not raw JSON.
Core entities
At minimum, define:
-
Events
- Fields:
event_id,title,category,start_time,end_time,status,neg_risk_group,comment_count.
- Fields:
-
Markets
- Fields from Gamma market objects:
market_id,event_id,question,outcomes,liquidity,volume_24h,volume_1w,volume_1m,volume_1y,open_interest,competitive_score,amm_liquidity,clob_liquidity.
- Fields from Gamma market objects:
-
Outcome Prices & Order Book Snapshots
market_id,outcome_id,price,timestamp,bid_volume,ask_volume,spread.
-
Trades
trade_id,market_id,outcome_id,side,size,price,timestamp,trader_id.
-
Trader Stats
- Per trader:
trader_id,volume_7d,maker_volume_7d,taker_volume_7d,share_of_volume_7d,win_rate,pnl,positions_count.
- Per trader:
Why normalization matters
Polymarket’s events and markets include many dashboard‑friendly fields (liquidity, volume windows, competitive score), but:
- Field names differ between Gamma, CLOB, and Data APIs.
- Windows vary (Gamma exposes 24h/1w/1m/1y volume; account stats expose 7‑day windows cached by UTC day and lagging up to 24 hours).
- Time filters and pagination differ per endpoint.
Clean tables let you:
- Compute market ranking and trending lists quickly.
- Generate per‑venue, per‑category, and per‑time‑window stats.
- Feed frontends with predictable schemas.
If you use Codex, you can shortcut much of this modeling by adopting Codex’s unified GraphQL objects (PredictionEvent, PredictionMarket, PredictionTraderStats, etc.).
Step 3: Fetch Discovery Data from Gamma API
First, ingest Polymarket’s catalog of events and markets.
3.1. List events
Use the Gamma /events endpoint to pull event‑level metadata.
Basic pattern:
GET https://api.polymarket.com/gamma/events?status=active&limit=100&offset=0
Map the response into your events table:
id→event_idtitle→titlecategoryandsubcategory→ category fieldsstartDate/endDate→start_time,end_timeisNegRiskGroup→neg_risk_groupcommentsCount→comment_count- Liquidity and volume fields → event‑level aggregates
Use pagination (limit, offset) or cursors depending on the docs.
3.2. List markets
Next, hit the Gamma /markets endpoint or event‑scoped market lists.
Example:
GET https://api.polymarket.com/gamma/markets?status=active&limit=100&offset=0
Normalize key fields:
id→market_ideventId→event_idquestion/ label fields →questionoutcomesarray → outcome table(s)liquidity,openInterest→ numeric metricsvolume24h,volume1w,volume1m,volume1y→ windowed volume fieldscompetitiveScore→ ranking metricammLiquidity,clobLiquidity→ liquidity breakdown
3.3. Respecting rate limits
Gamma rate limits from the docs:
- General Gamma: 4,000 requests / 10s
/events: 500 / 10s/markets: 300 / 10s
Production ingestion strategy:
- Use batch jobs (e.g., every 5–15 minutes) instead of hammering endpoints.
- Cache responses and track
updatedAtor lifecycle fields to detect changes. - Implement exponential backoff and retry for HTTP 429.
Optional: Unified discovery via Codex
Codex’s filterPredictionMarkets and eventScopedFilterPredictionMarkets endpoints expose Polymarket markets through a single GraphQL query.
Advantages:
- Already normalized across Polymarket and Kalshi.
- Event‑scoped call returns structured entrant/segment/ladder metadata without parsing labels client‑side.
- Helps if you plan to support multiple venues or want chart‑ready stats directly.
Step 4: Pull Prices and Order Books from CLOB API
Once you have events and markets, you need live pricing data for your dashboard.
Polymarket recommends using the CLOB market data endpoints.
4.1. Last trade prices (for lists and watchlists)
For market lists and portfolio overviews, use Polymarket’s “last trade prices” endpoint.
Key features:
- Supports up to 500 token IDs per call, ideal for homepage lists or watchlists.
- Returns latest execution prices for each outcome/token.
Workflow:
- Persist Polymarket token IDs for each outcome in your schema.
- Batch up to 500 IDs per request.
- Map response prices to
market_id/outcome_idrows.
4.2. Order books (for depth & spread)
Use the /book endpoint from the CLOB API.
- Rate limit: 1,500 requests / 10s.
- Returns bid/ask ladders for each outcome.
Normalize fields into an order_book_snapshots table:
market_id,outcome_idtimestamp(snapshot time)- Aggregated
best_bid,best_ask,bid_size,ask_size - Computed
spreadand depth metrics
4.3. Price history (for charts)
Use /prices-history for OHLC‑style charts.
- Rate limit: 1,000 requests / 10s.
- Request parameters typically include time window, resolution, and token/market identifiers.
Store results in a price_candles table:
market_id,outcome_id,bucket_start,bucket_endopen,high,low,close,volume
These will back line charts, candles, and volume bars.
Optional: Order books via Codex
Codex’s predictionOutcomeOrderBooks abstracts away some complexity:
- Fetches live books from Polymarket’s CLOB.
- Cached up to 10 seconds for “realtime‑ish” dashboards without hitting source endpoints heavily.
- Normalized format across venues.
For high‑traffic consumer frontends, delegating book fetching to Codex can reduce complexity and rate‑limit risk.
Step 5: Capture Trades and Positions via Data API
Analytics dashboards need more than prices—they need activity.
Polymarket’s Data API gives you trades, positions, and account stats.
5.1. Market‑scoped trades
Use the market or event‑scoped trades endpoint.
Docs note:
- Default history window is roughly the most recent 3 years for market/event‑scoped requests.
- Full history may only be available in some user‑scoped cases.
Ingestion tips:
- Pull recent trades (e.g., last 24h, 7d) on a rolling schedule.
- Persist
trade_idto avoid duplicates. - Populate your
tradestable to power:- Volume over time charts
- Trade count metrics
- Heat maps of activity per category
5.2. Positions per user
For portfolio views or trader analytics, use the /positions endpoint.
- Rate limit: 150 requests / 10s.
Normalize into a positions table:
trader_id(user account)market_id,outcome_idsize,average_entry_priceunrealized_pnl
5.3. Account stats
Polymarket’s account stats endpoint exposes:
- 7‑day maker/taker volume
- Share of venue volume and other summary metrics
Docs highlight:
- Stats are cached by UTC day.
- Can be stale by up to 24 hours.
Use these metrics for:
- Trader leaderboards (volume, share of volume, maker/taker balance)
- Segmentation (heavy vs casual traders)
Optional: Trader analytics via Codex
Codex provides prediction‑specific analytics endpoints like detailedPredictionMarketStats and trader recipes.
detailedPredictionMarketStats exposes windowed stats for:
- 5m, 1h, 4h, 12h, 1d, 1w, plus all‑time.
- Includes trending, relevance, and competitive scores.
This can save you from writing custom aggregation jobs, especially across multiple venues.
Step 6: Add Real‑Time Streaming with WebSockets
Polling is expensive and slow. Polymarket’s WebSockets and RTDS streams are built for production dashboards.
6.1. Public market WebSocket
Use the public market WebSocket channel for:
- Order book updates (bids, asks, trades)
- Price changes
- Market lifecycle events (open, resolve, pause)
Implementation pattern:
- Backend subscriber connects to WebSocket.
- Normalizes messages into in‑memory state and/or a fast store (Redis, in‑memory cache).
- Frontend fetches near‑real‑time snapshots via HTTP from your backend.
6.2. User WebSocket
For signed‑in traders, use the user WebSocket:
- Authenticated channel for orders, fills, cancels.
- Powers “My orders” and live portfolio updates.
6.3. RTDS streams
RTDS is useful for:
- Reference prices
- Comments and social activity
- Trade activity streams
Design considerations:
- Separate ingestion workers for WebSockets vs REST.
- Backpressure and reconnection logic.
- Message deduplication and sequence tracking.
Codex’s caching on order books and market stats can complement this by reducing direct WebSocket load in some architectures.
Step 7: Normalize and Aggregate into Insight‑Ready Metrics
With raw data flowing in, you need analytics‑grade metrics.
Focus on three layers:
-
Normalization layer
- Ensure consistent types, units, and IDs across Gamma, CLOB, and Data.
- Example: unify timestamps to UTC, prices to pUSD, consistent
market_idforeign keys.
-
Aggregation layer
- Daily/hourly market volume, liquidity, and price changes.
- Trader‑level metrics (7d volume, win rate, realized P&L).
- Category‑level stats (e.g., Economy vs Finance vs 2026 Predictions).
-
Feature layer for frontend
- Pre‑computed ranked lists: “Top volume 24h,” “Trending this week,” “Highest competitive score.”
- Time‑windowed stats: 5m, 1h, 4h, 12h, 1d, 1w, all‑time.
This is where Codex’s unified prediction market API often replaces custom ETL:
- Codex ingests and enriches Polymarket and Kalshi events, markets, trades.
- Exposes windowed stats, trending scores, relevance, and competitive metrics out of the box.
- Lets you focus on ranking logic and UX instead of pipelines.
If you build in‑house, consider materialized views or scheduled jobs (e.g., via Airflow) to update metrics on predictable intervals.
Step 8: Expose Metrics to Frontend Teams
Frontend teams care about consistent, low‑latency APIs—not your ETL nightmares.
Design a clean, frontend‑facing API that abstracts Polymarket’s complexity.
8.1. Market list endpoints
Expose an endpoint like:
GET /api/markets?category=2026-predictions&sort=volume_24h&limit=50
Response should include:
market_id,question,event_title,category- Latest outcome prices
liquidity,open_interestvolume_24h,volume_1w,competitive_score- Trending and relevance scores (from your aggregations or Codex)
8.2. Market detail endpoint
For a single‑market view:
GET /api/markets/:market_id
Include:
- Event and market metadata
- Outcome prices and order book summary
- Price history (candles) for charts
- Liquidity breakdown (AMM vs CLOB)
- Recent trades and volume trends
Codex’s predictionMarketPrice endpoint is specifically optimized for single‑market drill‑down views if you want to offload some of this work.
8.3. Trader analytics endpoints
For leaderboards and profiles:
GET /api/traders/:trader_id/stats
GET /api/traders/leaderboard?window=7d&metric=volume
Return:
- 7d volume, maker/taker split
- Win rate and realized P&L
- Positions count and concentration
Codex’s trader recipes can help you implement these faster with standardized metrics.
8.4. Performance and caching
Frontend‑facing APIs should:
- Hit your pre‑aggregated tables, not raw Polymarket endpoints.
- Use caching (Redis, CDN) for list endpoints.
- Only call live pricing/order book endpoints when needed, possibly via Codex’s cached graphs.
This architecture keeps latency low and prevents rate‑limit issues.
Step 9: Benchmark, Harden, and Scale
Before calling your dashboard “production‑ready,” run through:
9.1. Load testing and rate‑limit safety
- Simulate peak traffic and confirm your backend isn’t directly burst‑hitting Polymarket’s stricter endpoints (e.g.,
/tradesat 200 / 10s,/positionsat 150 / 10s). - Ensure bulk requests (e.g., last trade prices for up to 500 token IDs) are batched sensibly.
9.2. Monitoring and alerting
- Track error rates per Polymarket endpoint.
- Add alerts for rising HTTP 429 or 5xx responses.
- Monitor latency and cache hit ratios.
9.3. Schema evolution and venue expansions
Prediction market infrastructure is evolving fast:
- Polymarket’s CLOB V2 and pUSD cutover show that surfaces can change significantly.
- Kalshi and other venues expose REST, WebSocket, and FIX interfaces.
Codex’s cross‑venue normalization (Polymarket + Kalshi today) can buffer you from future schema shifts and let you add new venues behind the same GraphQL model.
FAQ: Polymarket APIs and Prediction Market Analytics
Q1: Does Polymarket have an API for public market data?
Yes. Polymarket exposes public market data across multiple APIs:
- Gamma API for events and markets (metadata, liquidity, volume, open interest).
- CLOB market data endpoints for prices, order books, and price history.
- Data API for trades, positions, and account stats.
Public market data is available without credentials according to Polymarket’s docs.
Q2: What’s the best way to fetch Polymarket market data for an analytics dashboard?
Follow Polymarket’s recommended workflow:
- Use Gamma for discovery and metadata (
/events,/markets). - Use CLOB for live prices and order books (
/book,last trade prices,/prices-history). - Use Data API for trades and positions.
For production dashboards, combine REST with WebSocket subscriptions for realtime updates and cache results to avoid rate‑limit issues.
Q3: How do I normalize Gamma API Polymarket feeds?
Normalize around a clear schema:
- Use
event_idandmarket_idas canonical keys. - Map Gamma fields like
liquidity,openInterest,volume24h,volume1winto numeric columns. - Standardize timestamps to UTC and prices to pUSD.
You can either build this layer in‑house (ETL pipelines, materialized views) or use Codex, which exposes a normalized prediction‑market model for Polymarket and Kalshi out of the box.
Q4: How can I expose insight‑ready prediction market metrics to frontend teams?
Wrap your normalized data in frontend‑friendly APIs:
- Market list endpoints with latest prices, liquidity, and volume windows.
- Market detail endpoints with price history, order book summary, and recent trades.
- Trader analytics endpoints with 7‑day volume, win rate, and P&L.
Pre‑compute rankings and trending scores so frontend teams can render rich dashboards from simple, low‑latency JSON responses.
Q5: When should I use Codex instead of hitting Polymarket directly?
Codex is useful when you:
- Need cross‑venue coverage (Polymarket + Kalshi) with one API.
- Don’t want to maintain indexers, ETL pipelines, and normalization logic.
- Need trading‑grade speed and reliability for high‑traffic apps.
Codex exposes enriched, windowed metrics (5m to all‑time) and cached order books, letting you ship prediction‑aware features faster while offloading most of the data engineering.
By following these nine steps—and leaning on Codex where it makes sense—you can turn “does Polymarket have an API?” into a concrete, production‑ready analytics dashboard that supports traders, analysts, and product teams at scale.
