Skip to main content

Official Python client for Polymarket

Project description

Polymarket Python SDK

Beta

Official Python SDK for Polymarket.

The SDK gives Python developers one coherent, workflow-oriented interface for building on Polymarket across public data, authenticated account, trading, builder attribution, and wallet workflows.

Beta Status

The Python SDK is currently in beta. We are working toward a stable public API and will use feedback during the beta period to refine the developer experience.

We welcome bug reports, feature requests, and general feedback through GitHub Issues. Please use the provided issue templates so we can triage reports consistently.

Installation

uv add --prerelease allow polymarket-client

or:

pip install --pre 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polymarket_client-0.1.0b11.tar.gz (254.2 kB view details)

Uploaded Source

Built Distribution

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

polymarket_client-0.1.0b11-py3-none-any.whl (223.3 kB view details)

Uploaded Python 3

File details

Details for the file polymarket_client-0.1.0b11.tar.gz.

File metadata

  • Download URL: polymarket_client-0.1.0b11.tar.gz
  • Upload date:
  • Size: 254.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for polymarket_client-0.1.0b11.tar.gz
Algorithm Hash digest
SHA256 dc82b99fdc6e96c9ccc1c1631838c1aa9639d16d3e24c51eedadf295c9a7518a
MD5 48d41b9720e87bccf343fc8651da8c03
BLAKE2b-256 4d2fa8d85076c67e3479203d6ca63d045e5f375e3aafed77814887156a751d46

See more details on using hashes here.

Provenance

The following attestation bundles were made for polymarket_client-0.1.0b11.tar.gz:

Publisher: release-please.yml on Polymarket/py-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polymarket_client-0.1.0b11-py3-none-any.whl.

File metadata

File hashes

Hashes for polymarket_client-0.1.0b11-py3-none-any.whl
Algorithm Hash digest
SHA256 57735439e35a83c105422e5e969496e213e70862ec1f9ea1d980edd520c8eeb7
MD5 34f2265dd263691ff47c5ace65fe42b6
BLAKE2b-256 1cf9c02ecd60641cf16a24d2c8644cd862de6e3e510bfccb30e9249dcd161ea4

See more details on using hashes here.

Provenance

The following attestation bundles were made for polymarket_client-0.1.0b11-py3-none-any.whl:

Publisher: release-please.yml on Polymarket/py-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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