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.

Download files

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

Source Distribution

polyoxide-0.28.1.tar.gz (364.4 kB view details)

Uploaded Source

Built Distributions

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

polyoxide-0.28.1-cp39-abi3-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

polyoxide-0.28.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

polyoxide-0.28.1-cp39-abi3-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

polyoxide-0.28.1-cp39-abi3-macosx_10_12_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file polyoxide-0.28.1.tar.gz.

File metadata

  • Download URL: polyoxide-0.28.1.tar.gz
  • Upload date:
  • Size: 364.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for polyoxide-0.28.1.tar.gz
Algorithm Hash digest
SHA256 13b97e48425163fac6d7fc1b5b6b618a1cb1d8f2d046914c09bde94fc6b7ed65
MD5 26e11a6b47c061ab095cdd02ef92d1f1
BLAKE2b-256 75af560523fab3a30a055c644ecb2e7e01c471f170d8bd7492f23e6e7246fd74

See more details on using hashes here.

File details

Details for the file polyoxide-0.28.1-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for polyoxide-0.28.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e75b353d80784b4d513157ba70961f03eb53f231ea520b8836e138e6e5f09e7b
MD5 8c6b089d8357355eaab4fa817ed6ae8b
BLAKE2b-256 431ae1fdaacd45133bf43353c4501b42b3ff87612083a6732b3037b06cda7651

See more details on using hashes here.

File details

Details for the file polyoxide-0.28.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polyoxide-0.28.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a9884c8c1dd340ed71f35548980c5cfb6c40de59104ec7b324dcc01aab78446f
MD5 3470f2c81687a53fdf16a0020257c73b
BLAKE2b-256 54e9622bfb2b72a601d80079e5cd15206dd8e0b81703629b18d187e848522fe0

See more details on using hashes here.

File details

Details for the file polyoxide-0.28.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polyoxide-0.28.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e39603322be055380aa85869e13e0220548b54d61332e4ce0d372f5cd2f52b0
MD5 1e9aecab71dff21439e370a5452508a9
BLAKE2b-256 6bc43b3bd2718cf97e223fa32920fecbe187f3209fcd8a6f25696046853c6dee

See more details on using hashes here.

File details

Details for the file polyoxide-0.28.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for polyoxide-0.28.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 eca864d1f9225ea14384ca365dc17c5ce6f61c83aee293d932d871bd616a31e2
MD5 75b25e409369fa2d7034570634c60fe3
BLAKE2b-256 4c9ade7cae40a3bb42b3f75610282056277c997f764fc1c180ef8462fcfe59a3

See more details on using hashes here.

Release history Release notifications | RSS feed

0.29.0

5 files

This release

0.28.1 This release

5 files

0.28.0

5 files

0.27.0

5 files

0.26.1

5 files

0.26.0

5 files

0.25.0

5 files

0.24.2

5 files

0.24.1

5 files

0.24.0

5 files

0.23.0

5 files

0.22.0

5 files

0.21.0

5 files

0.20.0

5 files

0.19.0

5 files

0.18.2

5 files

0.18.1

5 files

0.18.0

5 files

0.17.0

5 files

0.16.0

5 files

0.15.1

5 files

0.15.0

5 files

0.14.0

5 files

0.13.0

5 files

0.12.5

5 files

0.12.4

5 files

0.12.3

5 files

0.12.2

5 files

0.12.1

5 files

0.12.0

5 files

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