Python client for the Polymarket CLOB
Project description
py-clob-client
Python client for the Polymarket CLOB. Full API documentation can be found here.
Installation
pip install py-clob-client
Intended for use with Python 3.9
Requisites
Allowances
The correct token allowances must be set before orders can be placed. The following mainnet (Polygon) allowances should be set by the funding (maker) address. For testnet addresses and additional documentation please refer to the API documentation.
token(s) | spender | description |
---|---|---|
0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 |
0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E |
allow the exchange contract to transfer user's usdc |
0x4D97DCd97eC945f40cF65F87097ACe5EA0476045 |
0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E |
allow the exchange contract to transfer user's conditional tokens |
See this gist for a an example of how to set these allowances for an account using python.
Usage
import os
from py_clob_client.constants import POLYGON
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs
from py_clob_client.order_builder.constants import BUY
host = "https://clob.polymarket.com"
key = os.getenv("PK")
chain_id = POLYGON
# Create CLOB client and get/set API credentials
client = ClobClient(host, key=key, chain_id=chain_id)
client.set_api_creds(client.create_or_derive_api_creds())
# Create and sign an order buying 100 YES tokens for 0.50c each
resp = client.create_and_post_order(OrderArgs(
price=0.50,
size=100.0,
side=BUY,
token_id="16678291189211314787145083999015737376658799626183230671758641503291735614088"
))
print(resp)
See examples for more.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_clob_client-0.2.1.tar.gz
(15.6 kB
view hashes)
Built Distribution
Close
Hashes for py_clob_client-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 788e9e1b1a6bccfe5f2a60062deb58aee64fba92222359d1f45764bc645f37c5 |
|
MD5 | dbefba4d15466e74dd0d402096a04981 |
|
BLAKE2b-256 | 41429c72c4562da52b791f66fef5af0c81db131b4e3de5e5af44497b63d9c545 |