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