# Polymarket API

Polymarket exchange mechanics, on-chain Polygon CTF, Gamma/CLOB/Data APIs, EIP-712...

- Repository: https://github.com/agiprolabs/claude-trading-skills (507 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-09-03
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add agiprolabs/claude-trading-skills --skill polymarket-api -g -a claude-code -y`
Codex: `npx skills add agiprolabs/claude-trading-skills --skill polymarket-api -g -a codex -y`
Cursor: `npx skills add agiprolabs/claude-trading-skills --skill polymarket-api -g -a cursor -y`
Gemini CLI: `npx skills add agiprolabs/claude-trading-skills --skill polymarket-api -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add agiprolabs/claude-trading-skills`

## Description

Polymarket exchange mechanics, on-chain Polygon CTF, Gamma/CLOB/Data APIs, EIP-712 auth, identifier model, WebSocket, settlement, and geo/KYC constraint

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Polymarket API

Polymarket is a **prediction market on Polygon mainnet**. Every market is a pair of YES/NO **ERC-1155** tokens issued by the Conditional Token Framework (CTF), collateralized 1:1 in USDC. Off-chain CLOB matching, on-chain settlement, **zero taker fees**. Prices are in [0.00, 1.00] USDC; YES + NO ≈ 1.0 per market.

---

> **Before you write any API code, read the live docs first.**
>
> - Docs: https://docs.polymarket.com
> - Official Python SDK: https://github.com/Polymarket/py-clob-client
>
> Polymarket endpoints and auth flows have changed without notice. Prefer the official `py-clob-client` SDK over hand-rolled HTTP; it handles EIP-712 derivation, API credential management, and order signing. Only hand-roll when the SDK doesn't expose what you need.

---

## Identifier model

You will juggle four distinct IDs, get them confused and queries silently return wrong data.

| ID | What it is |
|----|-----------|
| `condition_id` | On-chain hex ID of the market (the CTF condition) |
| `clob_token_ids` | The YES/NO **pair** of ERC-1155 token IDs, a two-element list |
| `token_id` | A **single** outcome token, what you pass to order-book and WebSocket queries |
| `event_id` | Parent grouping (e.g. all brackets for "NYC high today") |

---

## Quick Start

### 1. Read markets, Gamma API (no auth required)

```python
import httpx

# CRITICAL: default sort is OLDEST-first, always override or you silently get closed markets
events = httpx.get("https://gamma-api.polymarket.com/events", params={
    "tag_id": 103040,        # category tag (e.g. weather)
    "order": "endDate",
    "ascending": "false",    # must be string "false", not bool
    "closed": "false",
}).json()

The rest: https://github.com/agiprolabs/claude-trading-skills/blob/HEAD/skills/polymarket-api/SKILL.md
