Official Python client for Polymarket
Project description
Polymarket Python SDK
Official Python SDK for Polymarket.
The SDK gives Python developers one coherent, workflow-oriented interface for building on Polymarket, starting with public data access and expanding toward authenticated account, trading, builder attribution, and relayer-backed workflows.
Installation
uv add polymarket-client
or:
pip install polymarket-client
Usage
Synchronous client:
from polymarket import Market, PublicClient
with PublicClient() as client:
market: Market = client.get_market(url="https://polymarket.com/event/example-market")
Asynchronous client:
import asyncio
from polymarket import AsyncPublicClient, Market
async def main() -> None:
async with AsyncPublicClient() as client:
market: Market = await client.get_market(
url="https://polymarket.com/event/example-market"
)
asyncio.run(main())
API Design
See SDK Direction for public API design principles and developer-experience decisions.
Development
Install dependencies:
make sync
Run checks:
make check
Build package artifacts:
make build
The Makefile is a thin convenience wrapper around uv. Running the underlying commands directly is also fine.
Testing
Unit tests run by default:
make test
Run unit tests in watch mode:
make test-watch
This runs the tests once immediately, then reruns them when Python files change.
Integration tests are opt-in:
make test-integration
Integration tests can load local secrets from a gitignored .env copied from .env.example:
cp .env.example .env
See .env.example for the supported local and CI secret names.
Tests that require credentials should use the require_env fixture so they skip when secrets are unavailable:
import pytest
@pytest.mark.integration
def test_authenticated_flow(require_env):
private_key = require_env("POLYMARKET_PRIVATE_KEY")
builder_api_key = require_env("POLYMARKET_BUILDER_API_KEY")
assert private_key
assert builder_api_key
The SDK does not load .env files at runtime. The integration test fixture loads .env only for tests that request credentials, and existing environment variables take precedence over local .env values.
Tests that place orders, spend funds, or mutate live state must also use @pytest.mark.metered. Metered tests are skipped unless POLYMARKET_RUN_METERED_TESTS=1 is set:
import pytest
@pytest.mark.integration
@pytest.mark.metered
def test_order_lifecycle(require_env):
private_key = require_env("POLYMARKET_PRIVATE_KEY")
assert private_key
POLYMARKET_RUN_METERED_TESTS=1 make test-integration
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polymarket_client-0.1.0b1.tar.gz.
File metadata
- Download URL: polymarket_client-0.1.0b1.tar.gz
- Upload date:
- Size: 194.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bb007d969314aa0706777541be430cde5b35af02588089900b890bc53d6367e
|
|
| MD5 |
91e80313a7b7eefc80832139b281c05e
|
|
| BLAKE2b-256 |
6b9961409048ccc00b9568e19a2f2a9355c44388513c7454f3f0c64e1ff846dc
|
Provenance
The following attestation bundles were made for polymarket_client-0.1.0b1.tar.gz:
Publisher:
publish.yml on Polymarket/py-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polymarket_client-0.1.0b1.tar.gz -
Subject digest:
3bb007d969314aa0706777541be430cde5b35af02588089900b890bc53d6367e - Sigstore transparency entry: 1591174192
- Sigstore integration time:
-
Permalink:
Polymarket/py-sdk@a50580b1d75812c8182c00ad7febdcaac29b88ff -
Branch / Tag:
refs/tags/polymarket-client-v0.1.0-b1 - Owner: https://github.com/Polymarket
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a50580b1d75812c8182c00ad7febdcaac29b88ff -
Trigger Event:
release
-
Statement type:
File details
Details for the file polymarket_client-0.1.0b1-py3-none-any.whl.
File metadata
- Download URL: polymarket_client-0.1.0b1-py3-none-any.whl
- Upload date:
- Size: 178.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec46543a523a9bed2879b17301b608a1652437021cb155728c3d29be29423978
|
|
| MD5 |
574b4ca9cde9194b57314b94e6b30b64
|
|
| BLAKE2b-256 |
6b1bfe0f9f714c917becf9d1f026f1ffd5b4c96f6cddae413e6b639f51385c8d
|
Provenance
The following attestation bundles were made for polymarket_client-0.1.0b1-py3-none-any.whl:
Publisher:
publish.yml on Polymarket/py-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polymarket_client-0.1.0b1-py3-none-any.whl -
Subject digest:
ec46543a523a9bed2879b17301b608a1652437021cb155728c3d29be29423978 - Sigstore transparency entry: 1591174217
- Sigstore integration time:
-
Permalink:
Polymarket/py-sdk@a50580b1d75812c8182c00ad7febdcaac29b88ff -
Branch / Tag:
refs/tags/polymarket-client-v0.1.0-b1 - Owner: https://github.com/Polymarket
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a50580b1d75812c8182c00ad7febdcaac29b88ff -
Trigger Event:
release
-
Statement type: