Skip to main content

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+

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.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pax-api 2.0.0
File Size Uploaded
pax_api-2.0.0.tar.gz 20.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pax-api 2.0.0
File Interpreter ABI Platform
pax_api-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.6 kB

Release files / pax_api-2.0.0.tar.gz

Download URL pax_api-2.0.0.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8f61d39f2094088058a6e03da0f5de34785e706431aa5784d6cfc85aaea84d4e
BLAKE2b-256 checksum
How to use checksums
9b35e4c78149a27ddc12ddf74734d5bd19411a3148d2773ce06694912cbd88e8
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.0.0-py3-none-any.whl

Download URL pax_api-2.0.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1db82982fbfe6985fc9ed06dab1f23758cca0bf3d183a3fcc6ca32c2c6b89d9
BLAKE2b-256 checksum
How to use checksums
f727b41fc6ed75cd19da434b05f3f9e1aae1938313591e1a41520cadcdd62c92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release history Release notifications | RSS feed

2.4.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

This release

2.0.0 This release

2 release 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