# Unsubscribe from Real-Time Candlestick (K-Line) Data

### API Description

This document describes how to **fully cancel** or **partially cancel** product subscriptions without disconnecting the WebSocket connection.

### Request Frequency

For the same WebSocket connection, all requests (subscription, unsubscription, heartbeat) are limited to **60 times per minute**. If the request frequency limit is exceeded, the connection will be automatically disconnected. If there are too many disconnections and the system determines it as a malicious request, the API key will be blocked. Please pay attention to the calling logic during use.

### Error Code Description

Refer to [WebSocket Error Code Description](/en-docs/getting-started/error-codes/websocket-error-codes.md)

### Endpoint

Please refer to [WebSocket Subscription Endpoints](/en-docs/websocket/subscription-address.md)

### Request (Protocol Code: 11002)

```json
{
    "code": 11002,
    "trace": "423afec425004bd8a5e02e1ba5f9b2b0",
    "data": {
        "codes": "BTCUSDT",
        "klineTypes": "1,2,4"
    }
}
```

> **Note**: The `data`, `codes`, or `klineTypes` parameter can be null or empty.
>
> * If the `codes` value cannot be obtained, a full cancellation will be performed. That is, if you have subscribed to candlestick data of 100 product pairs, all subscription data will be cleared and no further pushes will be made. If the `codes` value is provided, only the subscription data of the specified products will be cleared, and the data push of other products will not be affected.
> * If the `klineTypes` value cannot be obtained, all candlestick types (1-minute to 1-year) of the target products will be canceled. If the `klineTypes` value is provided, only the data push of the specified candlestick types will be cleared.
> * Example: Suppose you have subscribed to 1-minute and 5-minute candlesticks for products A and B. If the request parameters are `codes="A"` and `klineTypes="1"`, only the 1-minute candlestick push for product A will be canceled. This will not affect the 5-minute candlestick push for product A, nor the 1-minute and 5-minute candlestick pushes for product B.

| Parameter Name | Type    | Required | Description                                                                    | Example Value                                                            |
| -------------- | ------- | -------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------ |
| `code`         | Integer | Yes      | Request protocol code                                                          | Protocol code for unsubscribing from real-time candlestick data: `11002` |
| `trace`        | String  | Yes      | Traceable ID (random string)                                                   | `423afec425004bd8a5e02e1ba5f9b2b0`                                       |
| `data`         | JSON    | No       | Unsubscription data                                                            |                                                                          |
| `codes`        | String  | No       | Products to unsubscribe from (separated by commas for multiple products)       | `BTCUSDT`                                                                |
| `klineTypes`   | String  | No       | Candlestick types to unsubscribe from (separated by commas for multiple types) | `1,2`                                                                    |

### Response (Protocol Code: 11010)

```json
{
    "code": 11010,
    "trace": "423afec425004bd8a5e02e1ba5f9b2b0",
    "msg": "ok"
}
```

| Field Name | Type    | Required | Description                                     | Example Value                                                                     |
| ---------- | ------- | -------- | ----------------------------------------------- | --------------------------------------------------------------------------------- |
| `code`     | Integer | Yes      | Response protocol code                          | Response protocol code for unsubscribing from real-time candlestick data: `11010` |
| `trace`    | String  | Yes      | Traceable ID passed in the subscription request | `423afec425004bd8a5e02e1ba5f9b2b0`                                                |
| `msg`      | String  | Yes      | Response message                                | `ok`                                                                              |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.infoway.io/en-docs/websocket/websocket-unsubscribe-method/unsubscribe-from-real-time-candlestick-k-line-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
