---
title: "Kalshi Polymarket 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/docs/api/predictions"
---

# 预测市场 API 参考：Kalshi 与 Polymarket

按主题和事件读取预测概率，包含历史数据、交易平台详情和流式更新。

Narwhal 仅返回概率，不提供官方数据或自有价格。 [概览请参阅预测产品页面。](https://narwhalapi.com/zh/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/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/docs/errors.md)

使用错误的形态请求事件，或请求未知主题时，返回`404 event_not_found`。 详细信息会给出正确路径。

此页面对你有帮助吗?
