# Market Status methods

### List of Market Status methods:

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

### Market Status Query method

Used for one-time data get requests.

#### Method

```javascript
state.query
```

#### Request "params" parameters

|                   Name                   | Type    |                                             Description                                            | Example   |
| :--------------------------------------: | ------- | :------------------------------------------------------------------------------------------------: | --------- |
| market<mark style="color:red;">\*</mark> | STRING  |                                           Any public pair                                          | BTC\_USDT |
| period<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) | 86400     |

#### Request example

```javascript
{
  "method":"state.query",
  "params":
    [
      "BTC_USDT",
      86400
    ],
  "id":1
}
```

#### Response "result" parameters

|  Name  |   Type  |
| :----: | :-----: |
| period | NUMERIC |
|  last  |  STRING |
|  open  |  STRING |
|  close |  STRING |
|  high  |  STRING |
|   low  |  STRING |
|  deal  |  STRING |
| volume |  STRING |
| change |  STRING |

#### Response example

```javascript
{
    "id": 1,
    "params": [
        "BTC_USDT",
        86400
    ],
    "result": {
        "period": 86400,                       // period
        "last": "63740.5",                     // last price 24h
        "open": "64262.69",                    // open price 24h
        "close": "63746.175",                  // close price 24h
        "high": "64814.0909212",               // highest price 24h
        "low": "63409.39",                     // lowest price 24h
        "deal": "9728980.6793573261265715",    // deal
        "volume": "151.92971388",              // volume
        "change": "-0.81"                      // % change
    },
    "error": null
}
```

### Market Status Subscribe method

Used to subscribe to receive real-time updates.

#### Method

```javascript
state.subscribe
```

#### Request "prarams" paramaeters

| Name                                     |   Type  | Desciption                                                                                         |  Example |
| ---------------------------------------- | :-----: | -------------------------------------------------------------------------------------------------- | :------: |
| market<mark style="color:red;">\*</mark> |  STRING | Any public pair                                                                                    | ETH\_BTC |
| period<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) |   86400  |

#### Request example

```javascript
{
  "method":"state.subscribe",
  "params":
    [
      "ETH_BTC",
      86400
    ],
  "id":1
}
```

#### Response example (successfully subscribed)

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

#### Response "result" parameters ("state.update")

|  Name  |   Type  |
| :----: | :-----: |
| period | NUMERIC |
| volume |  STRING |
|  last  |  STRING |
|  open  |  STRING |
|   low  |  STRING |
|  close |  STRING |
|  high  |  STRING |
|  deal  |  STRING |

#### Response example ("state.update")

```javascript
{
  "result":
    {
      "period": 86400,                    // period
      "volume": "192238.62392908",        // volume 
      "last": "0.018295",                 // last price 24h
      "open": "0.017526",                 // open price 24h
      "low": "0.0174",                    // lowest price 24h
      "close": "0.018295",                // close price 24h
      "high": "0.02",                     // highest price 24h
      "deal": "3479.25570915213257"       // deal
    },
  "error": null,
  "id": null
}
```

### Market Status Unsubscribe method

Used to unsubscribe from the [Market Status Subscribe](#market-status-subscribe-method) method.

#### Method

```javascript
state.unsubscribe
```

#### Request example

```javascript
{
  "method":"state.unsubscribe",
  "params":[],
  "id":2
}
```

#### Response example (successfully unsubscribed)

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


---

# 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://earnbit.gitbook.io/earnbit/developers/exchange-api-documentation/public-methods-or-websoket/market-status-methods.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.
