> ## Documentation Index
> Fetch the complete documentation index at: https://dexbuilder.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 发现市场

> 通过 Prediction API 查询公开 Event、Market 与 Tag，支持按 ID、slug、筛选条件和 cursor 分页。

本页介绍如何查找和筛选公开 Event 与 Market。市场发现和公开市场数据接口无需认证。

生产环境 API Base URL：

```text theme={null}
https://api.dexbuilder.com
```

除接口另有说明外，Event 和 Market 的时间字段使用 Unix 秒级时间戳。Event 的 `title`、`description` 和 Tag `label` 可返回多语言对象；Market 的 `question` 和 `outcomes[].outcome` 也使用多语言对象。Market 列表返回摘要，按 ID 或 slug 查询返回详情。

## Events

Event 用于将一个或多个相关 Market 组织在一起。

### 根据 ID 查询 Event

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/events/<event_id>"
```

### 根据 slug 查询 Event

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/events/slug/<event_slug>"
```

Event 详情常用字段：

| 字段 | 说明 |
| - | - |
| `event_id` | Event 唯一标识 |
| `slug` | URL 友好的 Event 标识 |
| `title` | 多语言 Event 标题对象 |
| `description` | 多语言 Event 描述对象 |
| `markets` | Event 下的 Market 摘要 |
| `markets_has_more` | 内嵌 Market 是否还有更多数据 |
| `active`, `closed` | Event 生命周期状态 |
| `start_date`, `start_time`, `end_date`, `closed_time` | Event 时间字段 |
| `volume` | Event 成交量，使用 decimal string |
| `tags` | Tag 摘要 |

```json Example theme={null}
{
  "event_id": "event-123",
  "slug": "example-event",
  "title": { "en": "Example event" },
  "active": true,
  "closed": false,
  "markets": [],
  "markets_has_more": false
}
```

### Event 列表

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/events?limit=20&active=true&closed=false&sort=start_date&ascending=true"
```

支持的主要 Query 参数：

| 参数 | 说明 |
| - | - |
| `limit` | 返回数量，范围 1–100 |
| `cursor` | 上一页返回的 `next_cursor` |
| `sort` | `start_date`、`start_time`、`end_date` 或 `closed_time` |
| `ascending` | 是否升序 |
| `event_id` | 按 Event ID 筛选 |
| `slug` | 按 Event slug 筛选 |
| `tag_slug` | 按 Tag slug 筛选 |
| `active`, `closed` | 按生命周期状态筛选 |
| `start_date_min`, `start_date_max` | 开始时间范围，Unix 毫秒 |
| `end_date_min`, `end_date_max` | 结束时间范围，Unix 毫秒 |

响应：

```json Example theme={null}
{
  "items": [
    {
      "event_id": "event-123",
      "slug": "example-event",
      "title": { "en": "Example event" },
      "active": true,
      "closed": false,
      "volume": "12500.50",
      "tags": [
        { "tag_id": "sports", "slug": "sports", "label": { "en": "Sports" } }
      ]
    }
  ],
  "next_cursor": "eyJvZmZzZXQiOjIwfQ"
}
```

当 `next_cursor` 非空时，将它原样作为下一次请求的 `cursor`：

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/events?limit=20&cursor=<next_cursor>"
```

## Markets

Market 是实际可交易的问题，每个 Market 包含一个或多个 Outcome Token。

### 根据 Market ID 查询

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/markets/<market_id>"
```

### 根据 slug 查询

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/markets/slug/<market_slug>"
```

市场列表返回 Market 摘要；按 ID 或 slug 查询返回 Market 详情。三者均使用多语言 `question`、多语言 `outcomes[].outcome` 和 Unix 秒级 `start_date`、`end_date`。从 `outcomes[].token_id` 获取 Token ID 后，可继续查询价格和订单簿。

| 字段 | 说明 |
| - | - |
| `market_id` | Market 唯一标识；后续请求应原样使用返回值 |
| `event_id` | 所属 Event ID |
| `slug` | Market slug |
| `question` | 多语言市场问题对象 |
| `condition_id` | Condition ID |
| `outcomes` | Outcome 列表；每项包含多语言 `outcome` 和 `token_id` |
| `status`、`closed` | Market 状态 |
| `best_bid`、`best_ask`、`last_trade_price` | 盘口和最近成交摘要 |
| `start_date`、`end_date` | Market 时间，Unix 秒；无值时为 `null` |

以下为 Market 摘要示例；详情还可返回交易限制和结算字段：

```json Example theme={null}
{
  "market_id": "ge_42_7",
  "event_id": "ge_42",
  "slug": "example-market",
  "question": { "en": "Will the outcome occur?" },
  "condition_id": "ge_condition",
  "status": "active",
  "closed": false,
  "start_date": 1782666000,
  "end_date": 1782752400,
  "outcomes": [
    { "outcome": { "en": "Yes" }, "token_id": "ge_yes" },
    { "outcome": { "en": "No" }, "token_id": "ge_no" }
  ]
}
```

### Market 列表

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/markets?limit=20&active=true&closed=false&tag_slug=sports"
```

主要参数：

| 参数 | 说明 |
| - | - |
| `limit` | 返回数量，范围 1–100 |
| `cursor` | 上一页返回的 `next_cursor` |
| `market_id` | Market ID |
| `event_id` | 所属 Event ID |
| `slug` | Market slug |
| `condition_id` | Condition ID |
| `tag_slug` | 所属 Event 的 Tag slug |
| `active`, `closed` | Market 生命周期状态 |

## Tags

Tag 可用于构建分类筛选：

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/prediction/tags?limit=20&cursor=<cursor>"
```

```json theme={null}
{
  "items": [
    { "tag_id": "sports", "slug": "sports", "label": { "en": "Sports" } }
  ],
  "next_cursor": "eyJvZmZzZXQiOjIwfQ"
}
```

## 当前 API 范围

当前 Prediction API 提供 Event、Market、Tag、公开市场成交和 Token 市场数据等能力。未在 DexBuilder API 合同中定义的第三方专用接口不应作为正式集成依赖。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.