快速入門

在 5 分鐘內下出你的第一筆預測市場訂單。全部使用 curl——無需 SDK。

以下所有 curl 指令皆針對真實的正式 API 執行。 你將在步驟 1 中鑄造一個匿名沙盒金鑰(30 秒完成,無需電子郵件)。沙盒等級將訂單限制為每筆 $10 / 每日 $100,因此你輸入的任何內容都不會動到真實資金。訂單會經過與正式環境相同的驗證與等級限制,然後在模擬中成交:金鑰初始擁有 1,000 虛擬 USDT,且回應會包含 is_simulated: true。

步驟 1 — 建立沙盒金鑰

公開端點,無需驗證。速率限制為每日每 IP 1 次 mint、每瀏覽器指紋 1 次。

curl -X POST https://api.predictasiax.com/v1/sandbox-keys \
  -H "Content-Type: application/json" \
  -d '{"org_name":"my-test"}'

回應 — 立即複製 sk,僅顯示一次:

{
  "data": {
    "sk":            "sk_live_7d40ce10_12b638913cadfbbd...",   // your bearer, shown ONCE
    "api_key_id":    "api_sbx_...",
    "builder_id":    "bld_sbx_...",
    "app_id":        "app_sbx_...",
    "tier":          "sandbox",
    "caps":          { "max_order_usdt": "10", "daily_notional_usdt": "100" },
    "expires_at_ms": 1789741484472,                            // 30 days out
    "sandbox_url":   "https://api.predictasiax.com",
    "docs_url":      "https://docs.predictasiax.com/getting-started",
    "upgrade_url":   "https://docs.predictasiax.com/request-access"
  },
  "meta": { "ts_ms": 1787149484561, "trace_id": "trc_..." }
}

# Save it:
export SK=sk_live_7d40ce10_12b638913cadfbbd...

如果沙盒金鑰洩漏,請使用該金鑰本身來撤銷它:curl -X DELETE https://api.predictasiax.com/v1/keys/self -H "Authorization: Bearer $SK"。

此金鑰屬於新創建的匿名 Builder,標記為 tier=sandbox,並將於創建後 30 天過期。它使用 sk_live_ 前綴,可於生產環境使用——等級標記會將訂單硬性限制為每筆 $10 且每日名目金額 $100。

步驟 2 — 列出市場

市場是 predictasiax.com 上的即時市場。選取一個並保留其 id 供下一步使用(MARKET_ID=...):

curl "https://api.predictasiax.com/v1/markets?q=btc" \
  -H "Authorization: Bearer $SK"

回應(已精簡):

{
  "data": {
    "markets": [
      {
        "id":        "m_btc_150k_2026",
        "title":     "BTC > $150k by end of 2026",
        "category":  "crypto",
        "prices":    { "yes": "0.4200", "no": "0.5800" },
        "volume_usd":"12345.67",
        "status":    "open",
        "closes_at_ms": 1798700400000
      }
    ]
  }
}

步驟 3 — 下達 $1 訂單

以 $0.55 買入 2 份 yes 股份 = $1.10 名目金額 — 遠低於沙盒 $10 上限。寫入操作必須包含 Idempotency-Key,且必須符合 [A-Za-z0-9_-]{8,128};使用相同值重試是安全的。

IDEM=$(uuidgen | tr -d '-' | cut -c1-24)
curl -X POST https://api.predictasiax.com/v1/orders \
  -H "Authorization: Bearer $SK" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ${IDEM}" \
  -d '{
    "market_id":       "'"$MARKET_ID"'",
    "side":            "yes",
    "price":           "0.55",
    "size":            "2",
    "client_order_id": "cli-001"
  }'

訂單規則。 size 為最多 6 位小數的純十進位數;price 介於 0.0001–0.9999 之間,最多 4 位小數(指數形式數字如 1e-7 會被拒絕)。在一般市場中,limit 與 post_only 的價格必須落在 tick 網格上:0.04 至 0.96 之間以 0.01 為步進,低於 0.04 及高於 0.96 以 0.001 為步進;未落在網格上的訂單將被拒絕,並回傳 rejectReason: invalid_tick 及適用的 tick。訂單名目金額 size × price 必須介於 1 至 100,000 USDT 之間。不符合這些規則的訂單將回傳 400 INVALID_FIELD、BELOW_MIN_NOTIONAL 或 ABOVE_MAX_NOTIONAL。

使用沙盒金鑰時,訂單為模擬。若價格高於或等於市場當前價格,則以該價格成交;若低於當前價格,則掛單(status: "open",金額保留在 reserved_usdt 中),並在價格達到你的限價時成交,此檢查會在每次你讀取訂單、持倉、餘額或投資組合時執行:

{
  "data": {
    "order_id":           "sbx_ord_...",
    "client_order_id":    "cli-001",
    "market_id":          "...",
    "side":               "yes",
    "limit_price":        "0.55",
    "size":               2,
    "filled_size":        2,
    "status":             "filled",
    "fill_price":         "0.42",
    "fill_notional_usdt": "0.84",
    "reserved_usdt":      "0",
    "is_simulated":       true
  },
  "meta": { "trace_id": "...", "is_simulated": true }
}

