> For the complete documentation index, see [llms.txt](https://earnbit.gitbook.io/earnbit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://earnbit.gitbook.io/earnbit/developers/exchange-api-documentation/public-methods-or-websoket/kline-methods.md).

# KLine methods

### List of KLine methods:

* [KLine Query](#kline-query-method)- used for one-time data get requests.
* [KLine Subscribe](#kline-subscribe-method) - used to subscribe to receive real-time updates.
* [KLine Unsubscribe ](#kline-unsubscribe-method)- used to unsubscribe from the [KLine Subscribe ](#kline-subscribe-method)method.

### KLine Query method

Used for one-time data get requests.

#### Method

```javascript
kline.query
```

#### Request "params" parameters

|                    Name                    |   Type  | Description                                                                                        | Example    |
| :----------------------------------------: | :-----: | -------------------------------------------------------------------------------------------------- | ---------- |
|   pair<mark style="color:red;">\*</mark>   |  STRING | Any public pair                                                                                    | BTC\_USDT  |
|   start<mark style="color:red;">\*</mark>  | NUMERIC | Start time in TimeStamp format                                                                     | 1727272000 |
|    end<mark style="color:red;">\*</mark>   | NUMERIC | Start time in TimeStamp format                                                                     | 1727276700 |
| interval<mark style="color:red;">\*</mark> | NUMERIC | Time interval (60 = 1 min, 900 = 15 min, 1800 = 30 min, 3600 = 1 h, 14400 = 4 h, 86400 = 1 d, etc) | 3600       |

#### Request example

```javascript
{
  "method":"kline.query",
  "params":
    [
      "BTC_USDT",
      1727272000,
      1727276700,
      3600
    ],
  "id":10
}
```

#### Response "result" parameters

|   Name  |   Type  |
| :-----: | :-----: |
|   time  | NUMERIC |
|   open  |  STRING |
|  close  |  STRING |
| highest |  STRING |
|  lowest |  STRING |
|  volume |  STRING |
|  amount |  STRING |
|  market |  STRING |

#### Response example

```javascript
{
    "id": 10,
    "params": [
        "BTC_USDT",
        1727272000,
        1727276700,
        3600
    ],
    "result": [
        [
            1727276400,                   // time
            "63936.5",                    // open (price)
            "63876.99",                   // close (price)
            "63999",                      // highest (price)
            "63866.57",                   // lowest (price)
            "4.19554334",                 // volume 
            "268265.681968204036662"      // amount
            "BTC_USDT"                    // market
        ]
    ],
    "error": null
}
```

### KLine Subscribe method

Used to subscribe to receive real-time updates.

#### Method

```javascript
kline.subscribe
```

#### **Request "params"** parameters

|                    Name                    |   Type  | Description                                                                                        | Example   |
| :----------------------------------------: | :-----: | -------------------------------------------------------------------------------------------------- | --------- |
|   pair<mark style="color:red;">\*</mark>   |  STRING | Any public pair                                                                                    | BTC\_USDT |
| interval<mark style="color:red;">\*</mark> | NUMERIC | Time interval (60 = 1 min, 900 = 15 min, 1800 = 30 min, 3600 = 1 h, 14400 = 4 h, 86400 = 1 d, etc) | 3600      |

#### Request example

```javascript
{
  "method":"kline.subscribe",
  "params":
    [
      "BTC_USDT",
      3600
    ],
  "id":1
}
```

#### Response example (successfully subscribed)

```javascript
{
    "id": 1,
    "params": [],
    "result": {
        "status": "success"
    },
    "error": null
}
```

#### Response "params" parameters ("kline.update")

|   Name  |   Type  |
| :-----: | :-----: |
|   time  | NUMERIC |
|   open  |  STRING |
|  close  |  STRING |
| highest |  STRING |
|  lowest |  STRING |
|  volume |  STRING |
|  amount |  STRING |
|  market |  STRING |

#### Response example **("**&#x6B;line.updat&#x65;**")**

```javascript
{
    "id": null,
    "method": "kline.update",
    "params": [
        [
            1727262000,                      // time
            "63630.45000000",                // open (price)
            "63574.00000000",                // close (price)
            "63647.95000000",                // highest (price)
            "63572.00000000",                // lowest (price)
            "0.42535636",                    // volume
            "27060.5947980969293460",        // amount
            "BTC_USDT"                       // pair (name)
        ]
    ]
}
```

### KLine unsubscribe method

Used to unsubscribe from the [KLine Subscribe ](#kline-subscribe-method)method.

#### Method

```javascript
kline.unsubscribe
```

#### Request example&#x20;

```javascript
{
  "method":"kline.unsubscribe",
  "params":[],
  "id":10
}
```

#### Response example (successfully unsubscribed)

```javascript
{
    "id": 10,
    "params": [],
    "result": {
        "status": "success"
    },
    "error": null
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://earnbit.gitbook.io/earnbit/developers/exchange-api-documentation/public-methods-or-websoket/kline-methods.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
