pax-api — Official Python SDK for PredictAsiaX
REST + WebSocket client for the PredictAsiaX API gateway (https://api.predictasiax.com).
Version 3.0.0 · MIT license · Python 3.8+ · Changelog
- Docs: https://docs.predictasiax.com
- Verify: https://docs.predictasiax.com/verify — public audit-log verifier
- Sandbox key (anonymous):
POST /v1/sandbox-keys - Support: support@predictasiax.com
Install
pip install --upgrade pax-api
Quickstart
from pax_api import PaxClient
# Public endpoints need no key
pax = PaxClient()
print(pax.audit_status()["data"]["events"]["total"])
print(pax.get_orderbook("hadjar-f1-2026"))
# Mint a sandbox key (the api_key is shown once — store it)
key = pax.mint_sandbox_key(org_name="my-app")["data"]["api_key"]
pax = PaxClient(api_key=key) # sent as Authorization: Bearer sk_live_...
print(pax.get_balance())
print(pax.get_positions())
Credentials
| Mode | Constructor | Sent on the wire |
|---|---|---|
| API key | PaxClient(api_key="sk_live_...") |
Authorization: Bearer sk_live_... |
| HMAC signing | PaxClient(api_key="sk_live_...", key_id="api_...") |
PAX-ADDRESS, PAX-TIMESTAMP, PAX-NONCE, PAX-SIGNATURE (no key) |
| Session / OAuth | PaxClient(bearer_token="...") |
Authorization: Bearer ... |
HMAC signature (what the gateway verifies):
canonical = timestamp + "\n" + nonce + "\n" + METHOD + "\n" + path_with_query + "\n" + body
signature = base64(HMAC-SHA256(key = the full sk_live_ key, msg = canonical))
timestamp is Unix seconds (accepted window ±300 s), nonce is single-use, path_with_query includes /v1 and the query string. The SDK signs every attempt afresh, retries included. pax_api.auth.sign_request is exported if you need the headers yourself.
Trading
pax = PaxClient(api_key="sk_live_...", key_id="api_...")
order = pax.place_order(market_id="hadjar-f1-2026", side="yes", price="0.05", size="20")
pax.get_orders(status="open")
pax.cancel_order(order_id)
pax.cancel_all_orders(market_id="hadjar-f1-2026")
pax.place_orders_batch([
{"market_id": "hadjar-f1-2026", "side": "yes", "price": "0.04", "size": "25"},
{"market_id": "hadjar-f1-2026", "side": "no", "price": "0.90", "size": "5"},
])
place_order is a limit BUY of the chosen outcome (side="yes" or "no"), price 0.01–0.99.
Fee estimate
pax.estimate_fees(size="10", price="0.55", market_id="hadjar-f1-2026", side="yes")
Audit log verification
Every platform event is hash-chained and batched into SHA-256 Merkle trees. The SDK checks everything locally:
from pax_api import PaxClient, verify_event, verify_merkle_proof, expected_proof_length
pax = PaxClient()
result = pax.verify_audit_event(1866215)
print(result["ok"], result["checks"])
# checks: event_hash (sha256(prev_event_hash + canonical)), same_event,
# seq_in_batch, server_length_agrees, merkle (incl. proof length)
# Low level
proof = pax.audit_proof(1866215)["data"]
n = proof["batch"]["last_seq"] - proof["batch"]["first_seq"] + 1
verify_merkle_proof(proof["event_hash"], proof["batch"]["merkle_root"],
proof["merkle_proof"], expected_proof_length(n))
verify_merkle_proof requires expected_length: a proof with any other number of siblings is rejected, so an interior node cannot pass as a leaf. A root read from the same API proves internal consistency; for an independent check pass the anchored root (pax.audit_anchor(batch_num)) as root=.
WebSocket streams
See examples/03_websocket.py and PaxWSClient.
Error handling
Every response error becomes a typed exception:
from pax_api import (
PaxClient,
PaxRateLimitError,
PaxReadOnlyModeError,
PaxValidationError,
PaxWrongEnvKeyError,
PaxError, # base class — catch-all
)
try:
pax.place_order(...)
except PaxRateLimitError as e:
time.sleep(e.retry_after or 5)
except PaxValidationError as e:
print(f"Bad request: {e.details}")
except PaxReadOnlyModeError:
print("Trading paused by ops")
except PaxWrongEnvKeyError:
print("Wrong environment key")
except PaxError as e:
print(f"[{e.code}] {e.message} (request_id={e.request_id})")
Automatic retry
Built-in exponential backoff on 429, 500, 502, 504. Retry-After header respected on rate limits. Each mutating call gets one Idempotency-Key, reused by every retry of that call; place_order also fixes its client_order_id before the first attempt, so a retry can never place a second order.
pax = PaxClient(api_key=key, max_retries=5)
# max_retries=1 disables retries
Base URL
The gateway is https://api.predictasiax.com; methods add the /v1/... path themselves. A base_url ending in /v1 is accepted and normalised. Sandbox and production share the host: sandbox is a tier on the key (tier=self_serve), with per-order and per-day caps.
Applications (progressive trust)
Move from sandbox → trade-capped → trade-full by submitting an application:
res = pax.apply(track="self_serve", org="my-org", email="team@my-org.io")
print(res["data"]["application_code"]) # save this
status = pax.get_application(res["data"]["application_code"])
print(status["data"]["status"]) # submitted → in_review → approved / declined
Development
git clone https://github.com/predictasiax/pax-python-sdk
cd pax-python-sdk
pip install -e ".[dev]"
pytest # run all tests
ruff check src tests # lint
mypy src # type-check
Links
- OpenAPI spec
- AsyncAPI (WebSocket) spec
- Auth guide
- Verify (public Merkle verifier)
- Error codes
- Rate limits
- FAQ
- Changelog
- API Terms
License
MIT — see LICENSE.
Metadata
Release files for pax-api 3.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pax_api-3.0.1.tar.gz | 28.5 kB | Without provenance | Details for pax_api-3.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pax_api-3.0.1-py3-none-any.whl | Python 3 | none | any | Details for pax_api-3.0.1-py3-none-any.whl |
Total release size: 51.4 kB
Release files / pax_api-3.0.1.tar.gz
| Download URL | pax_api-3.0.1.tar.gz |
|---|---|
| Size | 28.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b49248147362e3474d6935d5289227e0b48a9b60739b2958311480bd6bf4fa3
|
|
BLAKE2b-256 checksum How to use checksums |
9a69cf92b4d58e4b779703b77689466ee38f191f4705fc0245e7aecb6c949ad1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / pax_api-3.0.1-py3-none-any.whl
| Download URL | pax_api-3.0.1-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c1cd62cf4317866e4e3909b077c468a96929a9837a3ef37e6d54f38a457f4bd8
|
|
BLAKE2b-256 checksum How to use checksums |
e15a046a7b382dc52528768a230a4b8131d37bd849159d99bb8a8ef1f0fc79a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for pax-api 3.0.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.