PolyOrderbooks Python SDK
Official Python client for the PolyOrderbooks API — historical Polymarket order books, prices, and liquidity metrics.
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— 401NotFoundError— 404RateLimitError— 429APIError— other HTTP failures
Development
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
Links
- Product: polyorderbooks.com
- Docs: docs.polyorderbooks.com
- OpenAPI: docs.polyorderbooks.com/openapi.json
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8245f4b4f7c7f57630fd3e7b400845bb8deedd60b286d8ca6cb1fd0d617b9d01
|
|
| MD5 |
d6b834e7de32bec35cd9e1c84b422007
|
|
| BLAKE2b-256 |
e692c0b99b5c095981d8069905b19bc63aea4e130a71171577666b1c3e76bc5e
|
Provenance
The following attestation bundles were made for polyorderbooks-0.1.0.tar.gz:
Publisher:
publish.yml on polyorderbooks/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polyorderbooks-0.1.0.tar.gz -
Subject digest:
8245f4b4f7c7f57630fd3e7b400845bb8deedd60b286d8ca6cb1fd0d617b9d01 - Sigstore transparency entry: 2343302447
- Sigstore integration time:
-
Permalink:
polyorderbooks/python-sdk@2ea73ec6f6b0e48067ea768dc4bb73e76f391a3c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/polyorderbooks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ea73ec6f6b0e48067ea768dc4bb73e76f391a3c -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05e3df4d04d2c116312173e436da98770b9b15fd66b8734b3b545c3f5e292385
|
|
| MD5 |
853aea4b76dac2d00cc8f7802d653954
|
|
| BLAKE2b-256 |
ada5883377d19b4685f921e8cf86a5582d85bf77a199dd93275105ea6e587430
|
Provenance
The following attestation bundles were made for polyorderbooks-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on polyorderbooks/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polyorderbooks-0.1.0-py3-none-any.whl -
Subject digest:
05e3df4d04d2c116312173e436da98770b9b15fd66b8734b3b545c3f5e292385 - Sigstore transparency entry: 2343302515
- Sigstore integration time:
-
Permalink:
polyorderbooks/python-sdk@2ea73ec6f6b0e48067ea768dc4bb73e76f391a3c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/polyorderbooks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ea73ec6f6b0e48067ea768dc4bb73e76f391a3c -
Trigger Event:
push
-
Statement type: