> ## 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 查詢和取消事件市場私有訂單。

訂單查詢與撤單都屬於私有操作，需要認證。生產環境 Base URL：

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

## 查詢訂單清單

```bash cURL theme={null}
curl -G "https://api.dexbuilder.com/api/v4/broker/prediction/orders" \
  -H "KEY: ${BROKER_API_KEY}" \
  -H "SIGN: ${SIGN}" \
  -H "Timestamp: ${TIMESTAMP}" \
  -H "X-User-Wallet-Address: ${USER_WALLET}" \
  --data-urlencode "status=open" \
  --data-urlencode "condition_id=<condition_id>" \
  --data-urlencode "limit=20"
```

常用篩選參數包括：`status`、`condition_id`、`event_id`、`order_id`、`client_order_id`、`from`、`to`、`sort_type`、`limit` 與 `cursor`。

`from`、`to` 使用 Unix 毫秒；`sort_type` 可按 `created_at` 或 `updated_at` 排序。

響應：

```json theme={null}
{
  "items": [
    {
      "order_id": "order-123",
      "client_order_id": "client-order-001",
      "event_id": "event-123",
      "condition_id": "0xabc...",
      "token_id": "token-yes",
      "outcome": "Yes",
      "side": "BUY",
      "price": "0.52",
      "size": "10",
      "size_matched": "4",
      "size_left": "6",
      "order_type": "GTC",
      "order_mode": "LIMIT",
      "status": "open",
      "created_at": 1782753357,
      "updated_at": 1782753357
    }
  ],
  "next_cursor": "eyJvZmZzZXQiOjIwfQ"
}
```

將 `next_cursor` 原樣作為下一頁請求的 `cursor`。

## 查詢單個訂單

```bash cURL theme={null}
curl "https://api.dexbuilder.com/api/v4/broker/prediction/orders/<order_id>" \
  -H "KEY: ${BROKER_API_KEY}" \
  -H "SIGN: ${SIGN}" \
  -H "Timestamp: ${TIMESTAMP}" \
  -H "X-User-Wallet-Address: ${USER_WALLET}"
```

詳情響應包含清單中的訂單標識、價格、數量、成交進度與狀態等欄位，並可能包含訂單服務回傳的 `error_code`。

## 取消單個訂單

```bash cURL theme={null}
curl -X DELETE "https://api.dexbuilder.com/api/v4/broker/prediction/orders/<order_id>" \
  -H "KEY: ${BROKER_API_KEY}" \
  -H "SIGN: ${SIGN}" \
  -H "Timestamp: ${TIMESTAMP}" \
  -H "X-User-Wallet-Address: ${USER_WALLET}"
```

```json theme={null}
{
  "order_id": "order-123",
  "status": "processing",
  "cancel_status": "accepted"
}
```

## 按 Condition 取消訂單

```bash cURL theme={null}
curl -X DELETE "https://api.dexbuilder.com/api/v4/broker/prediction/orders?condition_id=<condition_id>" \
  -H "KEY: ${BROKER_API_KEY}" \
  -H "SIGN: ${SIGN}" \
  -H "Timestamp: ${TIMESTAMP}" \
  -H "X-User-Wallet-Address: ${USER_WALLET}"
```

```json theme={null}
{
  "batch_id": "batch-123",
  "status": "accepted",
  "total_orders": 3
}
```

> [!NOTE]
>
> 請使用 Broker API Key，並在 `X-User-Wallet-Address` 中指定屬於當前 Broker 的使用者錢包地址。`SIGN` 須依實際請求方法、路徑、查詢參數和請求主體計算。詳見 [Broker API Key 與簽名](https://dexbuilder.mintlify.site/zh-TW/api-reference/common/broker-authentication.md) 及 [代表使用者存取](https://dexbuilder.mintlify.site/zh-TW/api-reference/common/sub-user-wallet.md)。


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