Skip to main content

PolyOrderbooks Python SDK

Official Python client for the PolyOrderbooks API — historical Polymarket order books, prices, and liquidity metrics.

CI

Install

pip install polyorderbooks

Or install the latest from GitHub:

pip install git+https://github.com/polyorderbooks/python-sdk.git

Quickstart

Get an API key from polyorderbooks.com/signup, then:

import os
from datetime import datetime, timedelta, timezone

from polyorderbooks import PolyOrderbooksClient

client = PolyOrderbooksClient(api_key=os.environ["POLYORDERBOOKS_API_KEY"])

# Or rely on POLYORDERBOOKS_API_KEY in the environment:
# client = PolyOrderbooksClient()

markets = client.list_markets(search="bitcoin", limit=5)
slug = markets["data"][0]["slug"]

end = datetime.now(timezone.utc)
start = end - timedelta(hours=6)

books = client.get_market_books(
    slug,
    start_ts=start.isoformat().replace("+00:00", "Z"),
    end_ts=end.isoformat().replace("+00:00", "Z"),
    resolution="60s",
    limit=100,
)

for outcome, points in books["data"].items():
    for point in points[:2]:
        bids = point.get("b") or []
        asks = point.get("a") or []
        best_bid = bids[0][0] if bids else None
        best_ask = asks[0][0] if asks else None
        print(point["t"], outcome, "bid", best_bid, "ask", best_ask)

client.close()

Context manager usage:

with PolyOrderbooksClient() as client:
    usage = client.get_usage()
    print(usage["plan"], usage["limits"])

Pagination

Use metadata.next_cursor manually, or helpers:

for page in client.iter_market_books(
    slug,
    start_ts="2026-04-01T00:00:00Z",
    end_ts="2026-04-02T00:00:00Z",
    resolution="60s",
):
    process(page["data"])

API coverage

Method Endpoint
get_usage() GET /v1/usage
list_series(...) GET /v1/series
list_events(...) GET /v1/events
list_markets(...) GET /v1/markets
get_market(id_or_slug) GET /v1/markets/{id_or_slug}
list_tags() GET /v1/tags
get_market_metrics(...) GET /v1/markets/{id_or_slug}/metrics
get_market_prices(...) GET /v1/markets/{id_or_slug}/prices
get_market_books(...) GET /v1/markets/{id_or_slug}/books
get_token_prices(...) GET /v1/tokens/{token_id}/prices
get_token_books(...) GET /v1/tokens/{token_id}/books

Authentication

Send your API key via the client constructor or POLYORDERBOOKS_API_KEY. The SDK sets X-API-Key on every request (the API also accepts Authorization: Bearer pob_…).

Errors

from polyorderbooks import AuthenticationError, NotFoundError, RateLimitError, APIError
  • AuthenticationError — 401
  • NotFoundError — 404
  • RateLimitError — 429
  • APIError — other HTTP failures

Development

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest

Links

License

MIT — see LICENSE.

Download files

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

Source Distribution

polyorderbooks-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

polyorderbooks-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file polyorderbooks-0.1.0.tar.gz.

File metadata

  • Download URL: polyorderbooks-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for polyorderbooks-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8245f4b4f7c7f57630fd3e7b400845bb8deedd60b286d8ca6cb1fd0d617b9d01
MD5 d6b834e7de32bec35cd9e1c84b422007
BLAKE2b-256 e692c0b99b5c095981d8069905b19bc63aea4e130a71171577666b1c3e76bc5e

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on polyorderbooks/python-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 polyorderbooks-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: polyorderbooks-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for polyorderbooks-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05e3df4d04d2c116312173e436da98770b9b15fd66b8734b3b545c3f5e292385
MD5 853aea4b76dac2d00cc8f7802d653954
BLAKE2b-256 ada5883377d19b4685f921e8cf86a5582d85bf77a199dd93275105ea6e587430

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on polyorderbooks/python-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