LogoHypereal AI
モデルCoding LLMLimitedAgentクレジット料金ドキュメントEnterpriseアフィリエイト
今すぐ始める
Hypereal AI
  • モデル
  • Coding LLM
  • プロダクト
  • GPUクラウド
  • GPU レンタル
  • モデル学習
  • ComfyUI API
  • モデルデプロイ
  • Hypereal SDK
  • Agent
  • クレジット料金
  • ドキュメント
  • Enterprise
  • アフィリエイト
記事一覧に戻る
APITutorialCrypto

How to Use Polymarket API: Complete Developer Guide (2026)

Build prediction market apps with Polymarket's REST and WebSocket APIs

Hypereal AI TeamHypereal AI Team
7 min read
2026年2月6日
100以上のAIモデル、1つのAPI

Hyperealで構築を始めよう

Kling、Flux、Sora、Veoなどに単一のAPIでアクセス。無料クレジットで開始、数百万規模まで拡張可能。

無料APIキーを取得ドキュメントを見る

クレジットカード不要 • 10万人以上の開発者 • エンタープライズ対応

How to Use Polymarket API: Complete Developer Guide (2026)

Polymarket is the largest prediction market platform, allowing users to trade on the outcomes of real-world events. Whether you want to build a dashboard, automate trading strategies, or pull market data into your application, the Polymarket API gives you programmatic access to everything on the platform.

This guide walks through the full Polymarket API setup, from authentication to placing your first trade, with working code examples in Python and JavaScript.

Polymarket API Overview

Polymarket exposes two main APIs:

API Purpose Authentication Rate Limit
CLOB API Trading, order placement, market data API key + secret 100 req/min
Gamma API Public market data, events, metadata None (public) 300 req/min

The CLOB (Central Limit Order Book) API is what you need for trading. The Gamma API is a read-only REST API for fetching market information, event details, and historical data without authentication.

Step 1: Get Your Polymarket API Key

To use the CLOB API, you need an API key tied to your Polymarket wallet.

  1. Go to polymarket.com and connect your wallet or create an account.
  2. Navigate to your account settings and find the API section.
  3. Generate a new API key and secret. Store these securely -- you will not see the secret again.

For the Gamma API, no authentication is required. You can start making requests immediately.

Step 2: Fetch Market Data with the Gamma API

The Gamma API is the easiest way to get started. It returns structured data about all active markets.

List All Active Markets

import requests

# Fetch active markets from Polymarket Gamma API
response = requests.get(
    "https://gamma-api.polymarket.com/markets",
    params={
        "active": "true",
        "limit": 10,
        "order": "volume24hr",
        "ascending": "false"
    }
)

markets = response.json()

for market in markets:
    print(f"Question: {market['question']}")
    print(f"Volume (24h): ${market.get('volume24hr', 0):,.2f}")
    print(f"Liquidity: ${market.get('liquidity', 0):,.2f}")
    print("---")
// Node.js / fetch example
const response = await fetch(
  "https://gamma-api.polymarket.com/markets?" +
  new URLSearchParams({
    active: "true",
    limit: "10",
    order: "volume24hr",
    ascending: "false"
  })
);

const markets = await response.json();

markets.forEach(market => {
  console.log(`Question: ${market.question}`);
  console.log(`Volume (24h): $${Number(market.volume24hr || 0).toLocaleString()}`);
  console.log(`Liquidity: $${Number(market.liquidity || 0).toLocaleString()}`);
  console.log("---");
});

Get a Specific Market by ID

import requests

market_id = "0x1234..."  # Replace with actual condition ID

response = requests.get(
    f"https://gamma-api.polymarket.com/markets/{market_id}"
)

market = response.json()
print(f"Question: {market['question']}")
print(f"Description: {market['description']}")
print(f"End Date: {market['endDate']}")

Search Markets by Keyword

import requests

response = requests.get(
    "https://gamma-api.polymarket.com/markets",
    params={
        "tag": "politics",
        "active": "true",
        "limit": 5
    }
)

markets = response.json()
for m in markets:
    print(f"{m['question']} — Volume: ${m.get('volume24hr', 0):,.0f}")

Step 3: Connect to the CLOB API for Trading

The CLOB API lets you place and manage orders. It requires cryptographic authentication using your API credentials.

Install the Python Client

pip install py-clob-client

Initialize the Client

from py_clob_client.client import ClobClient
from py_clob_client.clob_types import ApiCreds

# Your credentials
host = "https://clob.polymarket.com"
chain_id = 137  # Polygon mainnet
private_key = "0xYOUR_PRIVATE_KEY"

# Initialize the client
client = ClobClient(
    host,
    key=private_key,
    chain_id=chain_id
)

# Derive API credentials
api_creds = client.create_or_derive_api_creds()
client.set_api_creds(api_creds)

print("Connected to Polymarket CLOB API")

Fetch Order Book Data

