> For the complete documentation index, see [llms.txt](https://docs.infoway.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.infoway.io/rest-api/http-endpoints/get-trade.md).

# GET获取产品的实时成交明细(Trade)

获取股票、加密货币、外汇、能源、商品等所有产品的实时成交明细

### 接口说明

该接口获取各市场最新成交明细。标的写法见 标的代码约定。

### 请求频率

与其他 HTTP 接口共用[频率限制](/getting-started/api-limitation/http.md)，具体每秒次数由套餐决定。

### 错误码说明

见 [HTTP错误码](/getting-started/error-codes/http.md)。地址总览见 [行情地址说明](/getting-started/api-endpoints.md)。

### 接口地址

| 市场              | 完整路径                                                 |
| --------------- | ---------------------------------------------------- |
| 股票（美股、港股、A 股）   | `https://data.infoway.io/stock/batch_trade/{codes}`  |
| 日本              | `https://data.infoway.io/japan/batch_trade/{codes}`  |
| 印度              | `https://data.infoway.io/india/batch_trade/{codes}`  |
| 韩国              | `https://data.infoway.io/korea/batch_trade/{codes}`  |
| 台湾              | `https://data.infoway.io/taiwan/batch_trade/{codes}` |
| 加密货币            | `https://data.infoway.io/crypto/batch_trade/{codes}` |
| 外汇、能源、商品、贵金属、期货 | `https://data.infoway.io/common/batch_trade/{codes}` |

### 请求头

| 参数       | 类型     | 必填 | 描述         |
| -------- | ------ | -- | ---------- |
| `apiKey` | String | 是  | 套餐 API Key |

### 入参说明

| 参数名             | 类型      | 必填 | 描述                                                                  | 示例值               |
| --------------- | ------- | -- | ------------------------------------------------------------------- | ----------------- |
| `codes`         | String  | 是  | 路径参数。产品代码，逗号分隔，最多 100 个                                             | `TSLA.US,AAPL.US` |
| `withMarkPrice` | Boolean | 否  | 仅加密货币接口支持的 Query 参数，默认 `false`。设为 `true` 时，`.P` 合约可追加指数价、标记价和资金费率字段 | `true`            |

```http
GET https://data.infoway.io/stock/batch_trade/TSLA.US,AAPL.US
```

### 返回示例

以下数值仅用于展示字段格式。

```json
{
  "ret": 200,
  "msg": "success",
  "traceId": "27bdafb1-c735-4499-aad1-553820284895",
  "data": [
    {
      "s": "TSLA.US",
      "t": 1750177346523,
      "p": "298.310",
      "v": "100",
      "vw": "29831.000",
      "td": 0
    }
  ]
}
```

| 字段名  | 类型     | 描述                           | 示例值             |
| ---- | ------ | ---------------------------- | --------------- |
| `s`  | String | 标的代码                         | `USDCNY`        |
| `t`  | Long   | 成交时间（毫秒时间戳）                  | `1747382898892` |
| `p`  | String | 价格                           | `34.650`        |
| `v`  | String | 成交量                          | `439000`        |
| `vw` | String | **成交额**（不是均价 / VWAP）         | `15211350.000`  |
| `td` | Int    | 交易方向：`0` 默认，`1` Buy，`2` Sell | `0`             |

### 加密货币合约的标记价格

在 `/crypto/batch_trade/{codes}` 的 URL 后添加 `?withMarkPrice=true`，可为以 `.P` 结尾的合约请求以下附加字段。该参数默认关闭，不改变 `p` 的成交价格含义，也不适用于其他市场的成交接口。

```http
GET https://data.infoway.io/crypto/batch_trade/BTCUSDT.P?withMarkPrice=true
apiKey: YOUR_API_KEY
```

| 字段名               | 类型     | 描述                                        | 示例值             |
| ----------------- | ------ | ----------------------------------------- | --------------- |
| `indexPrice`      | String | 指数价格；可选                                   | `"83499.49"`    |
| `markPrice`       | String | 标记价格；可选                                   | `"83457.46"`    |
| `lastFundingRate` | String | 最新资金费率的小数值；例如 `0.00004277` 对应 `0.004277%` | `"0.00004277"`  |
| `nextFundingTime` | Long   | 下次资金费用结算时间，Unix 毫秒时间戳；可选                  | `1791820800000` |

附加字段仅在开启参数、代码以 `.P` 结尾且对应数据可用时返回。现货、未开启参数或缺少相应数据时，字段会省略；`nextFundingTime` 没有有效正值时也会省略。以上数值为格式示例。
