Skip to main content

Python client for the Polymarket CLOB

Project description

py-clob-client-crypto

PyPI

Python client for the Polymarket CLOB. Full API documentation can be found here.

Installation

pip install py-clob-client-crypto

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 CTF Exchange contract to transfer user's usdc
0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 0xC5d563A36AE78145C45a50134d48A1215220f80a allow the Neg Risk CTF Exchange contract to transfer user's usdc
0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296 allow the Neg Risk Adapter contract to transfer user's usdc
0x4D97DCd97eC945f40cF65F87097ACe5EA0476045 0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E allow the CTF Exchange contract to transfer user's conditional tokens
0x4D97DCd97eC945f40cF65F87097ACe5EA0476045 0xC5d563A36AE78145C45a50134d48A1215220f80a allow the Neg Risk CTF Exchange contract to transfer user's conditional tokens
0x4D97DCd97eC945f40cF65F87097ACe5EA0476045 0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296 allow the Neg Risk Adapter 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="71321045679252212594626385532706912750332728571942532289631379312455583992563"
))

print(resp)

See examples for more.

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

py_clob_client_crypto-0.18.3.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_clob_client_crypto-0.18.3-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file py_clob_client_crypto-0.18.3.tar.gz.

File metadata

  • Download URL: py_clob_client_crypto-0.18.3.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for py_clob_client_crypto-0.18.3.tar.gz
Algorithm Hash digest
SHA256 0d8779e33e8f23497d7b528c2f9dca559f26a8d88d3494e21b936cbce720d534
MD5 718d6d438cfe7a30e39dce071f17d9f8
BLAKE2b-256 ae7c2ef966d82df72fe726e44b228cf4d8d28c5221f27d5c7f28d05b8bccd09b

See more details on using hashes here.

File details

Details for the file py_clob_client_crypto-0.18.3-py3-none-any.whl.

File metadata

File hashes

Hashes for py_clob_client_crypto-0.18.3-py3-none-any.whl
Algorithm Hash digest
SHA256 381e9678d2827451672ac08640cf39abda028c2dd27fce70bc3228b22131039e
MD5 f9d335e42f1897e209dfa0597f4f84d2
BLAKE2b-256 183748639892e03023e2f45fac1233787a93a4d32f66506bcffa0a259f0a739d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page