# Prediction Market API

![PredictAsiaX — Asia's Prediction Market. Real-Time Foresight.](https://docs.predictasiax.com/assets/banner.jpg)

Web3-native prediction market API

REST + WebSocket · One price model · Deterministic IDs · HMAC + Bearer + API key auth · self-serve sandbox tier

[Get Started →](https://docs.predictasiax.com/getting-started) [REST Reference](https://docs.predictasiax.com/openapi) [WebSocket Reference](https://docs.predictasiax.com/asyncapi)

### [REST API](https://docs.predictasiax.com/openapi)

209 paths / 240 operations across 21 tag groups (Discovery, Builders, Apps, Attribution, Revenue, Orders, Auth, Subaccounts, Competitions, Composer, Weather, Liquidity, Data, Webhooks, Marketplace, Oracle, Sandbox, Audit, Portfolio, Copy trading, Provider Keys). Envelope response + Money as decimal string.

### [WebSocket API](https://docs.predictasiax.com/asyncapi)

Single connection with subscription filtering. 39 public channels, 16 account channels and 20 account pushes, controlled with 6 client commands. High-throughput multiplexed stream.

### [Sandbox — 30 seconds](https://docs.predictasiax.com/sandbox/)

Anonymous self-serve key via `POST /v1/sandbox-keys`. Same production host. Tier-capped at $10/order + $100/day. Starts with 1,000 virtual USDT; orders fill against the live market price in a simulation, never with real funds. No email required.

### [Getting Started](https://docs.predictasiax.com/getting-started)

Mint sandbox key → list markets → place a $1 order → see fee_ledger split → cancel. 5-minute curl walkthrough.

### [Authentication](https://docs.predictasiax.com/auth)

Bearer `sk_live_*` + OAuth 2.1 PKCE for hosted apps; live HMAC request signing.

### [Downloads](https://docs.predictasiax.com/downloads)

OpenAPI + AsyncAPI in YAML/JSON. Postman collection + sandbox/prod environments. Codegen ready.

### [Verify](https://docs.predictasiax.com/verify)

Public Merkle verifier over the operational ledger. Reconstruct proofs client-side and confirm any fill was included in a signed, R2-anchored batch. Six no-auth read endpoints under `/v1/audit/*`.

### [Fees](https://docs.predictasiax.com/fee-architecture)

PAF adaptive taker curve (8-20 bps effective; peak at 50/50 = PAF_BASE 20 bps, floor 8 bps at extremes), maker rebate of 5–20% of the taker fee by 30-day volume-share tier, 7-actor split, per-market MM stipend pool. Every market maker is on the same automatic program. Real-time LQF disclosure API at `/v1/lqf/config`.

## Get started in 30 seconds

#### 1. Mint an API key

Sign in on [predictasiax.com](https://predictasiax.com) → Settings → API Keys, or mint an anonymous sandbox key via `POST /v1/sandbox-keys`. All keys are `sk_live_*` prefixed; sandbox is differentiated by `tier=sandbox` on the key (not by prefix).

#### 2. List markets (public)

```
curl https://api.predictasiax.com/v1/markets \
  -H "Authorization: Bearer sk_live_..."
```

#### 3. Subscribe to fast ticks

```
wscat -c wss://predictasiax.com/ws
> {"method":"SUBSCRIBE","params":["fast_tick"]}
```

## Design principles

### One price model

One price model for every market. One `price` field, one `size` field.

### Deterministic IDs

Market IDs are `m_<sha256[0:16]>` — idempotent create. Repeat `POST /v1/markets` returns the same market.

### Web3 privacy first

Email, phone, IP stripped from external responses by default. Self-view paths (`/v1/account`) preserve. `X-PII-Redacted` header always present.

### Money as string

USDT 6dp, BTC 8dp, ETH 18dp — never JavaScript numbers (loses precision). `"1000.234567"` not `1000.234567`.

### Envelope + snake_case

`{ok, data, meta}` on every canonical response. Deep snake_case keys. Timestamps have `*_at_ms` sibling for easy Date construction.

### Chain-agnostic architecture

Settlement layer is fully abstracted — every core table carries a `chain_data` JSONB envelope so on-chain metadata (block, tx hash, chain_id) rides alongside off-chain ledger rows without breaking client integrations.

## Authentication

### API Key sk_live_*

Send `Authorization: Bearer sk_live_…`. The tier flag on the key controls capability — `sandbox` for sandbox keys, `read_live` / `trade_capped` / `trade_full` / `genesis` / `partner` for production. Same prefix, same host, promote by upgrading tier.

### OAuth 2.1 + PKCE

Apps acting on a PAX builder account get an access token from [connect.predictasiax.com](https://connect.predictasiax.com) (builder account sign-in) and send it as a Bearer. To trade for regular users, use [App connections](https://docs.predictasiax.com/builders#app-connections). Rotating refresh; reuse of a refresh token revokes the whole family.

### HMAC request signing

Live per-request signing for machine-to-machine clients. Every active API key can sign over the `PAX-ADDRESS / TIMESTAMP / NONCE / SIGNATURE` headers (`POLY-*` aliases accepted) — no ops provisioning. Keys issued before launch rotate once to enable.

## Rate limits

Per API key, fixed 60-second window, per-endpoint-category. Responses carry `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`; a `429` adds `Retry-After` — the exact wait until the window resets.

### Per-scope buckets sk_live_*

Independent fair-use buckets per endpoint category — read exhaustion never blocks trading, and vice versa. A 429 states the scope, the limit and the exact wait in `error.details`. See [Rate Limits](https://docs.predictasiax.com/rate-limits) for the full per-scope table.

### Identical at every tier

The published per-scope limits are the same for `sandbox`, `self_serve`, `read_live`, `trade_capped`, `trade_full`, `genesis` and `partner`. Trust tiers raise your *notional* ceilings (per-order + daily), never your request rate — see [Rate Limits](https://docs.predictasiax.com/rate-limits).

Source: https://docs.predictasiax.com/
