Python client for the Polymarket CLOBV2
Project description
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)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_clob_client_v2-0.0.4.tar.gz.
File metadata
- Download URL: py_clob_client_v2-0.0.4.tar.gz
- Upload date:
- Size: 39.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed4227d97a3aa9e7377c858fb388f4b9e0d71ba1bfb068a01540d3efdedbf0f0
|
|
| MD5 |
3a8bd940d38f34562352d61ff426aeaf
|
|
| BLAKE2b-256 |
f21057b0fe25ae31318c8b996ec1bd845598020d7de23ba4fe15bbb829007d33
|
Provenance
The following attestation bundles were made for py_clob_client_v2-0.0.4.tar.gz:
Publisher:
release.yaml on Polymarket/py-clob-client-v2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_clob_client_v2-0.0.4.tar.gz -
Subject digest:
ed4227d97a3aa9e7377c858fb388f4b9e0d71ba1bfb068a01540d3efdedbf0f0 - Sigstore transparency entry: 1321538864
- Sigstore integration time:
-
Permalink:
Polymarket/py-clob-client-v2@356bce4bc0b880409b89910105f518f975e800b2 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/Polymarket
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@356bce4bc0b880409b89910105f518f975e800b2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file py_clob_client_v2-0.0.4-py3-none-any.whl.
File metadata
- Download URL: py_clob_client_v2-0.0.4-py3-none-any.whl
- Upload date:
- Size: 46.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b388347921e69c0f982e8486499838c9a43bacce37a52143285d9e7c2d2784b
|
|
| MD5 |
516e69e1024cb9a0a5762660d05c909d
|
|
| BLAKE2b-256 |
313213e4a8184c81aea93183f8991cf237620d8bbad24263907152720f78b2b8
|
Provenance
The following attestation bundles were made for py_clob_client_v2-0.0.4-py3-none-any.whl:
Publisher:
release.yaml on Polymarket/py-clob-client-v2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_clob_client_v2-0.0.4-py3-none-any.whl -
Subject digest:
6b388347921e69c0f982e8486499838c9a43bacce37a52143285d9e7c2d2784b - Sigstore transparency entry: 1321539020
- Sigstore integration time:
-
Permalink:
Polymarket/py-clob-client-v2@356bce4bc0b880409b89910105f518f975e800b2 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/Polymarket
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@356bce4bc0b880409b89910105f518f975e800b2 -
Trigger Event:
release
-
Statement type: