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.1.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.1.0
File Size Uploaded
pax_api-2.1.0.tar.gz 21.1 kB Details

Built distribution (wheel)

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

Total release size: 39.4 kB

Release files / pax_api-2.1.0.tar.gz

Download URL pax_api-2.1.0.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
552e0fad69a2266d0227a1f6046c832c7c3884c27aff03ec9155729636476352
BLAKE2b-256 checksum
How to use checksums
b87470fb830961a250580e4a0c32eec3d4c5db53f76f9ec5ff48b9f9819c2f73
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.1.0-py3-none-any.whl

Download URL pax_api-2.1.0-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df9ec2f0c0e0d24ba6b7e6b02c4df94200fe25c7723fbb0f8b423b64090315d2
BLAKE2b-256 checksum
How to use checksums
f811bc19350e72812c81c6a683c5e26faba976c7fa4c5bb0e3aabf736cd2695a
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

This release

2.1.0 This release

2 release files

2.0.0

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