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)