{"library":"py-order-utils","title":"Polymarket Python Order Utilities","description":"Python utilities used to generate and sign orders for Polymarket's Exchange. The library facilitates interaction with Polymarket's Central Limit Order Book (CLOB) by providing tools for order building, signing, and data structuring. The current version is 0.3.2, with releases primarily driven by smart contract updates and critical bug fixes, indicating an active but demand-driven release cadence.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install py-order-utils"],"cli":null},"imports":["from py_order_utils.builders import OrderBuilder","from py_order_utils.signer import Signer","from py_order_utils.models import OrderData"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport json\nfrom web3 import Web3\nfrom py_order_utils.builders import OrderBuilder\nfrom py_order_utils.signer import Signer\nfrom py_order_utils.models import OrderData, SignedOrder\n\n# Configuration (replace with your actual values or environment variables)\nPRIVATE_KEY = os.environ.get('POLYMARKET_PRIVATE_KEY', '0x...') # Your Ethereum private key\nRPC_URL = os.environ.get('POLYMARKET_RPC_URL', 'https://rpc-amoy.polygon.technology/') # e.g., Polygon Amoy RPC URL\nEXCHANGE_ADDRESS = os.environ.get('POLYMARKET_EXCHANGE_ADDRESS', '0x...') # Polymarket CLOB Exchange Contract Address\nCHAIN_ID = int(os.environ.get('POLYMARKET_CHAIN_ID', '80002')) # e.g., 80002 for Polygon Amoy\n\ndef main():\n    if PRIVATE_KEY == '0x...' or EXCHANGE_ADDRESS == '0x...':\n        print(\"Please configure POLYMARKET_PRIVATE_KEY, POLYMARKET_RPC_URL, EXCHANGE_ADDRESS, and CHAIN_ID environment variables.\")\n        return\n\n    w3 = Web3(Web3.HTTPProvider(RPC_URL))\n    if not w3.is_connected():\n        print(f\"Failed to connect to RPC at {RPC_URL}\")\n        return\n\n    print(f\"Connected to chain ID: {w3.eth.chain_id}\")\n    \n    signer_instance = Signer(PRIVATE_KEY)\n    builder = OrderBuilder(EXCHANGE_ADDRESS, CHAIN_ID, signer_instance)\n\n    # Example OrderData payload (replace with actual order parameters)\n    order_data = OrderData(\n        maker='0x' + signer_instance.address[2:], # Your wallet address\n        taker='0x0000000000000000000000000000000000000000', # Taker address (0x0 for open orders)\n        longToken='0x...', # Address of the long token for the market\n        shortToken='0x...', # Address of the short token for the market\n        longTokenAmount='1000000000000000000', # 1 Long Token (example: 1e18 wei)\n        shortTokenAmount='500000000000000000', # 0.5 Short Token (example: 0.5e18 wei)\n        salt=w3.eth.get_block('latest').number, # Unique salt for the order\n        expiry=w3.eth.get_block('latest').timestamp + 3600, # Expires in 1 hour\n        feeRate='0', # Example fee rate\n        isPostOnly=False,\n        market='0x...', # Market contract address\n        minAmountReceived='0' # Minimum amount to receive\n    )\n\n    try:\n        # Create and sign the order\n        signed_order: SignedOrder = builder.build_signed_order(order_data)\n\n        # Generate the Order and Signature JSON to be sent to the CLOB API\n        print(\"\\n--- Signed Order JSON ---\")\n        print(json.dumps(signed_order.dict(), indent=2))\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart demonstrates how to initialize the `Signer` and `OrderBuilder` classes, construct a sample `OrderData` object with placeholder values, and generate a signed order suitable for submission to Polymarket's CLOB API. Ensure environment variables for `POLYMARKET_PRIVATE_KEY`, `POLYMARKET_RPC_URL`, `POLYMARKET_EXCHANGE_ADDRESS`, and `POLYMARKET_CHAIN_ID` are set for a runnable example.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"0.3.2","pypi_latest":"0.3.2","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":7.5,"avg_import_s":1.29,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"py-order-utils","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.18,"mem_mb":18.4,"disk_size":"68.6M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"py-order-utils","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":8.6,"import_time_s":0.92,"mem_mb":18.4,"disk_size":"71M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"py-order-utils","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.55,"mem_mb":19.9,"disk_size":"75.3M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"py-order-utils","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":7.4,"import_time_s":1.4,"mem_mb":19.9,"disk_size":"78M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"py-order-utils","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.68,"mem_mb":19.4,"disk_size":"66.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"py-order-utils","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5.9,"import_time_s":1.73,"mem_mb":19.4,"disk_size":"69M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"py-order-utils","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.05,"mem_mb":17.9,"disk_size":"66.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"py-order-utils","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":6.2,"import_time_s":1.05,"mem_mb":17.9,"disk_size":"69M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"py-order-utils","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.21,"mem_mb":18.3,"disk_size":"67.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"py-order-utils","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":9.6,"import_time_s":1.15,"mem_mb":18.4,"disk_size":"71M"}]}}