> 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/depth-methods.md).

# Depth methods

### List of Depth methods:

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

### Depth Query method

Used for one-time data get requests.

#### **Method**

```javascript
depth.query
```

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

| Name                                       |   Type  | Description                                      |  Example  |
| ------------------------------------------ | :-----: | ------------------------------------------------ | :-------: |
| market<mark style="color:red;">\*</mark>   |  STRING | Any public pair                                  | BTC\_USDT |
| limit<mark style="color:red;">\*</mark>    | NUMERIC | Limit of order quantity                          |     1     |
| interval<mark style="color:red;">\*</mark> |  STRING | Interval (defoult = 1, no interval: 0, step = 1) |     0     |

#### Request example

```javascript
{
  "method":"depth.query",
  "params":
    [
      "BTC_USDT",  // market
      1,          // limit
      "0"         // interval
    ],
  "id":1
}
```

#### Response "result" parameters

|  Name  |  Type  | Description                              |
| :----: | :----: | ---------------------------------------- |
|  type  | STRING | Order type (ask = sell, bid = buy)       |
|  price | STRING | Order price (in 1st ticker of the pair)  |
| amount | STRING | Order amount (in 1st ticker of the pair) |

#### Response example

```javascript
{
    "id": 1,
    "params": [
        "BTC_USDT",
        1,
        "0"
    ],
    "result": {
        "asks": [                   // type
            [
                "63552.1228986",   // price
                "0.328856"         // amount
            ]
        ],
        "bids": [                  // type
            [
                "63544.4971014",   // price
                "0.313271"         // amount
            ]
        ]
    },
    "error": null
}
```

### Depth Subscribe method

Used to subscribe to receive real-time updates.

#### Method

```javascript
depth.subscribe
```

#### Request "params" parameters

|                    Name                    | Type    |                       Type                       | Example   |
| :----------------------------------------: | ------- | :----------------------------------------------: | --------- |
|  market<mark style="color:red;">\*</mark>  | STRING  |                  Any public pair                 | BTC\_USDT |
|   limit<mark style="color:red;">\*</mark>  | NUMERIC |                 Number of orders                 | 1         |
| interval<mark style="color:red;">\*</mark> | STRING  | Interval (defoult = 1, no interval: 0, step = 1) | 0         |

#### Request example

```javascript
{
  "method":"depth.subscribe",
  "params":
    [
      "BTC_USDT",    // market
      1,            // limit
      "0"           // interval
    ],
  "id":1
}
```

#### Response example (successfully subscribed)

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

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

|  Name  | Type    |                    Description                    |
| :----: | ------- | :-----------------------------------------------: |
| status | BOOLEAN | FALSE = returned latest result, TRUE = no updates |
|  type  | STRING  |         Order type (ask = sell, bid = buy)        |
|  price | STRING  |      Order price (in 1st ticker of the pair)      |
| amount | STRING  |      Order amount (in 1st ticker of the pair)     |
| market | STRING  |                     Pair name                     |

#### Response example **("**&#x64;ept&#x68;**.update")**

```javascript
{
  "method": "depth.update",
  "params":
    [
      true,                  // status
        {
          "asks":            // type
            [
              [
                "0.018519", // price
                "120.6"     // amount
              ]
            ],
          "bids":
            [
              [
                "0.01806",    // price
                "90.31637262" // amount
              ]
            ]
        },
      "BTC_USDT"             // market
    ],
  "id": null
}
```

### Depth Unsubscribe method

Used to unsubscribe from the [Depth Subscribe](#depth-subscribe-method) method.

#### Method

```javascript
depth.unsubscribe
```

#### Request example

```javascript

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

#### Response example (successfully unsubscribed)

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