py-clob-client-crypto


Namepy-clob-client-crypto JSON
Version 0.18.6 PyPI version JSON
download
home_pagehttps://github.com/milesmao233/py-clob-client-crypto
SummaryPython client for the Polymarket CLOB
upload_time2024-10-21 07:14:52
maintainerPolymarket Engineering
docs_urlNone
authorPolymarket Engineering
requires_python>=3.9.10
licenseNone
keywords
VCS
bugtrack_url
requirements black eth-account eth-utils poly_eip712_structs py_order_utils pytest python-dotenv requests websockets
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## py-clob-client-crypto

<a href='https://pypi.org/project/py-clob-client'>
    <img src='https://img.shields.io/pypi/v/py-clob-client.svg' alt='PyPI'/>
</a>

Python client for the Polymarket CLOB. Full API documentation can be found [here](https://polymarket.github.io/slate-docs/#introduction).

### 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](https://polymarket.github.io/slate-docs/#introduction).

|                   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](https://gist.github.com/poly-rodr/44313920481de58d5a3f6d1f8226bd5e) for a an example of how to set these allowances for an account using python.

### Usage

```py
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](examples/) for more.**

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/milesmao233/py-clob-client-crypto",
    "name": "py-clob-client-crypto",
    "maintainer": "Polymarket Engineering",
    "docs_url": null,
    "requires_python": ">=3.9.10",
    "maintainer_email": "engineering@polymarket.com",
    "keywords": null,
    "author": "Polymarket Engineering",
    "author_email": "engineering@polymarket.com",
    "download_url": "https://files.pythonhosted.org/packages/e6/10/59b3bd6c07070364675dbab8a5950025c4b7ee2431b59ef82580baa8ef4a/py_clob_client_crypto-0.18.6.tar.gz",
    "platform": null,
    "description": "## py-clob-client-crypto\n\n<a href='https://pypi.org/project/py-clob-client'>\n    <img src='https://img.shields.io/pypi/v/py-clob-client.svg' alt='PyPI'/>\n</a>\n\nPython client for the Polymarket CLOB. Full API documentation can be found [here](https://polymarket.github.io/slate-docs/#introduction).\n\n### Installation\n\n`pip install py-clob-client-crypto`\n\nIntended for use with Python 3.9\n\n### Requisites\n\n#### Allowances\n\nThe 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](https://polymarket.github.io/slate-docs/#introduction).\n\n|                   token(s)                   |                   spender                    |                                  description                                   |\n| :------------------------------------------: | :------------------------------------------: | :----------------------------------------------------------------------------: |\n| `0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174` | `0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E` |            allow the CTF Exchange contract to transfer user's usdc             |\n| `0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174` | `0xC5d563A36AE78145C45a50134d48A1215220f80a` |        allow the Neg Risk CTF Exchange contract to transfer user's usdc        |\n| `0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174` | `0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296` |          allow the Neg Risk Adapter contract to transfer user's usdc           |\n| `0x4D97DCd97eC945f40cF65F87097ACe5EA0476045` | `0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E` |     allow the CTF Exchange contract to transfer user's conditional tokens      |\n| `0x4D97DCd97eC945f40cF65F87097ACe5EA0476045` | `0xC5d563A36AE78145C45a50134d48A1215220f80a` | allow the Neg Risk CTF Exchange contract to transfer user's conditional tokens |\n| `0x4D97DCd97eC945f40cF65F87097ACe5EA0476045` | `0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296` |   allow the Neg Risk Adapter contract to transfer user's conditional tokens    |\n\nSee [this gist](https://gist.github.com/poly-rodr/44313920481de58d5a3f6d1f8226bd5e) for a an example of how to set these allowances for an account using python.\n\n### Usage\n\n```py\nimport os\nfrom py_clob_client.constants import POLYGON\nfrom py_clob_client.client import ClobClient\nfrom py_clob_client.clob_types import OrderArgs\nfrom py_clob_client.order_builder.constants import BUY\n\nhost = \"https://clob.polymarket.com\"\nkey = os.getenv(\"PK\")\nchain_id = POLYGON\n\n# Create CLOB client and get/set API credentials\nclient = ClobClient(host, key=key, chain_id=chain_id)\nclient.set_api_creds(client.create_or_derive_api_creds())\n\n# Create and sign an order buying 100 YES tokens for 0.50c each\nresp = client.create_and_post_order(OrderArgs(\n    price=0.50,\n    size=100.0,\n    side=BUY,\n    token_id=\"71321045679252212594626385532706912750332728571942532289631379312455583992563\"\n))\n\nprint(resp)\n```\n\n**See [examples](examples/) for more.**\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python client for the Polymarket CLOB",
    "version": "0.18.6",
    "project_urls": {
        "Bug Tracker": "https://github.com/Polymarket/py-clob-client/issues",
        "Homepage": "https://github.com/milesmao233/py-clob-client-crypto"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "01db04bd5ccc9fb8b6627f6674af77998735bdc0b8921a4504a0e7fea6929722",
                "md5": "7e9e938b2a1b6cffbc7de18616f1376a",
                "sha256": "7eebc5f1ee0d4d51e04f2c54a6cbd1422b1fd913799030b82e32e04913068091"
            },
            "downloads": -1,
            "filename": "py_clob_client_crypto-0.18.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7e9e938b2a1b6cffbc7de18616f1376a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9.10",
            "size": 28355,
            "upload_time": "2024-10-21T07:14:51",
            "upload_time_iso_8601": "2024-10-21T07:14:51.298883Z",
            "url": "https://files.pythonhosted.org/packages/01/db/04bd5ccc9fb8b6627f6674af77998735bdc0b8921a4504a0e7fea6929722/py_clob_client_crypto-0.18.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e61059b3bd6c07070364675dbab8a5950025c4b7ee2431b59ef82580baa8ef4a",
                "md5": "daac1442a5c7f010fe932fdb957bb20a",
                "sha256": "66d6a42513fc7de0100b1ae4a11ee7c4411c60768dfb7a731c83e98aa3d21396"
            },
            "downloads": -1,
            "filename": "py_clob_client_crypto-0.18.6.tar.gz",
            "has_sig": false,
            "md5_digest": "daac1442a5c7f010fe932fdb957bb20a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9.10",
            "size": 23000,
            "upload_time": "2024-10-21T07:14:52",
            "upload_time_iso_8601": "2024-10-21T07:14:52.885201Z",
            "url": "https://files.pythonhosted.org/packages/e6/10/59b3bd6c07070364675dbab8a5950025c4b7ee2431b59ef82580baa8ef4a/py_clob_client_crypto-0.18.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-21 07:14:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "milesmao233",
    "github_project": "py-clob-client-crypto",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "black",
            "specs": [
                [
                    "==",
                    "24.4.2"
                ]
            ]
        },
        {
            "name": "eth-account",
            "specs": [
                [
                    "===",
                    "0.13.0"
                ]
            ]
        },
        {
            "name": "eth-utils",
            "specs": [
                [
                    "===",
                    "4.1.1"
                ]
            ]
        },
        {
            "name": "poly_eip712_structs",
            "specs": [
                [
                    "==",
                    "0.0.1"
                ]
            ]
        },
        {
            "name": "py_order_utils",
            "specs": [
                [
                    "==",
                    "0.3.2"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.2.2"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    "==",
                    "0.19.2"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.32.3"
                ]
            ]
        },
        {
            "name": "websockets",
            "specs": [
                [
                    "==",
                    "12.0"
                ]
            ]
        }
    ],
    "lcname": "py-clob-client-crypto"
}
        
Elapsed time: 0.71825s