> 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/getting-started/http-protocols.md).

# HTTP Protocols

Request and response conventions for HTTP and WebSocket.

### 1. HTTP

#### 1.1 Method

**Not** every HTTP endpoint is GET.

| Kind                                             | Method | Notes                                      |
| ------------------------------------------------ | ------ | ------------------------------------------ |
| Trades, depth, basic info, package, fundamentals | `GET`  | Path / query parameters                    |
| Historical / realtime kline v2                   | `POST` | Path `/{market}/v2/batch_kline`, JSON body |

Monthly archive downloads also use `POST` with a JSON body at `/kline/archive/download`; see [Monthly Candlestick Archive Download](https://docs.infoway.io/en-docs/rest-api/market-data/post-kline-archive-download.md).

Always send the API key:

| Header   | Required | Description                             |
| -------- | -------- | --------------------------------------- |
| `apiKey` | Yes      | Plan API key. `apikey` is also accepted |

#### 1.2 Response format

```json
{
    "ret": 200,
    "msg": "success",
    "traceId": "698f920a-c53b-401c-bfac-4ea46b9b8f12",
    "data": []
}
```

| Field     | Description                                                                                                                                      |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ret`     | Business code. `200` is success; see [REST API Error Codes](https://docs.infoway.io/en-docs/getting-started/error-codes/rest-api-error-codes.md) |
| `msg`     | Short status, e.g. `success`                                                                                                                     |
| `traceId` | Server-generated trace id (not `tradeId`)                                                                                                        |
| `data`    | Payload; shape depends on the endpoint                                                                                                           |

Quote failures are often **HTTP 200 + `ret=5xx`**. Read `ret` / `msg` first.

### 2. WebSocket

Quote URL:

```
wss://data.infoway.io/ws?business={stock|crypto|common|japan|india|korea|taiwan}&apikey=<key>
```

Markets share one host; `business` selects the channel.

News is a different path and has no `business`:

```
wss://data.infoway.io/news?apikey=<key>
```

After connect, `business=stock` may send a plaintext greeting, then `{"code":200,"msg":"ws connect success"}`. `200` means the socket is up.

Subscription failures on `crypto` and `common` can be sent as `Subscribe fail:` followed by JSON. Handle text types/prefixes before parsing JSON; a successful connection does not imply a successful subscription.

See [WebSocket Limitation](https://docs.infoway.io/en-docs/getting-started/api-limitation/websocket-limitation.md) and [Heartbeat](https://docs.infoway.io/en-docs/websocket/heartbeat.md). Addresses: [Endpoints](https://docs.infoway.io/en-docs/getting-started/endpoints.md). HTTP rate limits: [REST API Limitation](https://docs.infoway.io/en-docs/getting-started/api-limitation/rest-api-limitation.md).
