Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
agentmc15 avatar

Polymarket Api

  • 937 installs
  • 24 repo stars
  • Updated July 31, 2026
  • agentmc15/polymarket-trader

Polymarket API is a Claude Code skill that integrates Polymarket CLOB and Gamma APIs with on-chain position tracking for developers who build trading agents or prediction-market data tools.

About

Polymarket API is a deep integration skill from the polymarket-trader repository covering Polymarket’s Central Limit Order Book API at https://clob.polymarket.com, the Gamma API for market metadata, and on-chain data reads for positions. Authentication is tiered: Level 0 public market data and orderbooks, Level 1 signer key derivation, and Level 2 authenticated trading with orders and positions. Endpoint guidance includes GET /markets and related trading routes with patterns for reliable market data fetching, order placement, and wallet-linked position tracking in agent code. Reach for Polymarket API when wiring a Rust, TypeScript, or Python bot to prediction markets, backfilling orderbook history, or hardening error handling around CLOB rate limits and signatures. Assumes crypto wallet and API key hygiene; not investment advice.

  • Complete CLOB API reference with public, signer, and authenticated endpoints
  • Gamma API patterns for events, markets, and metadata retrieval
  • Python client initialization using py_clob_client with full order lifecycle examples
  • Authentication level guidance covering Level 0 public data through Level 2 trading
  • On-chain data patterns for smart contract interaction and position management

Polymarket Api by the numbers

  • 937 all-time installs (skills.sh)
  • +2 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #417 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/agentmc15/polymarket-trader --skill polymarket-api

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs937
repo stars24
Security audit2 / 3 scanners passed
Last updatedJuly 31, 2026
Repositoryagentmc15/polymarket-trader

How do you integrate Polymarket CLOB API for trading?

Add reliable Polymarket market data fetching, order placement, and on-chain position tracking to their trading agents or prediction-market tools.

Who is it for?

Developers building prediction-market bots, analytics dashboards, or agent tooling against Polymarket CLOB and Gamma endpoints.

Skip if: Skip Polymarket API when you need generic DEX swap integrations unrelated to Polymarket’s CLOB or Gamma market APIs.

When should I use this skill?

The user mentions Polymarket API, CLOB orders, Gamma markets, prediction market trading, or on-chain position tracking.

What you get

CLOB and Gamma API client code, authenticated order flows, and on-chain position tracking modules.

  • API integration code
  • Order placement flows
  • Position tracking logic

By the numbers

  • Documents three CLOB authentication levels from public through authenticated trading
  • CLOB base URL https://clob.polymarket.com with GET /markets endpoint

Files

SKILL.mdMarkdownGitHub ↗

Polymarket API Integration Skill

Overview

This skill provides comprehensive guidance for integrating with Polymarket's APIs and smart contracts.

API Endpoints

CLOB API (Central Limit Order Book)

Base URL: https://clob.polymarket.com

Authentication Levels
  • Level 0 (Public): Market data, orderbooks, prices
  • Level 1 (Signer): Create/derive API keys
  • Level 2 (Authenticated): Trading, orders, positions
Key Endpoints
GET  /markets              # List all markets
GET  /markets/{token_id}   # Get specific market
GET  /price?token_id=X     # Get current price
GET  /midpoint?token_id=X  # Get midpoint price
GET  /book?token_id=X      # Get orderbook
GET  /trades               # Get user trades
POST /order                # Place order
DELETE /order/{id}         # Cancel order
GET  /positions            # Get positions

Gamma API (Market Metadata)

Base URL: https://gamma-api.polymarket.com

GET /events              # List events
GET /events/{slug}       # Get event details
GET /markets             # List markets
GET /markets/{id}        # Get market details

Python Implementation Patterns

Initialize Client

from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs, OrderType
import os

