Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

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)

For Polymarket V2 outcomes, pass position_id instead of token_id:

resp = client.create_and_post_order(
    OrderArgs(position_id="456", price=0.4, size=100, side=Side.BUY),
    options=PartialCreateOrderOptions(tick_size="0.01"),
    order_type=OrderType.GTC,
)

Provide exactly one identifier. position_id automatically selects Exchange V3 signing, including when using OrderBuilder directly, and ignores neg_risk and any requested exchange version. Existing token_id orders retain server-selected version routing; PartialCreateOrderOptions(version=1) or version=2 can override it. Signed orders and HTTP payloads still use the protocol field tokenId for both kinds of identifier.

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)

Position-backed market orders use the same workflow and amount units:

resp = client.create_and_post_market_order(
    MarketOrderArgs(position_id="456", amount=100, side=Side.BUY),
    options=PartialCreateOrderOptions(tick_size="0.01"),
    order_type=OrderType.FOK,
)

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 1.2.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 1.2.2
File Size Uploaded Provenance Actions
py_clob_client_v2-1.2.2.tar.gz 53.5 kB With provenance Details for py_clob_client_v2-1.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 105.3 kB

Release files / py_clob_client_v2-1.2.2.tar.gz

Download URL py_clob_client_v2-1.2.2.tar.gz
Size 53.5 kB
Tags Source
SHA-256 checksum
How to use checksums
052798a9ac4f66bff15541262c10d91121310956ee57a5d86adf566ba0152eaa
BLAKE2b-256 checksum
How to use checksums
4799fce103519bf07dcb8dd8e7ea5823f3a2d67a71896799ed636020abde0b28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / py_clob_client_v2-1.2.2-py3-none-any.whl

Download URL py_clob_client_v2-1.2.2-py3-none-any.whl
Size 51.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7291a450b77cb04a7531865edb5a1adfb1cc528a4514a94dd5f25a665024e8f
BLAKE2b-256 checksum
How to use checksums
919ef8c071fd3bc445718c2a10871bcfc6dc39d6ebf834023bf9ebbc052538e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for py-clob-client-v2 1.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for py_clob_client_v2-1.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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