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

# Deals methods

### List of Deals methods:

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

### Deals Query method

Used for one-time data get requests.

#### Method

```javascript
deals.query
```

#### Request "params" parameters

|                   Name                   |   Type  |       Description       | Example  |
| :--------------------------------------: | :-----: | :---------------------: | -------- |
| market<mark style="color:red;">\*</mark> |  STRING |     Any public pair     | ETH\_BTC |
|  limit<mark style="color:red;">\*</mark> | NUMERIC | How many trades to show | 2        |
| lastId<mark style="color:red;">\*</mark> | NUMERIC | How many trades to skip | 0        |

#### Request example

```javascript
{
  "method":"deals.query",
  "params":
    [
      "ETH_BTC",
      2,
      0
    ],
  "id":1
}
```

#### Response "params" and "result" parameters

|  Name  |   Type  | Description                          |
| :----: | :-----: | ------------------------------------ |
| market |  STRING | Pair name                            |
|  type  |  STRING | Trade type (buy or sell)             |
|  time  | NUMERIC | Time in TimeStamp format             |
|   id   | NUMERIC | ID                                   |
| amount |  STRING | Trade amount (in 1st ticker of pair) |
|  price |  STRING | Trade price (in 1st ticker of pair)  |

#### Response example

```javascript
{
    "id": 1,
    "params": [
        "BTC_USDT",                        // market
        2,                                 // limit
        0                                  // lastId
    ],
    "result": [
        {
            "id": 19201768267,             // ID
            "type": "buy",                 // type
            "time": 1.727276247759E9,      // time
            "price": "63865.07",           // price
            "amount": "0.00448678"         // amount
        },
        {
            "id": 19201768100,
            "type": "sell",
            "time": 1.727276246117E9,
            "price": "63860.3281504",
            "amount": "0.00155184"
        }
    ],
    "error": null
}
```

### Deals Subscribe method

Used to subscribe to receive real-time updates.

#### Method

```javascript
deals.subscribe
```

#### Request "params" parameters

|                   Name                   |  Type  |       Type      | Example   |
| :--------------------------------------: | :----: | :-------------: | --------- |
| market<mark style="color:red;">\*</mark> | STRING | Any public pair | BTC\_USDT |

#### Request example

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

#### Response example (successfully subscribed)

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

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

|  Name  |   Type  | Description                          |
| :----: | :-----: | ------------------------------------ |
| market |  STRING | Pair name                            |
|   id   | NUMERIC | ID                                   |
|  type  |  STRING | Trade type (buy or sell)             |
|  time  | NUMERIC | Time in TimeStamp format             |
|  price |  STRING | Trade price (in 1st ticker of pair)  |
| amount |  STRING | Trade amount (in 1st ticker of pair) |

#### **Response example  ("**&#x64;eals.updat&#x65;**")**

```javascript
{
    "id": null,
    "method": "deals.update",
    "params": [
        "BTC_USDT",                           // market
        [
            {
                "id": 19201677141,            // ID
                "type": "sell",               // type
                "time": 1.727275412302E9,     // time
                "price": "63859.83136",       // price
                "amount": "0.0020744"         // amount
            },
            ...
            ]
    ]
}
```

### Deals Unsubscribe method

Used to unsubscribe from the [Deals Subscribe](#deals-subscribe-method) method.

#### Method

```javascript
deals.unsubscribe
```

#### Request example

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

#### Response example (successfully unsubscribed)

```javascript
{
    "id": 2,
    "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/deals-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.