class PolymarketService:
    def __init__(self):
        self.client = ClobClient(
            host="https://clob.polymarket.com",
            key=os.getenv("POLYMARKET_PRIVATE_KEY"),
            chain_id=137,
            signature_type=1,
            funder=os.getenv("POLYMARKET_FUNDER_ADDRESS")
        )
        self.client.set_api_creds(
            self.client.create_or_derive_api_creds()
        )
    
    async def get_market_data(self, token_id: str) -> dict:
        """Fetch comprehensive market data."""
        return {
            "price": self.client.get_price(token_id, "BUY"),
            "midpoint": self.client.get_midpoint(token_id),
            "book": self.client.get_order_book(token_id),
            "spread": self.client.get_spread(token_id),
        }
    
    async def place_order(
        self,
        token_id: str,
        side: str,
        price: float,
        size: float,
        order_type: str = "GTC"
    ) -> dict:
        """Place a limit order."""
        order = self.client.create_order(
            OrderArgs(
                token_id=token_id,
                price=price,
                size=size,
                side=side,
            )
        )
        return self.client.post_order(order, order_type)

WebSocket Subscription

import asyncio
import websockets
import json

async def subscribe_market_updates(token_ids: list[str]):
    """Subscribe to real-time market updates."""
    uri = "wss://ws-subscriptions-clob.polymarket.com/ws/market"
    
    async with websockets.connect(uri) as ws:
        await ws.send(json.dumps({
            "type": "subscribe",
            "markets": token_ids
        }))
        
        async for message in ws:
            data = json.loads(message)
            yield data

Gamma API Client

import httpx

class GammaClient:
    BASE_URL = "https://gamma-api.polymarket.com"
    
    def __init__(self):
        self.client = httpx.AsyncClient(base_url=self.BASE_URL)
    
    async def get_active_markets(self) -> list[dict]:
        """Fetch all active markets."""
        response = await self.client.get("/markets", params={"active": True})
        return response.json()
    
    async def get_event(self, slug: str) -> dict:
        """Fetch event with all markets."""
        response = await self.client.get(f"/events/{slug}")
        return response.json()

Order Types

  • GTC (Good Till Cancelled): Stays until filled or cancelled
  • GTD (Good Till Date): Expires at specified time
  • FOK (Fill or Kill): Must fill entirely or cancel
  • IOC (Immediate or Cancel): Fill what's available, cancel rest

Price Calculations

def calculate_implied_probability(price: float) -> float:
    """Convert price to implied probability."""
    return price  # Prices ARE probabilities (0-1)

def calculate_cost(price: float, shares: float) -> float:
    """Calculate cost to buy shares."""
    return price * shares

def calculate_pnl(
    entry_price: float,
    current_price: float,
    shares: float,
    side: str
) -> float:
    """Calculate unrealized P&L."""
    if side == "BUY":
        return (current_price - entry_price) * shares
    return (entry_price - current_price) * shares

Error Handling

from py_clob_client.exceptions import PolymarketException

try:
    result = client.post_order(order)
except PolymarketException as e:
    if "INSUFFICIENT_BALANCE" in str(e):
        # Handle insufficient funds
        pass
    elif "INVALID_PRICE" in str(e):
        # Handle price out of range
        pass
    raise

Rate Limits

  • Public endpoints: ~100 requests/minute
  • Authenticated endpoints: ~1000 requests/minute
  • WebSocket: Varies by subscription type

Always implement exponential backoff and request queuing.

Key Contract Addresses (Polygon)

CONTRACTS = {
    "CTF_EXCHANGE": "0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",
    "NEG_RISK_CTF_EXCHANGE": "0xC5d563A36AE78145C45a50134d48A1215220f80a",
    "CONDITIONAL_TOKENS": "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045",
    "USDC": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
}

Related skills

How it compares

Use Polymarket API for CLOB and Gamma-specific trading flows; use generic Web3 skills only for unrelated chain contracts.

FAQ

What APIs does Polymarket API cover?

Polymarket API documents the CLOB REST API at clob.polymarket.com for orderbooks and trading, the Gamma API for market metadata, and patterns for on-chain position reads.

What are Polymarket CLOB authentication levels?

Polymarket CLOB defines Level 0 public data, Level 1 signer key creation, and Level 2 authenticated trading for orders and positions requiring API credentials.

Is Polymarket Api safe to install?

skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Backend & APIsagentsautomation

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.