# ダウンロード

機械可読な仕様書 + Postman コレクション。独自のSDKをコード生成するか、任意のHTTPツールにインポートできます。

## OpenAPI 3.1 (REST)

パブリックREST仕様 — **21のタググループにまたがる209パス / 240操作**: Discovery、Builders、Apps、Attribution、Revenue、Orders、Auth、Subaccounts、Competitions、Composer、Weather、Liquidity、Data、Webhooks、Marketplace、Oracle、Sandbox、Audit、Portfolio、Copy trading、Provider Keys。監査チェーン (`/v1/audit/head`、`/root`、`/batches`、`/health`、`/anchor`) はパブリックであり、認証不要です。管理/チーム/決済エンドポイントはランタイムに存在しますが、パブリック仕様からは意図的に省略されています。[openapi-generator](https://openapi-generator.tech) (50以上のターゲット言語) によるコード生成に対応。

| 形式 | ファイル | サイズ | 用途 |
|---|---|---|---|
| YAML | [openapi.yaml](https://docs.predictasiax.com/downloads/openapi.yaml) | 273 KB | 人間が読めやすく、差分が取りやすい |
| JSON | [openapi.json](https://docs.predictasiax.com/downloads/openapi.json) | 388 KB | Redoc / Swagger UI / コード生成ツール |

```
# Codegen Python client
openapi-generator generate -i https://docs.predictasiax.com/downloads/openapi.json -g python -o pax-python-client

# Codegen TypeScript axios client
openapi-generator generate -i https://docs.predictasiax.com/downloads/openapi.json -g typescript-axios -o pax-ts-client

# Codegen Go client
openapi-generator generate -i https://docs.predictasiax.com/downloads/openapi.json -g go -o pax-go-client
```

## AsyncAPI 2.6 (WebSocket)

WebSocket仕様 — **サーバーメッセージ78種（Ev*）+ クライアントメッセージ7種（Cmd*：6つのコマンドとpingによるキープアライブ）**、合計85種が`components.messages`に定義されています。各メッセージには`x-access`が付与されます：`public`チャネル39、`account`チャネル16（AUTH後のSUBSCRIBE）、`push`イベント12（自身の認証済みソケットに送信）、`control`応答11。クライアントコマンド：`AUTH` / `SUBSCRIBE` / `UNSUBSCRIBE` / `LOCALE` / `RFQ_SUBSCRIBE` / `RFQ_UNSUBSCRIBE`（RFQ系2つの動詞は、クォーテーション要求の更新用にソケットを登録します）。publicおよびaccountチャネルのリストは、ライブゲートウェイのACLと一致します。

| 形式 | ファイル | サイズ | 用途 |
|---|---|---|---|
| YAML | [asyncapi.yaml](https://docs.predictasiax.com/downloads/asyncapi.yaml) | 50 KB | 人間が読めやすく、差分が取りやすい |
| JSON | [asyncapi.json](https://docs.predictasiax.com/downloads/asyncapi.json) | 73 KB | AsyncAPI Studio、コード生成ツール |

```
# Codegen Node.js WebSocket client from AsyncAPI
npm i -g @asyncapi/generator
ag https://docs.predictasiax.com/downloads/asyncapi.json @asyncapi/nodejs-ws-template -o pax-ws-client
```

## Postman Collection

PredictAsiaX は [Postman のパブリックワークスペースとして公開されています](https://www.postman.com/predictasiax-2938441/predictasiax-api)。ご自身の Postman ワークスペースにフォークすると、仕様のバージョンアップに伴って自動的に同期されます:

- **ワークスペース**: `PredictAsiaX API` · 1 コレクション + 2 環境 (production + sandbox)。
- **Fork**: Postmanにサインイン → ワークスペースを開く → *Fork Collection*をクリック。
- **環境設定**: フォーク後、`PAX Sandbox` 環境を編集し、`apiKey` を `POST /v1/sandbox-keys` から取得した `sk_live_*` に設定してください。

直接ダウンロード（エアギャップ環境/監査レビュー用ミラー）:

| ファイル | 目的 | サイズ |
|---|---|---|
| [postman.json](https://docs.predictasiax.com/downloads/postman.json) | コレクション — openapi.json から生成された、サンプルボディ付きの全239件のパブリックREST操作。環境変数に `apiKey` を設定してください | 486 KB |
| [pax-sandbox.postman_environment.json](https://docs.predictasiax.com/downloads/pax-sandbox.postman_environment.json) | サンドボックス環境 — `baseUrl`、`apiKey`、HMACシークレット | <1 KB |
| [pax-production.postman_environment.json](https://docs.predictasiax.com/downloads/pax-production.postman_environment.json) | 本番環境 — 構造は同じで、本番URLを使用 | <1 KB |

### Postman にインポート

1. Postman を開き、**Import**（左上）をクリックします。
2. 3つのファイルすべて（コレクション + 2つの環境）をドラッグするか、URLを貼り付けてください:
  ```
  https://docs.predictasiax.com/downloads/postman.json
  https://docs.predictasiax.com/downloads/pax-sandbox.postman_environment.json
  https://docs.predictasiax.com/downloads/pax-production.postman_environment.json
  ```
3. 右上の環境セレクター → **PAX Sandbox**を選択。
4. Environment タブ → `apiKey` にサンドボックスキー（`POST /v1/sandbox-keys`、tier=sandbox）の `sk_live_*` を入力します。保存します。
5. 任意のリクエストを開き、**Send** をクリックします。完了です。

**Postman → cURL:** Postmanでリクエストを設定した後、リクエストパネルの右上にある**Code**ボタンをクリックすると、同等のcURL、Python、Node、またはGoのスニペットをコピーできます。

## MCPサーバー

PredictAsiaX は [公式 MCP レジストリ](https://registry.modelcontextprotocol.io/v0/servers?search=predictasiax) に `com.predictasiax/mcp` として公開されています。AIエージェントアプリ（Claude Desktop、Cursor、Windsurf、カスタムエージェント）は、MCP クライアントのレジストリ検索を通じてサーバーを発見し、直接接続できます。

| フィールド | 値 |
|---|---|
| レジストリ名 | `com.predictasiax/mcp` |
| サーバーURL | `https://mcp.predictasiax.com` |
| トランスポート | SSE + ストリーム可能なHTTP |
| 認証 | Bearer `sk_live_*`（`POST /v1/sandbox-keys` でセルフサーブ発行）; 公開データ（マーケット、オーダーブック、手数料、ドキュメント）を読み取る19のツールには認証情報不要 |
| ツール (46) | `market_search`、`market_get`、`market_orderbook`、`market_price_history`、`probability_movers`、`markets_top_volume`、`category_list`、`portfolio_read`、`portfolio_history`、`balance_get`、`positions_list`、`subaccount_list`、`place_order`、`cancel_order`、`cancel_all_orders`、`orders_open`、`orders_history`、`fee_estimate`、`mm_stipend_estimate`、`mm_stipend_history`、`liquidity_leaderboard`、`subaccount_create`、`subaccount_transfer`、`subaccount_close`、`composer_templates_list`、`composer_template_get`、`composer_proposal_submit`、`resolution_evidence`、`mm_quote_post`、`mm_quotes_list`、`rfq_create`、`rfq_accept`、`builder_me`、`builder_apps_list`、`builder_apikeys_list`、`tier_status`、`fee_ledger_read`、`webhook_endpoints_list`、`webhook_create`、`webhook_deliveries`、`access_request_create`、`access_request_status`、`docs_search`、`docs_read`、`sandbox_agent_examples`、`health` — `tools/list` 経由でネームスペース付きの `pax.*` |

## SDKs

ネイティブ SDK が利用可能です。どちらも `https://api.predictasiax.com` のゲートウェイをターゲットとし（メソッドは `/v1/…` パスを追加）、Bearer または HMAC（`PAX-*` ヘッダー）認証、オフライン監査検証ツール、書き込み時の自動 `Idempotency-Key` 生成、および安全なデフォルト設定（HTTPS のみ、ストリーミングレスポンス上限、CRLF ヘッダーガード、レスポンスボディサイズ上限 10 MB）をサポートしています。

| 言語 | パッケージ | バージョン | インストール |
|---|---|---|---|
| Python | `pax-api` | 3.3.2 LIVE | `pip install "pax-api>=3"` |
| TypeScript / JavaScript | `@predictasiax/api` | 3.4.1 LIVE | `npm i @predictasiax/api@3` |
| Go | OpenAPI コード生成による | — | `oapi-codegen -package pax https://docs.predictasiax.com/downloads/openapi.yaml` |
| Rust | OpenAPI コード生成による | — | `openapi-generator generate -g rust -i https://docs.predictasiax.com/downloads/openapi.json` |
| その他の 50 以上の言語 | OpenAPI コード生成による | — | `openapi-generator generate -g <lang> -i https://docs.predictasiax.com/downloads/openapi.json` |

### TypeScript クイックスタート

```
# npm i @predictasiax/api@3    (2.x cannot authenticate against the current gateway)
import { PaxClient } from '@predictasiax/api';

// 1. Public endpoints need no key; mint a sandbox key (api_key is shown once)
const pub = new PaxClient();
const minted = await pub.sandboxKeys.mint({ orgName: 'my-app' });

// 2. Use the key: Authorization: Bearer sk_live_...
//    (or { apiKey, keyId: 'api_...' } to HMAC-sign with PAX-* headers instead)
const pax = new PaxClient({ apiKey: minted.api_key });

for await (const market of pax.markets.list({ category: 'crypto' })) {
  console.log(market.id, market.title);
}

// Limit BUY of one outcome. Idempotency-Key and client_order_id are generated
// once per call and reused across retries.
const { data, requestId } = await pax.orders.place({
  marketId: 'hadjar-f1-2026', side: 'yes', price: '0.05', size: '20',
}).withResponse();
console.log('Order:', data, 'Request:', requestId);

// Price an order first (public, nothing placed), then wait for the fill and the settlement.
// Both waits read the result over REST and ride out 429, 5xx and network errors.
const q = await pub.markets.quote('hadjar-f1-2026', { side: 'yes', amount: 25 });
console.log(q.fill?.avg_price, q.fill?.fee_usdt, q.fill?.filled_all);
const { status, filledSize } = await pax.orders.waitForFill(data, { marketId: 'hadjar-f1-2026', timeoutMs: 30_000 });
const res = await pub.markets.waitForSettlement('hadjar-f1-2026');   // until status "settled"

// Offline audit verification
console.log((await pub.audit.verify(110841)).ok);

// WebSocket streaming
import { PaxWSClient } from '@predictasiax/api';
const ws = new PaxWSClient({ apiKey: minted.api_key, subscribeOnConnect: ['fast_tick', 'account'] });
ws.on('fast_tick', (e) => console.log(e));
await ws.connect();
```

### Python クイックスタート

```
# pip install "pax-api>=3"    (2.x cannot authenticate against the current gateway)
from pax_api import PaxClient

# 1. Public endpoints need no key; mint a sandbox key (api_key is shown once)
key = PaxClient().mint_sandbox_key(org_name="my-app")["data"]["api_key"]

# 2. Use the key: Authorization: Bearer sk_live_...
#    (or PaxClient(api_key=key, key_id="api_...") to HMAC-sign instead)
pax = PaxClient(api_key=key)
print(pax.get_balance())

# 3. Limit BUY of one outcome; client_order_id + Idempotency-Key fixed across retries
order = pax.place_order(market_id="hadjar-f1-2026", side="yes", price="0.05", size="20")

# Price an order first (public, nothing placed), then wait for the fill and the settlement.
# Both waits read the result over REST and ride out 429, 5xx and connection errors.
q = PaxClient().quote("hadjar-f1-2026", side="yes", amount=25)["data"]
print(q["fill"])
r = pax.wait_for_fill(order, market_id="hadjar-f1-2026", timeout=30)   # r["status"], r["filled_size"]
res = PaxClient().wait_for_settlement("hadjar-f1-2026")                 # until status "settled"

# Offline audit verification
print(PaxClient().verify_audit_event(110841)["ok"])

# WebSocket streaming (multiplexed subscriptions, sequence# gap detection)
from pax_api import PaxWSClient
ws = PaxWSClient(api_key=key)
ws.on("fast_tick", lambda evt: print("tick:", evt))
ws.subscribe(["fast_tick", "orderbook", "account"])
ws.run_forever()
```

直接ダウンロード（エアギャップ環境 / 監査レビュー用のミラー。PyPI と同じファイルです）: [pax_api-3.3.2-py3-none-any.whl](https://docs.predictasiax.com/downloads/sdk/python/pax_api-3.3.2-py3-none-any.whl) (SHA-256 `6be3f9ad00533b540728239b7ec133dcbfe8d118b3f3269b027765b659077bc3`) · [pax_api-3.3.2.tar.gz](https://docs.predictasiax.com/downloads/sdk/python/pax_api-3.3.2.tar.gz) (SHA-256 `c4ef72a0dbbe155f9a0c7ffd458211bb5de7198d5952b88a5bfe219fe3437c3a`).

## モックサーバー (Prism)

オフライン開発用に、OpenAPI 仕様に対してローカルモックサーバーを起動します:

```
npm i -g @stoplight/prism-cli
prism mock https://docs.predictasiax.com/downloads/openapi.json
# → mock server on http://localhost:4010
```

Prism は OpenAPI の例に従ってダミーのレスポンスを生成します。サンドボックスへのアクセスがプロビジョニングされる前の CI やクライアント開発に最適です。

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