Skip to main content

Polyoxide

Python SDK for Polymarket APIs, powered by Rust via PyO3 and maturin.

Every client comes in async and sync variants. Async methods return Python awaitables; sync methods block via an internal Tokio runtime and release the GIL while waiting.

Async Sync API Description
Gamma GammaSync Gamma Market data, events, series, tags, comments, sports, search, users
ClobClient ClobClientSync CLOB Order book, prices, spreads, trade history, fee rates
DataApi DataApiSync Data User positions/trades/activity, leaderboard, holders, volume, open interest

Installation

pip install polyoxide

Wheels are published for Linux (x86_64, aarch64), macOS (x86_64, aarch64), and Windows (x86_64).

Quick Start

Async (Gamma -- market data)

import asyncio
from polyoxide import Gamma

async def main():
    gamma = Gamma()
    markets = await gamma.markets().list(limit=5, open=True)
    for m in markets:
        print(f"{m.question}  --  {m.slug}")

asyncio.run(main())

Sync (Gamma)

from polyoxide import GammaSync

gamma = GammaSync()
markets = gamma.markets().list(limit=5, open=True)
for m in markets:
    print(f"{m.question}  --  {m.slug}")

CLOB (order book data)

from polyoxide import ClobClientSync

clob = ClobClientSync()
book = clob.markets().order_book("TOKEN_ID")
print(book.bids, book.asks)

spread = clob.markets().spread("TOKEN_ID")
print(spread)

Data API

DataApi and DataApiSync serve the Data API's routes as methods (Polymarket retired Data API v1 on 2026-11-02, so they are v2's): snake_case fields, cursor-only paging, and errors with a stable code.

from polyoxide import DataApiSync

data = DataApiSync()

# One page, and the cursor for the next one
page = data.trades(limit=50)
print(len(page), page.pagination.next_cursor)

# Every page, re-sending the same filters each time
for page in data.iter_activity("0xADDRESS", types=["TRADE"], limit=500):
    for row in page.data:
        print(row.activity_type, row.usdc_size)

# A wallet's positions, and None, not an error, for a wallet the API does not know
positions = data.positions(user="0xADDRESS", limit=5)
stats = data.user_stats("0xADDRESS")

# The trader leaderboard
leaders = data.leaderboard(time_period="week", limit=10)

Async walks use async for page in DataApi().iter_trades(...). Enum arguments take the exact wire spelling (time_period="week", sort_direction="DESC"), and a value the route does not accept raises ValueError before any request is sent.

Client API Reference

Gamma / GammaSync

Constructed with optional base_url, timeout_ms, and pool_size keyword arguments.

Namespace Methods
.markets() get(id), get_by_slug(slug), list(...), tags(id)
.events() get(id), get_by_slug(slug), list(...), tags(id), tweet_count(id), comment_count(id)
.series() get(id), list(...)
.tags() get(id), get_by_slug(slug), list(...), get_related(id), get_related_by_slug(slug)
.comments() get(id), list(...), by_user(address)
.sports() list(), market_types(), list_teams(...)
.search() public_search(query, ...)
.user() get(address)
.health() ping()

ClobClient / ClobClientSync

No arguments required (uses public/unauthenticated endpoints).

Namespace Methods
.markets() get(condition_id), get_by_token_ids(token_ids), list(), order_book(token_id), price(token_id, side), midpoint(token_id), prices_history(token_id), neg_risk(token_id), fee_rate(token_id), tick_size(token_id), spread(token_id), last_trade_price(token_id), live_activity(condition_id), simplified(), sampling(), sampling_simplified(), calculate_price(token_id, side, amount)
.health() ping(), server_time()

DataApi / DataApiSync

Constructed with optional base_url, timeout_ms, and pool_size keyword arguments. Each route is a method: approvals, positions, combo_positions, user_pnl, user_stats, user_volume, value, activity, combo_activity, trades, holders, live_volume, open_interest, prices_history, resolutions, tokens, biggest_winners, builders_leaderboard, builder_volume, leaderboard, leaderboard_user and status; each paged route also has iter_<route>(...).

Result Objects

All response objects expose named properties matching the upstream JSON fields, plus:

  • .to_dict() -- convert to a plain Python dict
  • str(obj) -- JSON string representation
  • repr(obj) -- type-annotated representation

Error Handling

All exceptions inherit from PolyoxideError:

from polyoxide import PolyoxideError, ApiError, RateLimitError

try:
    markets = gamma.markets().list()
except RateLimitError:
    print("slow down")
except ApiError as e:
    print(f"API error: {e}")
