Skip to main content

PY Polymarket CLOB Client V2

Python client for the Polymarket CLOB (v2)

Usage

# pip install py_clob_client_v2

import os
from py_clob_client_v2 import ApiCreds, ClobClient, OrderArgs, OrderType, PartialCreateOrderOptions, Side

host = "<polymarket-clob-host>"
chain_id = 137  # or 80002 for Amoy testnet

# Step 1: obtain API credentials using your wallet (L1 auth)
client = ClobClient(host=host, chain_id=chain_id, key=os.environ["PK"])
creds = client.create_or_derive_api_key()

# Step 2: initialize a fully-authenticated client (L1 + L2)
client = ClobClient(host=host, chain_id=chain_id, key=os.environ["PK"], creds=creds)

# Place a resting limit buy (GTC)
resp = client.create_and_post_order(
    order_args=OrderArgs(
        token_id="",  # token ID of the market outcome — get from https://docs.polymarket.com
        price=0.4,
        side=Side.BUY,
        size=100,
    ),
    options=PartialCreateOrderOptions(tick_size="0.01"),
    order_type=OrderType.GTC,
)
print(resp)

See examples for more information.

Market Orders

from py_clob_client_v2 import MarketOrderArgs

# Market buy — amount is in USDC
# OrderType.FOK: entire order must fill immediately or it is cancelled
# OrderType.FAK: fills as much as possible, remainder is cancelled
resp = client.create_and_post_market_order(
    order_args=MarketOrderArgs(
        token_id="",
        amount=100,  # USDC
        side=Side.BUY,
        order_type=OrderType.FOK,
    ),
    options=PartialCreateOrderOptions(tick_size="0.01"),
    order_type=OrderType.FOK,
)
print(resp)

Authentication

The client has two authentication levels:

L1 — wallet signature (EIP-712). Required to create or derive API keys.

client = ClobClient(host=host, chain_id=chain_id, key=os.environ["PK"])
creds = client.create_or_derive_api_key()

L2 — HMAC with API credentials. Required for order placement, cancellation, and account data.

creds = ApiCreds(
    api_key=os.environ["CLOB_API_KEY"],
    api_secret=os.environ["CLOB_SECRET"],
    api_passphrase=os.environ["CLOB_PASS_PHRASE"],
)
client = ClobClient(host=host, chain_id=chain_id, key=os.environ["PK"], creds=creds)

Metadata

Release files for py-clob-client-v2-felix 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-clob-client-v2-felix 1.0.2
File Size Uploaded
py_clob_client_v2_felix-1.0.2.tar.gz 46.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-clob-client-v2-felix 1.0.2
File Interpreter ABI Platform
py_clob_client_v2_felix-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 96.1 kB

Release files / py_clob_client_v2_felix-1.0.2.tar.gz

Download URL py_clob_client_v2_felix-1.0.2.tar.gz
Size 46.3 kB
Tags Source
SHA-256 checksum
How to use checksums
96efa8833d64e0335e02dbd616ca4873050f489248fc2719a04cc2f6eea6e7ce
BLAKE2b-256 checksum
How to use checksums
e873e730b0b79e28dc34d74ccff6fcf4ceb98734e25db51a92043a654ad58765
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / py_clob_client_v2_felix-1.0.2-py3-none-any.whl

Download URL py_clob_client_v2_felix-1.0.2-py3-none-any.whl
Size 49.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
203db7d8d9463c3a54351b6c6df047f234657791492b5f0c906634716769f017
BLAKE2b-256 checksum
How to use checksums
20a09c4bccb5adf8efd9ce86f31bf6889cf0997145dff977fb3ef4dc119a8567
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page