Skip to main content

Overview

Onchain order fills from Polymarket’s smart contracts. This data history goes back until 2022. This is generated from the OrderFilled event, since OrdersMatched loses information about all the parties the orders are matched with. Data is scraped from the CTFExchange contract as well as the NegRiskCTFExchange contract.

Columns

ColumnTypeDescription
block_numberintegerPolygon block number
block_timestampintegerBlock timestamp in milliseconds
sidestringTrade side: BUY or SELL
sizedecimalNumber of contracts filled
pricedecimalPrice
makerstringMaker address
takerstringTaker address

Fetching Data

Using Market Slug + Outcome

import requests

def download_onchain_fills(market_slug, outcome, date_str, api_key):
    url = f"https://datasets.predictiondata.dev/polymarket/onchain/fills/{market_slug}/{outcome}/{date_str}.csv.gz"
    params = {'slug': 'true', 'apikey': api_key}
    
    response = requests.get(url, params=params)
    response.raise_for_status()
    
    with open(f'{market_slug}_{outcome}_{date_str}_fills.csv.gz', 'wb') as f:
        f.write(response.content)
    
    print(f"Downloaded to {market_slug}_{outcome}_{date_str}_fills.csv.gz")

if __name__ == "__main__":
    api_key = "YOUR_API_KEY"
    market_slug = "ramp-ipo-in-2025"
    outcome = "YES"
    date_str = "2025-11-16"
    
    download_onchain_fills(market_slug, outcome, date_str, api_key)

Using Token ID

import requests

def download_onchain_fills_by_token(token_id, date_str, api_key):
    url = f"https://datasets.predictiondata.dev/polymarket/onchain/fills/{token_id}/{date_str}.csv.gz"
    params = {'apikey': api_key}
    
    response = requests.get(url, params=params)
    response.raise_for_status()
    
    with open(f'{token_id}_{date_str}_fills.csv.gz', 'wb') as f:
        f.write(response.content)
    
    print(f"Downloaded to {token_id}_{date_str}_fills.csv.gz")

if __name__ == "__main__":
    api_key = "YOUR_API_KEY"
    token_id = "6535996220481600525438454491949371553057652243233032166205012948847090204871"
    date_str = "2025-11-16"
    
    download_onchain_fills_by_token(token_id, date_str, api_key)

Notes

  • Date format: YYYY-MM-DD
  • No need to manage Polymarket’s frontend models (gamma) vs onchain CLOB token IDs
  • Prices automatically calculated for both USDC trades and outcome-outcome trades (YES vs NO)