---
title: "Polymarket Kalshi API 預測市場賠率 | Narwhal API"
description: "Kalshi and Polymarket odds by topic and event: market shapes, history, venues and the WebSocket stream."
url: "https://narwhalapi.com/zh-tw/docs/api/predictions"
---

# Polymarket Kalshi API 參考文件

依主題與事件讀取預測機率，包含歷史資料、交易平台詳情與串流更新。

Narwhal 僅回傳機率，不提供官方數據或自有價格。 [概覽請參閱預測產品頁面。](https://narwhalapi.com/zh-tw/api/predictions.md)

## 端點

基礎 URL 為 `https://api.narwhalapi.com`。 傳送 `Authorization: Bearer $NARWHAL_API_KEY`。 每個 MCP 工具名稱都與其操作 ID 一致。

| 操作 ID | 方法與路徑 |
| --- | --- |
| `predictions_list_topics` | `GET /v1/predictions/topics` |
| `predictions_get_topic` | `GET /v1/predictions/topics/{topic_id}` |
| `predictions_list_events` | `GET /v1/predictions/events` |
| `predictions_get_scalar` | `GET /v1/predictions/scalar/{event_id}` |
| `predictions_get_extreme` | `GET /v1/predictions/extreme/{event_id}` |
| `predictions_get_timing` | `GET /v1/predictions/timing/{event_id}` |
| `predictions_get_binary` | `GET /v1/predictions/binary/{event_id}` |
| `predictions_get_scalar_history` | `GET /v1/predictions/scalar/{event_id}/history` |
| `predictions_get_extreme_history` | `GET /v1/predictions/extreme/{event_id}/history` |
| `predictions_get_timing_history` | `GET /v1/predictions/timing/{event_id}/history` |
| `predictions_get_binary_history` | `GET /v1/predictions/binary/{event_id}/history` |
| `predictions_get_policy_path` | `GET /v1/predictions/policy-paths/{authority}` |
| `predictions_get_policy_path_history` | `GET /v1/predictions/policy-paths/{authority}/history` |
| WebSocket | `/v1/predictions/stream` |

請求範例

```
curl --request GET \
  --url "https://api.narwhalapi.com/v1/predictions/scalar/usa-cpi-yoy-2026-09" \
  --header "Authorization: Bearer $NARWHAL_API_KEY"
```

小數以字串表示。 機率使用四位小數，例如 `"0.8250"`。 時間戳記使用 UTC，以 `Z` 結尾，精確到整秒。

沒有值的欄位會省略，但有四個例外：純量結果的邊界 `lower` 和 `upper` 在開放尾端使用 null；結果市場的 `value` 在交易場所未提供值時為 null；主題的 `ended` 在主題仍在進行時為 null；最後一頁的 `next_cursor` 為 null。清單欄位一律存在，為空時使用 `[]`。

## 主題與事件

先列出主題，再透過 `topic_id` 請求某個主題，讀取該主題及其事件。 主題 ID 包括 `usa-cpi-yoy`、`usa-fed` 和 `xau-monthly-extreme`。

| 參數 | 規則 |
| --- | --- |
| `group` | 主題清單中的可選值：`central_banks`、`us_prices`、`us_jobs`、`us_activity`、`global_activity`、`global_prices`、`metals`、`energy`、`rates` 或 `fx`。 |
| `include_ended` | 主題清單的選用參數：`true` 會同時列出已結束的主題。預設不列出。依 ID 請求已結束的主題仍會回傳。 |
| `topic`、 `release_id` | 事件清單的選用篩選條件。 |
| `status` | 事件清單的選用篩選條件：`upcoming`、`trading`、`closed`、`settled`或`void`。`open`不是有效值。 |
| `shape` | 事件清單的選用篩選條件：`scalar`、`extreme`、`timing`、`binary`、`categorical`或`set`。 |
| `from`、 `to` | 事件清單中針對`resolves_at`的選用UTC時間篩選條件。`from`必須早於`to`。 |
| `limit`、 `cursor` | 事件清單中的可選參數。`limit` 的取值範圍為1–100，預設值為50。 回應包含 `next_cursor`；將其作為 `cursor` 傳入以讀取下一頁。在最後一頁中它為 `null`。 |

### 主題欄位

主題包含 `topic_id`、`commodity_key`、`benchmark`、`group`、`title`、`shape`、`unit`、`unit_key`、`price_currency`、`venues`、`resolution_kind`、`calendar`、`ended` 和 `next_event_id`。`commodity_key`、`benchmark`、`unit`、`unit_key`、`price_currency`、`calendar` 和 `next_event_id` 僅在已設定時傳送。`ended` 一律傳送：主題結束的日期（`YYYY-MM-DD`），主題仍在進行時為 `null`。主題詳細資料不含 `next_event_id`。

`venues` 列出交易平台 ID，例如 `["kalshi","polymarket"]`。 `resolution_kind` 為 `release`、`price_fix`、`price_window` 或 `occurrence`。 `calendar` 僅在有值時傳回，包含 `country` 和 `family`。 `commodity_key` 指明價格主題所追蹤的大宗商品，例如 `gold`。只有主題指定了基準時才傳送 `benchmark`，例如原油的 `wti`。`price_currency` 是主題價格的幣別。

### 清單和主題列

事件清單列包含 `event_id`、`question`、`status`、`closes_at`、`resolves_at`、`topic_id` 和 `shape`；若主題追蹤某個大宗商品價格，還有 `commodity_key` 和 `benchmark`；已設定時還有 `release_id` 和精簡的 `result`。它們不含 `as_of`、`stale`、`unit` 或 `venues`。主題詳細資料中的 `events` 清單使用相同的列，但不含 `topic_id`、`shape`、`commodity_key` 和 `benchmark`：先是即將開始和交易中的事件，再是最近的另外 5 個事件。

### 事件欄位

所有事件類型都使用這些欄位。 各形態專屬欄位直接出現在事件中。事件頁面不含`shape`，形態由路徑識別。清單列包含`shape`。

| 欄位 | 內容 |
| --- | --- |
| `event_id`、 `topic_id`、 `question` | 事件 id、主題 id 和問題。 |
| `status` | `upcoming`、`trading`、`closed`、`settled` 或 `void`。 |
| `closes_at`、 `resolves_at`、 `as_of` | 交易關閉、結果確定和資料擷取時間。 |
| `release_id` | 公開行事曆發布紀錄的 id，沒有值時省略。 |
| `resolution`、 `resolves_with` | `resolution` 是文字說明。`resolves_with` 是獨立欄位，僅在有值時傳回。 |
| `unit`、 `venues` | 事件單位和下文所述的交易平台市場紀錄。 |
| `unit_key` | `unit_key` 以單一標準寫法表示單位，例如 troy_ounce、barrel 或 tonne；`unit` 保留來源的原始寫法。當價格以分報價時，`price_scale` 為 0.01：將價格乘以它，即可得到以 `currency` 計價的金額。 |
| `commodity_key`、 `benchmark`、 `price_currency` | 僅在已設定時傳送。`commodity_key` 和 `benchmark` 來自主題。`price_currency` 是事件價格的幣別，在 `unit` 指明幣別時傳送，例如 `usd_per_barrel`。 |
| `stale` | 在`upcoming`、`trading`和`closed`事件中傳送，在`settled`和`void`事件中省略。對於`upcoming`和`trading`事件，如果距離上次檢查交易場所已超過3分鐘，或儲存的快照已過期，則為true。對於這些事件，如果超過30分鐘未檢查交易場所、沒有檢查紀錄，或儲存的快照中沒有即時報價，則省略機率，所有`quotes`清單為空，所有交易場所均被排除。已關閉事件如果關閉時沒有即時報價，也不會傳送機率；僅當儲存的快照已過期時，才標記為過期。遇到任一過期狀態，都不要據此交易。 |
| `result` | 已結算及作廢事件中各交易場所的結果（見下方「結果」）。在事件狀態為 `settled` 或 `void` 之前，會省略此欄位。 |

## 依市場類型區分的機率

透過事件所屬形態的路徑請求。純量、極值、時間和二元請求可使用選填的 `at`，指定過去以 UTC 記錄的某一分鐘。

以下回應本文僅供示例，數值均為虛構。

### 純量

每個結果包含 `key`、`label`、`lower`、`upper`、`probability` 和 `quotes`。`median`、`p10` 和 `p90` 分別使用累積機率達到 50/10/90% 時所在列的上界。對於開放的上尾端，使用該列的下界，並在 `above` 中列出對應欄位名稱（例如 `["p90"]`）。`above` 一律存在，沒有欄位落在開放上尾端時為 `[]`。對於決策類事件或沒有機率時，省略 `median`、`p10` 和 `p90`。沒有價格的列省略 `probability`。

純量回應主體範例

```
{
  "outcomes": [
    {"key": "le_3.0", "label": "3.0% or lower", "lower": null, "upper": "3.0",
     "probability": "0.8250", "quotes": [
       {"venue": "kalshi", "probability": "0.8250",
        "market_ids": ["KXCPIYOY-26SEP-T3.0"]}
     ]},
    {"key": "gt_3.0_le_3.2", "label": "Above 3.0% to 3.2%", "lower": "3.0", "upper": "3.2",
     "probability": "0.1500", "quotes": [
       {"venue": "kalshi", "probability": "0.1500",
        "market_ids": ["KXCPIYOY-26SEP-T3.0", "KXCPIYOY-26SEP-T3.2"]}
     ]},
    {"key": "gt_3.2", "label": "Above 3.2%", "lower": "3.2", "upper": null,
     "probability": "0.0250", "quotes": [
       {"venue": "kalshi", "probability": "0.0250",
        "market_ids": ["KXCPIYOY-26SEP-T3.2"]}
     ]}
  ],
  "median": "3.0", "p10": "3.0", "p90": "3.2", "above": []
}
```

### 極值

`window`包含`start`和`end`。高點和低點機率顯示在`up`和`down`列中，每列含有`key`、`level`、`probability`和`quotes`。沒有交易場所參與合成的列會省略`probability`。`observation`為`any_trade`、`close`或`any_release`（視窗內發布的任何官方數值）。

極值回應主體範例

```
{
  "window": {"start": "2026-10-01T00:00:00Z", "end": "2026-11-01T00:00:00Z"},
  "observation": "any_trade",
  "up": [{"key": "up:4200", "level": "4200", "probability": "0.3060", "quotes": [
    {"venue": "polymarket", "probability": "0.3060", "market_ids": ["59472725739075996773"]}
  ]}],
  "down": [{"key": "down:3600", "level": "3600", "probability": "0.2000", "quotes": [
    {"venue": "polymarket", "probability": "0.2000", "market_ids": ["38105266318445209131"]}
  ]}]
}
```

### 時間

每個步驟表示截至`by`時某事已發生的機率。步驟包含`key`、`by`、`kind`（決策會議為`meeting`，當日結束為`date`）、`label`、`probability`和`quotes`；沒有交易場所參與合成的步驟會省略`probability`。事件也包含`not_within_window`。

時間類型回應主體範例

```
{
  "steps": [
    {"key": "2026-10-28", "by": "2026-10-28T18:00:00Z", "kind": "meeting", "label": "28 Oct 2026 meeting",
     "probability": "0.0035", "quotes": [
       {"venue": "polymarket", "probability": "0.0035", "market_ids": ["44988145651657165705"]}
     ]}
  ],
  "not_within_window": "0.9965"
}
```

### 二元

事件包含`quotes`，有交易場所參與合成時也包含`probability`。`labels`是含有`yes`和`no`標籤的物件，僅在標籤不同於Yes和No時傳送。

二元回應主體範例

```
{
  "probability": "0.0495",
  "quotes": [
    {"venue": "polymarket", "probability": "0.0495", "market_ids": ["63705498927604542864"]}
  ]
}
```

### 政策利率路徑

請求時將 `authority` 設為 `federal-reserve`、`european-central-bank`、`bank-of-england`、`bank-of-japan`、`bank-of-canada`、`reserve-bank-of-australia` 或 `bank-indonesia`。

回應包含`as_of`和`meetings`。政策路徑以基點回傳利率變動。目前利率可從核心資料API取得。預期變動根據機率加權的決策列計算，將降息50+按−50 bps、升息50+按+50 bps計算。累計變動為各次會議預期變動的總和。計算方法見OpenAPI說明和MCP工具文字。

政策利率路徑回應範例

```
{
  "as_of": "2026-10-08T12:00:00Z",
  "meetings": [
    {"event_id": "usa-fed-2026-10", "resolves_at": "2026-10-28T18:00:00Z",
     "p_cut": "0.6000", "p_hold": "0.4000", "p_hike": "0.0000",
     "expected_change_bps": "-15.0", "cumulative_change_bps": "-15.0"}
  ]
}
```

## 歷史

純量、極值、時間和二元類型的事件使用 `/v1/predictions/{shape}/{event_id}/history`。

| 參數 | 規則 |
| --- | --- |
| `interval` | `1m`、`5m`、`1h`（預設）或`1d`。`1m`和`5m`價格柱保留30天；更早的`start`回傳`400 invalid_query`，請改用`1h`或`1d`。 |
| `start`、 `end` | 必填。UTC時間；`end`必須晚於`start`。 時間視窗上限為：`1m` 最多 2 天，`5m` 最多 7 天，`1h` 最多 92 天，`1d` 最多 3,660 天。 |
| `cursor` | 選填字串，最多 200 個字元。將上一頁的 `next_cursor` 作為 `cursor` 傳入，並保持 `start`、`end` 和 `interval` 不變。 |

回應包含 `series` 和 `next_cursor`。 每個序列包含 `key`、`active_from` 和 `bars`。`active_to` 僅在序列結束後傳回。 每根柱包含 `timestamp` 和 `close`。 它們記錄每個時間間隔的收盤機率。 `timestamp` 標記柱的起點，該柱在一個 `interval` 後結束。包含 `open`、`high` 和 `low` 的柱是即時擷取的。僅含收盤值的柱是來自單一交易場所的回補資料，`backfill_venue` 有值時會標明該場所。 即使`next_cursor`不為 null，頁面也可能為空。

每頁約含 5,000 根柱，計為一次呼叫。回應包含 `next_cursor`（最後一頁為 `null`）；將其作為 `cursor` 傳入，並保持 `start`、`end` 和 `interval` 不變，以讀取下一頁。WTI、天然氣和 CPI 區間等滾動市場可能有很多頁。來自其他視窗的游標或格式錯誤的游標會傳回 `400` `invalid_query`；MCP 歷史工具接受相同的 `cursor`，並傳回相同的 `next_cursor`。

歷史回應範例，僅顯示一個序列

```
{
  "series": [
    {"key": "le_3.0", "active_from": "2026-10-01T00:00:00Z",
     "bars": [
       {"timestamp": "2026-10-08T11:00:00Z",
        "open": "0.8000", "high": "0.8400", "low": "0.7900", "close": "0.8250"}
     ]}
  ],
  "next_cursor": null
}
```

政策利率路徑歷史可透過 `/v1/predictions/policy-paths/{authority}/history` 取得。 `start`和`end`為必填項，視窗最長366天。沒有`interval`、`cursor`或`next_cursor`。 回應包含`meeting_dates`和`days`。`meeting_dates`為每次會議提供一次`event_id`和`resolves_at`。`days`中的每個項目包含`date`和`meetings`，其中每次會議都有`event_id`、`p_cut`、`p_hold`、`p_hike`、`expected_change_bps`和`cumulative_change_bps`。

## 交易平台與資料整合

Kalshi 和 Polymarket 的市場列在 `venues` 中，每個針對該問題找到的交易平台市場對應一筆紀錄。 具有`weight`的交易場所參與合成機率。具有`excluded_reason`的交易場所僅供參考，不參與合成。這兩個欄位有且僅有一個。

每筆 `quotes` 紀錄包含 `venue`、`probability` 和 `market_ids`。被排除的交易場所仍會出現在 `quotes` 中，可透過事件的 `venues` 識別。

| 交易平台欄位 | 內容 |
| --- | --- |
| `venue` | 交易場所 id。 |
| `url`、 `rules_url`、 `rules_text`、 `settlement_source` | 市場連結、規則連結和文字，以及結算來源。`rules_text`限2,000個字元。 |
| `weight`、 `volume_24h_usd`、 `open_interest_usd` | 交易場所的深度占比、24小時交易量及未平倉合約量。 |
| `match` | 僅在有差異時傳回，包含取自下方固定清單的 `differences` 和一句話的 `note`。 |
| `excluded_reason` | 對於目前分鐘：`stale`（3 分鐘內沒有報價）、`thin`（深度低於該主題的最低要求），或下列差異值之一。 |
| `settlement` | `"settled"` 或 `"void"`，在交易場所結算後傳回；待結算時省略。 平台的結果在 `result` 中，不在此處。 |

| 差異 | 處理方式 |
| --- | --- |
| `outcome_set` | 各列無法一一對應。 使用共有列進行整合；若剩餘不足 3 列，則排除。 |
| `timing` | 結果確定時間不同；予以排除。 |
| `source` | 依據不同來源結算；予以排除。 |
| `rules` | 使用不同條件；予以排除。 |

## 結果

已結算及作廢事件帶有 `result`，包含各交易場所的結果、數值及是否最終確定。在事件結算之前，會省略此欄位。所有帳戶在 Narwhal 取得結果後即可立即查看。

清單中的精簡格式為 `{final, settled_at}`，發生修訂時再加上 `amended_at`；只有所有交易場所都有結果列或被標記為 `unavailable` 後才傳回 `settled_at`，沒有結算時間時也會省略此欄位。

| 欄位 | 內容 |
| --- | --- |
| `final` | 僅當事件上每個平台的結果都已最終確認時才為 true。尚未最終確認的結果仍可能變動。 |
| `venues` | 每個交易場所一筆紀錄：`venue` 和 `markets`（僅事件詳細資料傳回；清單中省略）。交易場所層級的 `final`、`settled_at` 和 `amended_at` 僅出現在有兩個以上交易場所的事件中。只有一個交易場所時，這些值與事件層級的值相同。`unavailable` 僅在為 true 時傳回。 |
| `outcome`、 `value` | 依`markets`中的每個市場回傳，含有`market_id`（Kalshi代碼或Polymarket市場ID）。`outcome`在Kalshi中為`yes`、`no`、`void`或`scalar`，在Polymarket中為勝出標籤、`split`、`custom`或`unresolved`。`value`是十進位字串：Kalshi的YES結算價（所以`no`為`0`），或Polymarket的勝出價格（完全勝出為`1`）。交易場所未提供值時為null。 |
| `settled_at` | 平台完成結算的時間；在事件層級為各平台中最晚的時間。 |
| `amended_at` | 最終結果的判定或數值後來發生變更的時間（爭議或修訂）。從未變更時省略。 |
| `unavailable` | 平台已刪除該事件的市場且 Narwhal 沒有保存結果時為 true。這不會阻止 `final` 變為 true。 |

如果 Narwhal 無法讀取其儲存的結果，會傳回不含 `result` 的事件，並加上回應標頭 `X-Narwhal-Results: unavailable`。請稍後重試。MCP 工具結果也會提供相同提示。

串流與 Webhook 只傳遞狀態。請讀取事件以取得其結果。

## 資料時效

每 60 秒讀取一次各交易平台的資料。 REST 回傳最新一分鐘的資料，並附帶 `as_of`。 使用 `at` 讀取已擷取的任意一分鐘的資料。

機率對所有帳戶即時開放，包括僅使用免費額度的帳戶。

串流和預測 Webhook 對所有帳戶開放。每次連線和每次投遞都計為一次呼叫。 [預測 Webhook 請參閱 Webhook API 參考。](https://narwhalapi.com/zh-tw/docs/api/webhooks.md)

## 串流

將API金鑰放入`Authorization: Bearer`標頭，連線至`/v1/predictions/stream`，然後傳送訂閱。串流票證（`POST /v1/predictions/stream-ticket`）僅供Narwhal網站使用；伺服器和應用程式一律使用金鑰。

訂閱訊息

```
{"action":"subscribe","topics":["usa-fed"],"event_ids":[]}
```

| 訊息 | 內容或頻率 |
| --- | --- |
| `ready` | 連線開啟時傳送。隨後請訂閱。 |
| `subscribed` | 符合條件的事件 ID。 |
| `snapshot` | 完整事件，`shape` 與事件並列。 |
| `update` | 完整事件，但不含交易場所的靜態欄位：`url`、`rules_url`、`rules_text` 和 `settlement_source` 僅出現在 `snapshot` 中。有變更時傳送更新，每個事件每分鐘最多一次，`shape` 與事件並列。 |
| `status` | 事件的新狀態，格式為`{"type":"status","event_id":"...","status":"..."}`。 |
| `pong` | 對 `{"action":"ping"}` 的回覆。 |
| `error` | `{"type":"error","code":"..."}`。參見下方代碼。 |
| `rate_limited` | 連線嘗試超過短時間請求速率限制時傳送的錯誤碼。 |
| `heartbeat` | 每 30 s 傳送一次 `{"type":"heartbeat"}`，不含時間戳記或伺服器時間。 |

一個連線最多支援 200 個事件。 重新連線會提供最新快照，不進行重播。 每個訂閱最多接受40個`topics`和200個`event_ids`。每個連線最多接受30條命令。錯誤代碼：`invalid_command`、`subscribe_required`、`resubscribe_required`、`command_limit`、`slow_consumer`、`stream_limit`、`quota_unavailable`、`insufficient_credits`、`rate_limited`、`revoked`、`unauthorized`、`unavailable`、`shutdown`和`invalid_frame`。

## 錯誤

錯誤使用`NarwhalProblem`：`400 invalid_query`、`404 event_not_found`或`503 predictions_unavailable`。 [查看所有錯誤](https://narwhalapi.com/zh-tw/docs/errors.md)

使用錯誤的形態請求事件，或請求未知主題時，回傳`404 event_not_found`。 詳細資訊會提供正確路徑。

此頁面對你有幫助嗎?
