From c12b796e1ee97bec737aacc8f85889f7d40ebc1d Mon Sep 17 00:00:00 2001 From: Contbyte <108092991+contbytex@users.noreply.github.com> Date: Tue, 19 May 2026 12:59:57 +0300 Subject: [PATCH 1/2] docs: add environment setup instructions to README --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 86ff107..a885207 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,18 @@ Python client for the Polymarket CLOB (v2) +## Environment Setup + +Before running the examples or initializing the client, ensure you have set up your environment variables. You can copy the provided example file to get started: + +```bash +cp .env.example .env +``` + +Then, populate your new `.env` file with your credentials: +- `PK`: Your wallet's private key (Required for L1 auth). +- `CLOB_API_KEY`, `CLOB_SECRET`, `CLOB_PASS_PHRASE`: Your API credentials (Required for L2 auth). + ### Usage ```python @@ -23,7 +35,7 @@ client = ClobClient(host=host, chain_id=chain_id, key=os.environ["PK"], creds=cr # 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 + token_id="", # token ID of the market outcome — get from [https://docs.polymarket.com](https://docs.polymarket.com) price=0.4, side=Side.BUY, size=100, From 67ea42cf4c8ea304f803cc73c4c642fdb1a8e97b Mon Sep 17 00:00:00 2001 From: Contbyte <108092991+contbytex@users.noreply.github.com> Date: Wed, 20 May 2026 17:11:38 +0300 Subject: [PATCH 2/2] docs: add inline comments and clarify order ID in cancel_orders example --- examples/orders/cancel_orders.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/orders/cancel_orders.py b/examples/orders/cancel_orders.py index efb8b27..02d5a9a 100644 --- a/examples/orders/cancel_orders.py +++ b/examples/orders/cancel_orders.py @@ -8,11 +8,15 @@ def main(): + # Load the private key from the environment pk = os.environ["PK"] account = Account.from_key(pk) + + # Default to Mumbai testnet (80002) if no chain ID is provided chain_id = int(os.environ.get("CHAIN_ID", 80002)) print(f"Address: {account.address}, chainId: {chain_id}") + # Initialize the ClobClient with API credentials host = os.environ.get("CLOB_API_URL", "http://localhost:8080") creds = ApiCreds( api_key=os.environ["CLOB_API_KEY"], @@ -21,9 +25,12 @@ def main(): ) client = ClobClient(host=host, chain_id=chain_id, key=pk, creds=creds) + # Cancel one or multiple existing orders by their Order IDs + # Note: Replace the example string below with your actual order ID(s) resp = client.cancel_orders([ "0x7ce769d075f4f1263603fde09862f5998f5e6ae4a39a16f3780f0bd708d3fc1c", ]) + print(resp) print("Done!")