# Get the order book for a specific market
token_id = "71321045..."  # The token ID for a specific outcome

order_book = client.get_order_book(token_id)

print("Bids:")
for bid in order_book.bids[:5]:
    print(f"  Price: {bid.price} | Size: {bid.size}")

print("Asks:")
for ask in order_book.asks[:5]:
    print(f"  Price: {ask.price} | Size: {ask.size}")

Place a Limit Order

from py_clob_client.order_builder.constants import BUY

# Create and sign a limit order
order_args = {
    "token_id": "71321045...",
    "price": 0.55,        # Price in USDC (0.55 = 55 cents = 55% probability)
    "size": 100,           # Number of shares
    "side": BUY,
    "fee_rate_bps": 0,     # Fee in basis points
}

signed_order = client.create_and_post_order(order_args)
print(f"Order placed: {signed_order}")

Cancel an Order

# Cancel a specific order
order_id = "0xABC123..."
result = client.cancel(order_id)
print(f"Order cancelled: {result}")

# Cancel all open orders
result = client.cancel_all()
print(f"All orders cancelled: {result}")

Step 4: Stream Real-Time Data with WebSockets

Polymarket offers WebSocket connections for real-time price updates and order book changes.

import asyncio
import websockets
import json

async def stream_market_data():
    uri = "wss://ws-subscriptions-clob.polymarket.com/ws/market"

    async with websockets.connect(uri) as ws:
        # Subscribe to a market
        subscribe_msg = {
            "type": "subscribe",
            "market": "71321045...",  # Token ID
            "channel": "price"
        }
        await ws.send(json.dumps(subscribe_msg))
        print("Subscribed to price updates")

        async for message in ws:
            data = json.loads(message)
            print(f"Price update: {data}")

asyncio.run(stream_market_data())

Step 5: Build a Simple Market Dashboard

Here is a practical example that pulls the top markets and displays them in a formatted table.

import requests
from tabulate import tabulate

def get_top_markets(limit=10):
    response = requests.get(
        "https://gamma-api.polymarket.com/markets",
        params={
            "active": "true",
            "limit": limit,
            "order": "volume24hr",
            "ascending": "false"
        }
    )
    return response.json()

def format_market_table(markets):
    rows = []
    for m in markets:
        rows.append([
            m["question"][:60],
            f"${float(m.get('volume24hr', 0)):,.0f}",
            f"${float(m.get('liquidity', 0)):,.0f}",
            m.get("endDate", "N/A")[:10]
        ])

    headers = ["Market", "24h Volume", "Liquidity", "End Date"]
    return tabulate(rows, headers=headers, tablefmt="grid")

markets = get_top_markets()
print(format_market_table(markets))

Polymarket API Rate Limits and Best Practices

Endpoint Rate Limit Recommended Interval
Gamma API (public) 300 req/min 200ms between requests
CLOB REST API 100 req/min 600ms between requests
WebSocket No hard limit Use heartbeat pings every 30s
Order placement 10 orders/sec Batch when possible

Best practices

  • Cache market data. Market metadata does not change frequently. Cache it locally and refresh every 5-10 minutes.
  • Use WebSockets for real-time data. Polling the REST API wastes rate limits. Use WebSocket subscriptions for live price feeds.
  • Handle 429 errors gracefully. Implement exponential backoff when you hit rate limits.
  • Store API keys in environment variables. Never hardcode private keys or API secrets in your code.
import os

# Load from environment variables
api_key = os.environ.get("POLYMARKET_API_KEY")
api_secret = os.environ.get("POLYMARKET_API_SECRET")
private_key = os.environ.get("POLYMARKET_PRIVATE_KEY")

Common API Response Codes

Code Meaning Action
200 Success Process response
400 Bad request Check parameters
401 Unauthorized Verify API credentials
404 Not found Check market/order ID
429 Rate limited Back off and retry
500 Server error Retry after delay

Frequently Asked Questions

Is the Polymarket API free? Yes. The Gamma API is completely free with no authentication required. The CLOB API is free to use but requires a funded Polymarket account to place trades.

Which blockchain does Polymarket use? Polymarket operates on Polygon (chain ID 137). You need USDC on Polygon to trade.

Can I use the API for automated trading bots? Yes. The CLOB API is designed for programmatic trading. Many users run automated strategies. Be aware of the terms of service regarding market manipulation.

Is there a sandbox or testnet? Polymarket has occasionally offered testnet environments for developers. Check their Discord and documentation for current availability.

What programming languages are supported? The official client library is in Python (py-clob-client). The REST and WebSocket APIs work with any language that supports HTTP requests.

Wrapping Up

The Polymarket API is one of the most accessible prediction market APIs available. The public Gamma API requires zero setup for reading market data, and the CLOB API gives you full trading capabilities with Python client support.

If you are building AI-powered applications that incorporate prediction market data or any kind of media generation, try Hypereal AI free -- 35 credits, no credit card required. It provides simple APIs for image, video, and avatar generation that pair well with data-driven applications.