如果虛擬餘額無法覆蓋訂單,則不會建立該訂單:{"data": {"ok": false, "status": "REJECTED", "reject_reason": "insufficient_balance", ...}}。使用 DELETE /v1/orders/{order_id} 取消(預留資金將被退回)。沙盒中的持倉會以當前價格計價,且在市場結算時不會進行結算。

在具有餘額的生產環境金鑰上,成交會回傳訂單及其手續費拆分(僅供說明——確切的 splits 區塊由 PAX 在成交時透過伺服器端的 PAX Adaptive Fee 曲線推導得出):

{
  "data": {
    "order": {
      "order_id":     "ord_...",
      "status":       "filled",
      "filled_size":  "2",
      "fill_price":   "0.4200",
      "created_at_ms":1787149484561
    },
    "fee": {
      "taker_fee_bps":   20,                // PAF centre at 50/50, floor 8, ceiling 25
      "fee_total":       "0.001680",        // 20 bps of $0.84 notional
      "splits": {
        "acquisition_builder": "0.000000",  // unfilled → absorbed by platform_net
        "execution_builder":   "0.000000",  // 0 bps — builders earn their builder fee instead
        "operator":            "0.000000",  // 0 bps — PAX is the only operator; carried in platform_net
        "market_creator":      "0.000000",  // unfilled → absorbed by platform_net
        "mm_stipend_pool":     "0.000420",  // 5 bps — funds LQF-scored MM stipends
        "lp":                  "0.000168",  // 2 bps — pooled LP holder distribution
        "platform_net":        "0.001092"   // 10 bps residual + 3 (mc absorbed)
      },
      "attribution": {
        "execution_builder_id":   "sb_d5b09d2a...",   // your builder
        "acquisition_builder_id": null,
        "operator_id":            "op_pax_v3",
        "market_creator_id":      null,
        "builder_tier":           "trade_capped",
        "unfilled_roles":         ["acquisition_builder","market_creator"]
      }
    }
  }
}

splits 區塊透過 7 角色 PAF 拆分(acquisition_builder / execution_builder / operator / market_creator / mm_stipend_pool / lp / platform_net)在平台帳簿上寫入冪等的 financial_event 記錄。未分配的歸因角色會由 platform_net 吸收,以保護營收。自適應 Taker 手續費:feeBps = clamp(PAF_BASE_BPS · 4 · p · (1−p), PAF_FLOOR_BPS, PAF_CEILING_BPS),基礎值 20,下限 8,上限 25 —— 在 50/50 附近達到峰值,在極端值時下降。完整模型與分桶比例請見 手續費架構。

步驟 4 — 超出上限的請求(查看等級上限的實際運作)

嘗試下達一筆超過 $10 的訂單:

IDEM=$(uuidgen | tr -d '-' | cut -c1-24)
curl -X POST https://api.predictasiax.com/v1/orders \
  -H "Authorization: Bearer $SK" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ${IDEM}" \
  -d '{
    "market_id":"'"$MARKET_ID"'",
    "side":"yes","price":"0.50","size":"100",
    "client_order_id":"too-big"
  }'

回應 — 429 TIER_LIMIT_EXCEEDED:

{
  "error": {
    "code":    "TIER_LIMIT_EXCEEDED",
    "message": "order notional 50.00 exceeds tier max_order_usdt 10",
    "details": { "tier": "sandbox", "cap": "10" }
  }
}

若要解除上限並進行真實交易,請取得生產環境金鑰(申請存取,無需審核)並導入交易量——它會自動升級。當 30 天歸因交易量達到 $1,000 時,trade_capped(每單 $100,每日 $1k)將解鎖;達到 $50,000 時,trade_full(無上限)將解鎖。無需提交升級請求,也無人為步驟——請參閱 速率限制 → 提升等級。

步驟 5 — 讀取你的投資組合

curl "https://api.predictasiax.com/v1/portfolio" \
  -H "Authorization: Bearer $SK"

回傳你的未平倉持倉,並即時重算標記價格(即時計算未實現損益)。

步驟 6 — 取消訂單

兩種等效格式——在你的客戶端中選擇較清晰的一種:

# Canonical
curl -X DELETE https://api.predictasiax.com/v1/orders/ord_... \
  -H "Authorization: Bearer $SK"

# Alias (useful when your HTTP client can't send DELETE)
curl -X POST https://api.predictasiax.com/v1/orders/ord_.../cancel \
  -H "Authorization: Bearer $SK"

已成交的訂單會回傳 STATE_CONFLICT(無法取消已成交的訂單);未平倉的訂單會轉為 cancelled。

後續步驟

準備上線嗎? 主機與基礎 URL 相同 — https://api.predictasiax.com/v1。提交 申請存取 即可將你的 Builder 從 sandbox 升級至 trade_capped 或 trade_full 等級。無需切換環境或重新產生金鑰。