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 (user positions and leaderboard)

import asyncio
from polyoxide import DataApi

async def main():
    data = DataApi()

    # Leaderboard
    leaders = await data.leaderboard().get(limit=10, time_period="WEEK")
    for t in leaders:
        print(t.user_name, t.pnl)

    # User positions
    positions = await data.user("0xADDRESS").list_positions(limit=5)
    for p in positions:
        print(p.title, p.size)

asyncio.run(main())

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.

Namespace Methods
.user(address) list_positions(...), positions_value(...), closed_positions(...), trades(...), activity(...), traded()
.trades() list(...)
.holders() list(markets, ...)
.open_interest() get(...)
.live_volume() get(event_id)
.leaderboard() get(...)
.builders() leaderboard(...), volume(...)
.health() ping()

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}")
Exception When
ApiError API returned an error response
AuthenticationError Invalid or missing credentials
ValidationError Request parameters failed validation
RateLimitError Rate limit exceeded (HTTP 429)
NetworkError Connection failure
TimeoutError Request timed out

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

A .pyi stub file is included at python/polyoxide/__init__.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.

Release files for polyoxide 0.30.0

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.30.0
File Size Uploaded
polyoxide-0.30.0.tar.gz 367.8 kB Details

Built distributions (wheels)

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

Total release size: 12.9 MB

Release files / polyoxide-0.30.0.tar.gz

Download URL polyoxide-0.30.0.tar.gz
Size 367.8 kB
Tags Source
SHA-256 checksum
How to use checksums
67a980691e93b671b6a5d3da354749d5ccb01da66bbe7b5485fff7a0adc6caae
BLAKE2b-256 checksum
How to use checksums
b5713ec686c42553ddfa359a1bf4e22f0025605a9b6b10b36d4e02acccfd28e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

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

Download URL polyoxide-0.30.0-cp39-abi3-win_amd64.whl
Size 3.4 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
fa555402a30d9278f77ff2a3ad365af2cf3f1eba1ae1180abc6b99a61bd829fd
BLAKE2b-256 checksum
How to use checksums
f3d7691ddbce3b53f729317b0cc8ea06172e5823614fbeae82d1086a4810b3d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

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

Download URL polyoxide-0.30.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.2 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
15854fa03529853cbead3b3288a7f9263c303622ada6314edd657557ec1c0e26
BLAKE2b-256 checksum
How to use checksums
45653b1708802695d17b40ed2907a56bbd48314d0e5fc32cbe1e7f1935927192
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

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

Download URL polyoxide-0.30.0-cp39-abi3-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bc8186cec7fe0af69e62c7a6298be2c308e1fd0221f1524d97aa1fc4e75514f9
BLAKE2b-256 checksum
How to use checksums
f86f2d5213eae5ce43be4232d298ac7acc3b00c9994503aa93fa8a4ac444b2c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

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

Download URL polyoxide-0.30.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 3.1 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
2eba314fbbeb5f700fb92bb758a4c1ef04dd6d5ba27ae42583c0a2536899ecf6
BLAKE2b-256 checksum
How to use checksums
229f42f84b784ea9817f77b980fb7a770afb8ce3e1f69554cb9b7c1bd3e30369
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0
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