関連記事

GLM-4.6 API の使い方:開発者向け完全ガイド (2026年版)

11 min read

GLM-4.7 API の使い方:開発者ガイド (2026)

12 min read

2026年版 ChatGPTの制限を突破する正しい方法

6 min read

On this page

  • How to Use Polymarket API: Complete Developer Guide (2026)
  • Polymarket API Overview
  • Step 1: Get Your Polymarket API Key
  • Step 2: Fetch Market Data with the Gamma API
  • List All Active Markets
  • Get a Specific Market by ID
  • Search Markets by Keyword
  • Step 3: Connect to the CLOB API for Trading
  • Install the Python Client
  • Initialize the Client
  • Fetch Order Book Data
  • Place a Limit Order
  • Cancel an Order
  • Step 4: Stream Real-Time Data with WebSockets
  • Step 5: Build a Simple Market Dashboard
  • Polymarket API Rate Limits and Best Practices
  • Best practices
  • Common API Response Codes
  • Frequently Asked Questions
  • Wrapping Up
Desktop agent

Download Hypereal Agent

Run a local AI media workspace for image generation, video prompts, model selection, credit tracking, and saved artifacts.

MacWindows
v0.1.1Requires a hypereal.cloud API keyRelease manifest
Hypereal Agent desktop app screenshot

今日から構築を開始

今すぐ構築を開始
Logo
Hypereal AI好奇心を探求する
TwitterGitHubLinkedInYouTubeEmail
インフラ
  • GPU レンタル
  • モデル学習
  • ComfyUI API
  • モデルデプロイ
  • 公開カタログ
  • インフラドキュメント
  • GPU ログ
  • 料金
LLM API
  • Hypereal SDK
  • Coding Credits
  • All LLM Models
  • Claude Opus 4.7
  • Claude Sonnet 4.6
  • GPT-5.5
  • Claude Haiku 4.5
  • GPT-5.5 Pro
  • GPT-5.3 Codex
  • Gemini 3.1 Pro Preview
  • Gemini 3.5 Thinking
  • Gemini 3.5 Fast
  • DeepSeek V4 Pro
  • Kimi K2.6
  • GLM-5.1
AI API
  • AI API Overview
  • Seedance 2.0 API
  • Kling 3.0 API
  • Veo 3.1 API
  • FLUX API
  • GPT Image 2 API
  • vs WaveSpeed
  • vs fal.ai
  • vs Replicate
  • vs KIE.ai
動画モデル
  • Google Veo 3.1 API
  • Kling 3.0 API
  • Kling O3 Pro API
  • Seedance 2.0 API
  • HappyHorse 1.0 API
  • WAN 2.7 API
  • WAN Video API
  • Grok Video API
  • Hunyuan Video API
  • PixVerse V6 API
  • Pika Video API
  • Luma Dream Machine API
  • MiniMax Video API
  • Vidu Video API
画像モデル
  • NanoBanana 2 API
  • FLUX 2 API
  • GPT Image 1 API
  • Grok Image API
  • SeeDream V5 API
  • Imagen 4 API
  • Ideogram API
  • Recraft API
  • DALL-E 3 API
  • Stable Diffusion API
  • Gemini Image API
ツール
  • Face Swap API
  • Video Face Swap API
  • Virtual Try-On API
  • Image Upscaler API
  • Video Upscaler API
  • AI Talking Avatar API
  • Lip Sync API
  • OmniHuman Avatar API
  • Tripo3D H3.1 API
  • ElevenLabs TTS API
  • Fish Audio TTS API
  • Whisper STT API
  • Lyria Music API
ジェネレーター
  • Hypereal Agent
  • AI画像ジェネレーター
  • AI動画ジェネレーター
  • AIアバタージェネレーター
  • AIオーディオジェネレーター
  • AI 3Dジェネレーター
  • AIツール
  • 画像アップスケーラー
  • 動画アップスケーラー
コレクション
  • ベスト動画モデル
  • ベスト画像モデル
  • Seedance 2.0
  • WAN 2.7
  • Qwen Image 2
  • Grok AI
  • Seedance 1.5
  • モーションコントロール
  • コンテンツ検出
  • オブジェクト検出
会社情報
  • 会社概要
  • ドキュメント
  • Hypereal SDK
  • Cookbook
  • ブログ
  • 更新履歴
  • お問い合わせ
  • よくある質問
  • ヒント&チュートリアル
  • ロードマップ
  • エンタープライズ
  • アフィリエイトプログラム
  • Platform
  • 開発者プログラム
法的情報
  • プライバシーポリシー
  • 利用規約
  • 返金ポリシー
  • Cookieポリシー
  • 料金
  • 全モデル
  • サイトマップ
  • Status
全システム正常
•カリフォルニアから愛を込めて ❤️
© 著作権 2026。全著作権所有。