Polymarket API in Python - odds, volume and order books to CSV without writing a scraper
Polymarket prices are probabilities: a YES share at $0.69 means the market gives the event about a 69% chance. That makes them handy for dashboards, newsletters, research and model features. Polymarket's own APIs are public and free: the Gamma API for markets and events, the CLOB API for order books and price history, and a Data API for trades. If you're writing a trading bot, use them directly.…
Polymarket offers probabilities for events as odds, which can be used in various applications such as dashboards, newsletters, research, and model features. They provide APIs for markets, events, order books, and price history, as well as trades data. When fetching data directly from the APIs, outcomes, outcomePrices, and clobTokenIds are returned as JSON strings nested within JSON and require an additional parsing step.
The endpoint limits the number of markets per page to 100, necessitating pagination. There is no server-side search functionality on /markets, and sorting top markets by volume through /events does not yield market rankings but rather events, causing small side-markets of popular events to potentially appear higher in the list. The API consolidates data into a single record per market, making it easier to import into a CSV file.
The required Python libraries include csv, os, and requests. After running the script, a CSV file named polymarket.csv is generated, containing fields such as question, yes_probability, volume_24h, liquidity, closes, and url. For instance, on 2026-09-18, the CSV includes entries like "Will the price of Bitcoin be above $76,000 on September 18?" with a 98.9% yes probability, "Will the price of Bitcoin be above $72,000 on September 18?" with a 100% yes probability, and "Will Bitcoin reach $80,000 in September?" without specifying search criteria, resulting in the 100 most traded open markets sorted by 24-hour volume.
Each record in the CSV includes details like the question, outcomes (names and their respective prices and implied probabilities), yesPrice and noPrice, impliedProbability, volume, volume_24h, liquidity, bestBid and bestAsk, spread, lastTradePrice, closeTime, status, result, eventTitle, and tags.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.