except PolyoxideError as e:
    print(f"something else: {e}")

Each exception follows the error's class, one class to one exception, so the type never depends on the wording of a message:

Exception Class When
NetworkError Network No response arrived: a failed connect, a timeout, a dropped connection
UnavailableError Unavailable The venue is unavailable for now (408, 425, 5xx); retrying may succeed
RateLimitError RateLimited Rate limit exceeded (HTTP 429)
AuthenticationError Unauthorized Invalid or missing credentials (401, 403)
ValidationError InvalidRequest Refused before sending: bad input, a URL that does not parse, a signing failure; and a v2 invalid_request
ApiError VenueRefusal The venue refused the request (any other 4xx, a 400 included); and a v2 error with any code not mapped below
RestrictedError Restricted The venue will not serve this caller (418, 451)
DecodeError Decode A response that did not decode, or a page walk that could not continue

A Data API error with its structured body maps by its code: invalid_request to ValidationError, rate_limited to RateLimitError, request_timeout to TimeoutError (a subclass of UnavailableError), and any other code to ApiError. Every exception also carries status, code, retryable, trace_id, parameter and retry_after, which are None unless the error came from a v2 route.

Async Support

Async clients (Gamma, ClobClient, DataApi) use pyo3-async-runtimes to bridge Rust futures into Python awaitables. They work with asyncio.run(), await, and any asyncio-compatible event loop.

Sync clients (GammaSync, ClobClientSync, DataApiSync) execute on a shared background Tokio runtime and release the GIL while blocking, so they are safe to use from threaded Python code.

Type Stubs

.pyi stub files are included at python/polyoxide/__init__.pyi and python/polyoxide/v2.pyi for editor autocomplete and type checking.

Building from Source

Requires Rust and Python 3.9+.

pip install maturin
maturin develop --release

License

Licensed under either of MIT or Apache-2.0 at your option.

Metadata

Release files for polyoxide 0.49.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polyoxide 0.49.1
File Size Uploaded Provenance Actions
polyoxide-0.49.1.tar.gz 1.3 MB Without provenance Details for polyoxide-0.49.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for polyoxide 0.49.1
File Actions
polyoxide-0.49.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for polyoxide-0.49.1-cp39-abi3-win_amd64.whl
polyoxide-0.49.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for polyoxide-0.49.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
polyoxide-0.49.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for polyoxide-0.49.1-cp39-abi3-macosx_11_0_arm64.whl
polyoxide-0.49.1-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for polyoxide-0.49.1-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 15.6 MB

Release files / polyoxide-0.49.1.tar.gz

Download URL polyoxide-0.49.1.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
85308c096c32eead267ad5c233de6015b873cc49a623845b0bb3d38f6667b68c
BLAKE2b-256 checksum
How to use checksums
2c9f4bc96f2ef2ef932bddeeb5417b6197638f0537a43a4f0a180b5c4f867476
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / polyoxide-0.49.1-cp39-abi3-win_amd64.whl

Download URL polyoxide-0.49.1-cp39-abi3-win_amd64.whl
Size 3.9 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8e913607413bb9a2655a46f935bba874a4306b607f6ae09161068da642cee1fb
BLAKE2b-256 checksum
How to use checksums
7236d96defbc3ae79fc30207205320aef42c3540639b899487992adcdd7b7c13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / polyoxide-0.49.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL polyoxide-0.49.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 3.6 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7f019ded591d15526b747f48102f158a383bc5f9fded85300f9495bc25a64b3a
BLAKE2b-256 checksum
How to use checksums
3c2b5f6dba3d32eebef4164922dab1a264ff5b991594d5d32383b5302d8e604b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / polyoxide-0.49.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL polyoxide-0.49.1-cp39-abi3-macosx_11_0_arm64.whl
Size 3.3 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
18e2b9ce898a00a9af39d1d9b5c5a97814864b24a081436a16b2bf3652ba11e6
BLAKE2b-256 checksum
How to use checksums
c8b0a0d5c7fb96e2375db529ced04cbb3db16a4cc4f4ae98c4ae87172934a795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / polyoxide-0.49.1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL polyoxide-0.49.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 3.5 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
9ceb605b0dddd2058cc6106e064a7646a2e5d2795256f3d35a9e85dc2a3db2ad
BLAKE2b-256 checksum
How to use checksums
fe8c78be4c4c4adc1244b39aed37d4389410e0c8574ddb632e782e65e0eb1254
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Security for polyoxide 0.49.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.49.1 This release

5 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page