# Trades

## Stream trades in all pairs in Standard spot exchange

### ✅ Request

{% tabs %}
{% tab title="Subscription" %}
{% code title="Subscription" %}

```json
{
  "id": 1,
  "method": "spot.trades.subscribe.pairs.all",
  "params": null
}
```

{% endcode %}
{% endtab %}

{% tab title="Unsubscription" %}
{% code title="Unsubscription" %}

```json
{
  "id": 1,
  "method": "spot.trades.unsubscribe.pairs.all",
  "params": null
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 📤 Response

{% tabs %}
{% tab title="Success" %}
{% code title="Success" %}

```json
{
  "result": null,
  "id": 1
}
```

{% endcode %}
{% endtab %}

{% tab title="Error" %}
{% code title="Error" %}

```json
{
  "code": 1,
  "msg": "Internal Error: {error}"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 📡 Streamed Data Format

{% code title="Trade Stream" %}

```json
[
  "spotTrade",                  // eventId
  987654,                       // orderId
  "0xBaseTokenAddress",         // base token address
  "0xQuoteTokenAddress",        // quote token address
  "ETH",                        // base token symbol
  "USDC",                       // quote token symbol
  "0xPairAddress",              // pair contract address
  "ETH/USDC",                   // pair symbol
  true,                         // isBid (true = buy, false = sell)
  3142.25,                      // price
  "0xUserAddress",              // account (initiator)
  "0xAssetAddress",             // traded asset address
  "ETH",                        // traded asset symbol
  1.5,                          // amount (of asset)
  4713.375,                     // valueUSD
  1.5,                          // baseAmount
  4713.375,                     // quoteAmount
  1713657900,                   // timestamp (Unix)
  "0xTakerAddress",             // taker address
  "0xMakerAddress",             // maker address
  "0xTransactionHash"           // transaction hash
]
```

{% endcode %}

### 📄 Field Descriptions

| Index | Field         | Type    | Description                              |
| ----- | ------------- | ------- | ---------------------------------------- |
| 0     | `eventId`     | String  | Unique event identifier                  |
| 1     | `orderId`     | Number  | ID of the trade order                    |
| 2     | `base`        | String  | Base token address                       |
| 3     | `quote`       | String  | Quote token address                      |
| 4     | `baseSymbol`  | String  | Symbol of base token                     |
| 5     | `quoteSymbol` | String  | Symbol of quote token                    |
| 6     | `pair`        | String  | Address of the pair contract             |
| 7     | `pairSymbol`  | String  | Symbol of the pair (e.g., `ETH/USDC`)    |
| 8     | `isBid`       | Boolean | `true` if it's a buy, `false` if sell    |
| 9     | `price`       | Number  | Price per unit in quote token            |
| 10    | `account`     | String  | Address of the user initiating the trade |
| 11    | `asset`       | String  | Address of the asset being traded        |
| 12    | `assetSymbol` | String  | Symbol of the traded asset               |
| 13    | `amount`      | Number  | Amount of asset traded                   |
| 14    | `valueUSD`    | Number  | Trade value in USD                       |
| 15    | `baseAmount`  | Number  | Volume in base token                     |
| 16    | `quoteAmount` | Number  | Volume in quote token                    |
| 17    | `timestamp`   | Number  | Unix timestamp of the trade              |
| 18    | `taker`       | String  | Taker address                            |
| 19    | `maker`       | String  | Maker address                            |
| 20    | `txHash`      | String  | Transaction hash                         |

## Stream trades in specific pairs in Standard spot exchange

### ✅ Request

{% tabs %}
{% tab title="Subscription" %}
{% code title="Subscription" %}

```json
{
  "id": 1,
  "method": "spot.trades.subscribe.pairs",
  "params": {
    "pairs": ["ETH/USDC", "WBTC/USDT"]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="Unsubscription" %}
{% code title="Unsubscription" %}

```json
{
  "id": 1,
  "method": "spot.trades.unsubscribe.pairs",
  "params": {
    "pairs": ["ETH/USDC", "WBTC/USDT"]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 📤 Response

{% tabs %}
{% tab title="Success" %}
{% code title="Success" %}

```json
{
  "result": null,
  "id": 1
}
```

{% endcode %}
{% endtab %}

{% tab title="Error" %}
{% code title="Error" %}

```json
{
  "code": 1,
  "msg": "Internal Error: {error}"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 📡 Streamed Data Format

{% code title="Trade Stream" %}

```json
[
  "spotTrade",                  // eventId
  987654,                       // orderId
  "0xBaseTokenAddress",         // base token address
  "0xQuoteTokenAddress",        // quote token address
  "ETH",                        // base token symbol
  "USDC",                       // quote token symbol
  "0xPairAddress",              // pair contract address
  "ETH/USDC",                   // pair symbol
  true,                         // isBid (true = buy, false = sell)
  3142.25,                      // price
  "0xUserAddress",              // account (initiator)
  "0xAssetAddress",             // traded asset address
  "ETH",                        // traded asset symbol
  1.5,                          // amount (of asset)
  4713.375,                     // valueUSD
  1.5,                          // baseAmount
  4713.375,                     // quoteAmount
  1713657900,                   // timestamp (Unix)
  "0xTakerAddress",             // taker address
  "0xMakerAddress",             // maker address
  "0xTransactionHash"           // transaction hash
]
```

{% endcode %}

### 📄 Field Descriptions&#x20;

| Index | Field         | Type    | Description                              |
| ----- | ------------- | ------- | ---------------------------------------- |
| 0     | `eventId`     | String  | Unique event identifier                  |
| 1     | `orderId`     | Number  | ID of the trade order                    |
| 2     | `base`        | String  | Base token address                       |
| 3     | `quote`       | String  | Quote token address                      |
| 4     | `baseSymbol`  | String  | Symbol of base token                     |
| 5     | `quoteSymbol` | String  | Symbol of quote token                    |
| 6     | `pair`        | String  | Address of the pair contract             |
| 7     | `pairSymbol`  | String  | Symbol of the pair (e.g., `ETH/USDC`)    |
| 8     | `isBid`       | Boolean | `true` if it's a buy, `false` if sell    |
| 9     | `price`       | Number  | Price per unit in quote token            |
| 10    | `account`     | String  | Address of the user initiating the trade |
| 11    | `asset`       | String  | Address of the asset being traded        |
| 12    | `assetSymbol` | String  | Symbol of the traded asset               |
| 13    | `amount`      | Number  | Amount of asset traded                   |
| 14    | `valueUSD`    | Number  | Trade value in USD                       |
| 15    | `baseAmount`  | Number  | Volume in base token                     |
| 16    | `quoteAmount` | Number  | Volume in quote token                    |
| 17    | `timestamp`   | Number  | Unix timestamp of the trade              |
| 18    | `taker`       | String  | Taker address                            |
| 19    | `maker`       | String  | Maker address                            |
| 20    | `txHash`      | String  | Transaction hash                         |


---

# 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://docs.standard.im/apps/spot/for-developers/websocket-streams/trades.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.
