> 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/en-docs/rest-api/market-data/get-latest-trade.md).

# GET Latest Trade

Retrieve the latest trade for stocks, cryptocurrencies, forex, energy, commodities, and more.

### Overview

Returns the most recent trade tick per symbol. See Symbol convention for suffixes.

### Request frequency

Shares the same HTTP [rate limits](https://docs.infoway.io/en-docs/getting-started/api-limitation/rest-api-limitation) as other REST endpoints.

### Error codes

See [REST API Error Codes](https://docs.infoway.io/en-docs/getting-started/error-codes/rest-api-error-codes). Address list: [Endpoints](https://docs.infoway.io/en-docs/getting-started/endpoints).

### Endpoint

| Market                                      | Full URL                                             |
| ------------------------------------------- | ---------------------------------------------------- |
| Equities (US, HK, CN A-shares)              | `https://data.infoway.io/stock/batch_trade/{codes}`  |
| Japan                                       | `https://data.infoway.io/japan/batch_trade/{codes}`  |
| India                                       | `https://data.infoway.io/india/batch_trade/{codes}`  |
| Korea                                       | `https://data.infoway.io/korea/batch_trade/{codes}`  |
| Taiwan                                      | `https://data.infoway.io/taiwan/batch_trade/{codes}` |
| Crypto                                      | `https://data.infoway.io/crypto/batch_trade/{codes}` |
| Forex, energy, commodities, metals, futures | `https://data.infoway.io/common/batch_trade/{codes}` |

### Authentication

| Header   | Type   | Required | Description  |
| -------- | ------ | -------- | ------------ |
| `apiKey` | String | Yes      | Plan API key |

### Parameters

| Parameter       | Type    | Required | Description                                                                                                                                                           | Example           |
| --------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| `codes`         | String  | Yes      | Path parameter. Comma-separated symbols, up to 100                                                                                                                    | `TSLA.US,AAPL.US` |
| `withMarkPrice` | Boolean | No       | Query parameter for the crypto endpoint only. Defaults to `false`. When `true`, `.P` contracts may include index price, mark price, funding fields, and open interest | `true`            |

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

### Example response

The following values illustrate the response format.

```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
    }
  ]
}
```

| Field | Type   | Description                               | Example         |
| ----- | ------ | ----------------------------------------- | --------------- |
| `s`   | String | Symbol                                    | `USDCNY`        |
| `t`   | Long   | Trade time (Unix milliseconds)            | `1747382898892` |
| `p`   | String | Price                                     | `34.650`        |
| `v`   | String | Volume                                    | `439000`        |
| `vw`  | String | **Turnover / trade value** (not VWAP)     | `15211350.000`  |
| `td`  | int    | Direction: `0` default, `1` buy, `2` sell | `0`             |

### Mark prices and open interest for crypto contracts

Append `?withMarkPrice=true` to `/crypto/batch_trade/{codes}` to request the following additional fields for contracts ending in `.P`. The parameter defaults to false, leaves `p` as the trade price, and does not apply to trade endpoints for other markets.

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

```json
{
  "ret": 200,
  "msg": "success",
  "traceId": "27bdafb1-c735-4499-aad1-553820284895",
  "data": [
    {
      "s": "BTCUSDT.P",
      "t": 1791817200000,
      "p": "83460.10",
      "v": "0.001",
      "vw": "83.46010",
      "td": 1,
      "indexPx": "83499.49",
      "markPx": "83457.46",
      "fundRate": "0.00004277",
      "fundTime": 1791820800000,
      "openInt": "12345.678",
      "openIntTime": 1791817200000
    }
  ]
}
```

| Field         | Type   | Description                                                                | Example         |
| ------------- | ------ | -------------------------------------------------------------------------- | --------------- |
| `indexPx`     | String | Index price; optional                                                      | `"83499.49"`    |
| `markPx`      | String | Mark price; optional                                                       | `"83457.46"`    |
| `fundRate`    | String | Latest funding rate as a decimal; `0.00004277` means `0.004277%`; optional | `"0.00004277"`  |
| `fundTime`    | Long   | Next funding settlement time, in Unix milliseconds; optional               | `1791820800000` |
| `openInt`     | String | Open interest; optional                                                    | `"12345.678"`   |
| `openIntTime` | Long   | Open interest time, in Unix milliseconds; optional                         | `1791817200000` |

Each additional field is returned only when the parameter is enabled, the symbol ends in `.P`, and that value is available. These fields are omitted for spot symbols or when the parameter is disabled. The four string fields are omitted when their values are `null`, and numeric values retain their string format. `fundTime` and `openIntTime` are returned only when positive. These values illustrate the format.
