pax-api — Official Python SDK for PredictAsiaX
Web3-native prediction market REST + WebSocket API client. Polymarket-compatible HMAC signing pattern.
Version 1.0.0 · MIT license · Python 3.8+
- Docs: https://docs.predictasiax.com
- Developer landing: https://predictasiax.com/developer
- Get API key: https://predictasiax.com/settings/api-keys
- Support: support@predictasiax.com
Install
# Direct install from PredictAsiaX-hosted wheel
pip install https://docs.predictasiax.com/downloads/sdk/python/pax_api-1.0.0-py3-none-any.whl
# Or download tarball + install locally
curl -O https://docs.predictasiax.com/downloads/sdk/python/pax_api-1.0.0.tar.gz
pip install pax_api-1.0.0.tar.gz
(PyPI publish coming soon — install methods above work today.)
Quickstart (sandbox — no real money)
from pax_api import PaxClient
with PaxClient(api_key="sk_test_YOUR_KEY", env="sandbox") as pax:
faucet = pax.faucet() # get 10k test USDT
print(faucet["data"]["balance_free"]) # → "10000.000000"
templates = pax.list_templates()
markets = pax.list_markets(category="crypto", limit=10)
market = pax.create_market(
template_id="crypto_price_binary_60s",
params={"asset": "BTC"},
)
print(market["data"]["market"]["market_id"]) # → "m_..."
HMAC-signed requests (production)
Machine-to-machine trading bots should use HMAC signing (Polymarket-compatible 5-header pattern).
from pax_api import PaxClient
pax = PaxClient(
api_key="sk_live_YOUR_KEY",
secret="<64-hex secret>",
passphrase="<passphrase>",
env="production",
)
pax.place_order(
market_id="m_...",
outcome_id="yes",
side="buy",
order_type="limit",
size="100",
price="0.55",
client_order_id="unique-per-intent-id", # retry-safe within 24h
)
WebSocket streams
from pax_api import PaxWSClient
ws = PaxWSClient(
api_key="sk_test_...",
env="sandbox",
subscribe_on_connect=["fast_tick", "trade_executed", "account"],
)
ws.on("fast_tick", lambda e: print("tick:", e))
ws.on("trade_executed", lambda e: print("trade:", e))
ws.on("account", lambda e: print("balance:", e.get("balance_free")))
ws.run_forever() # blocks; Ctrl+C to exit
Auto-reconnect + exponential backoff built-in. All 4 client methods supported:
subscribe, unsubscribe, auth, set_locale.
Error handling
Every response error becomes a typed exception. Catch the specific type you want to handle:
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)
# then retry
except PaxValidationError as e:
print(f"Bad request: {e.details}") # {'field': 'size', ...}
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 responses. Retry-After
header respected on rate limits. Non-idempotent creates are safe when you send
client_order_id.
pax = PaxClient(api_key="sk_test_...", env="sandbox", max_retries=5)
# max_retries=0 disables retries entirely
Environments
| Env | Base URL | Keys |
|---|---|---|
production |
https://api.predictasiax.com/v1 |
sk_live_* |
sandbox |
https://api.predictasiax.com/v1 |
sk_test_* |
sk_test_* on production returns 401 WRONG_ENV_KEY. Same the other way. See
docs auth guide.
Custom base URL
pax = PaxClient(api_key="...", base_url="https://your-mirror/api")
Development
# Get source (tarball)
curl -O https://docs.predictasiax.com/downloads/sdk/python/pax_api-1.0.0.tar.gz
tar -xzf pax_api-1.0.0.tar.gz && cd pax_api-1.0.0
pip install -e ".[dev]"
pytest # run all tests
ruff check src tests # lint
mypy src # type-check
Links
License
MIT — see LICENSE.
Release files for pax-api 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pax_api-2.2.0.tar.gz | 21.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pax_api-2.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.5 kB
Release files / pax_api-2.2.0.tar.gz
| Download URL | pax_api-2.2.0.tar.gz |
|---|---|
| Size | 21.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95ce63103572ee4c6ef5dee1ce12af15f9d9d67eeb0f94a6d6eac53d3d18e605
|
|
BLAKE2b-256 checksum How to use checksums |
734518602621fe69666c807e18b8a199bf368ca2a9193dc596bdbf7fe3565e58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / pax_api-2.2.0-py3-none-any.whl
| Download URL | pax_api-2.2.0-py3-none-any.whl |
|---|---|
| Size | 18.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6cb6901f7e9d301a997c850614b3f7564388ea177854d9aeebbcbfe23bc8c70c
|
|
BLAKE2b-256 checksum How to use checksums |
ca72ee36dcdcb2dc5037cc3ac06f372bfa7eb576e3c2ff9c9809d036338e6dce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|