> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kraken.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Trades

> Subscribe to real-time trade events when orders are matched in the book

<div className="api-banner">
  <span className="api-protocol ws">WSS</span>
  <span className="api-detail">ws.kraken.com/v2</span>
  <span className="api-tag">trade</span>
</div>

The `trade` channel generates a trade event when orders are matched in the book.

Multiple trades may be batched in a single message but that does not mean that these trades resulted from a single taker order.

The feed accepts a list of symbols for subscription.

## Subscribe

<Tabs>
  <Tab title="Request">
    <ResponseField name="method" type="string" required>
      Value: `subscribe`
    </ResponseField>

    <ResponseField name="params" type="object" required>
      <Expandable title="properties" defaultOpen>
        <ResponseField name="channel" type="string" required>
          Value: `trade`
        </ResponseField>

        <ResponseField name="symbol" type="string[]" required>
          <span className="field-attr">Example:</span> `["BTC/USD", "MATIC/GBP"]`

          A list of currency pairs.
        </ResponseField>

        <ResponseField name="snapshot" type="boolean">
          <span className="field-attr">One of:</span> `true`, `false`<br />
          <span className="field-attr">Default:</span> `false`

          Request a snapshot after subscribing.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="req_id" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>
  </Tab>

  <Tab title="Response">
    <ResponseField name="method" type="string" required>
      Value: `subscribe`
    </ResponseField>

    <ResponseField name="result" type="object">
      <Expandable title="properties" defaultOpen>
        <ResponseField name="channel" type="string" required>
          Value: `trade`
        </ResponseField>

        <ResponseField name="symbol" type="string" required>
          <span className="field-attr">Example:</span> `"BTC/USD"`

          The currency pair associated with this subscription.
        </ResponseField>

        <ResponseField name="snapshot" type="boolean">
          Indicates if a snapshot is requested.
        </ResponseField>

        <ResponseField name="warnings" type="string[]">
          An advisory message, highlighting deprecated fields or upcoming changes to the channel.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="success" type="boolean">
      Indicates if the request was successfully processed by the engine. One of: `true`, `false`
    </ResponseField>

    <ResponseField name="error" type="string">
      Error message. Condition: if `success` is `false`.
    </ResponseField>

    <ResponseField name="time_in" type="string">
      The timestamp when the subscription was received on the wire, just prior to parsing data. Format: RFC3339. Example: `2022-12-25T09:30:59.123456Z`
    </ResponseField>

    <ResponseField name="time_out" type="string">
      The timestamp when the acknowledgement was sent on the wire, just prior to transmitting data. Format: RFC3339. Example: `2022-12-25T09:30:59.123456Z`
    </ResponseField>

    <ResponseField name="req_id" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>
  </Tab>
</Tabs>

## Snapshot / Update

The snapshot and update responses share the same schema. An update message is streamed on a trade event.

The snapshot reflects the most recent 50 trades.

<ResponseField name="channel" type="string">
  Value: `trade`
</ResponseField>

<ResponseField name="type" type="string">
  <span className="field-attr">One of:</span> `snapshot`, `update`
</ResponseField>

<ResponseField name="data" type="object[]">
  A list of trade events.

  <Expandable title="properties" defaultOpen>
    <ResponseField name="symbol" type="string">
      <span className="field-attr">Example:</span> `"BTC/USD"`

      The symbol of the currency pair.
    </ResponseField>

    <ResponseField name="side" type="string">The side of the taker order.</ResponseField>
    <ResponseField name="qty" type="float">Size of the trade.</ResponseField>
    <ResponseField name="price" type="float">Average price of the trade.</ResponseField>

    <ResponseField name="ord_type" type="string">
      <span className="field-attr">One of:</span> `limit`, `market`

      The order type of the taker order.
    </ResponseField>

    <ResponseField name="trade_id" type="integer">Trade identifier is a sequence number, unique per book.</ResponseField>

    <ResponseField name="timestamp" type="string">
      <span className="field-attr">Format:</span> RFC3339<br />
      <span className="field-attr">Example:</span> `2022-12-25T09:30:59.123456Z`

      The book order update timestamp.
    </ResponseField>
  </Expandable>
</ResponseField>

## Unsubscribe

<Tabs>
  <Tab title="Request">
    <ResponseField name="method" type="string" required>
      Value: `unsubscribe`
    </ResponseField>

    <ResponseField name="params" type="object" required>
      <Expandable title="properties" defaultOpen>
        <ResponseField name="channel" type="string" required>
          Value: `trade`
        </ResponseField>

        <ResponseField name="symbol" type="string[]" required>
          <span className="field-attr">Example:</span> `["BTC/USD", "MATIC/GBP"]`

          A list of currency pairs.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="req_id" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>
  </Tab>

  <Tab title="Response">
    <ResponseField name="method" type="string" required>
      Value: `unsubscribe`
    </ResponseField>

    <ResponseField name="result" type="object">
      <Expandable title="properties" defaultOpen>
        <ResponseField name="channel" type="string" required>
          Value: `trade`
        </ResponseField>

        <ResponseField name="symbol" type="string" required>
          <span className="field-attr">Example:</span> `"BTC/USD"`

          The currency pair associated with this subscription.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="success" type="boolean">
      Indicates if the request was successfully processed by the engine. One of: `true`, `false`
    </ResponseField>

    <ResponseField name="error" type="string">
      Error message. Condition: if `success` is `false`.
    </ResponseField>

    <ResponseField name="time_in" type="string">
      The timestamp when the subscription was received on the wire, just prior to parsing data. Format: RFC3339. Example: `2022-12-25T09:30:59.123456Z`
    </ResponseField>

    <ResponseField name="time_out" type="string">
      The timestamp when the acknowledgement was sent on the wire, just prior to transmitting data. Format: RFC3339. Example: `2022-12-25T09:30:59.123456Z`
    </ResponseField>

    <ResponseField name="req_id" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>
  </Tab>
</Tabs>

<Panel>
  <CodeGroup>
    ```json Subscribe Request theme={null}
    {
        "method": "subscribe",
        "params": {
            "channel": "trade",
            "symbol": [
                "MATIC/USD"
            ],
            "snapshot": true
        }
    }
    ```

    ```json Subscribe Response theme={null}
    {
        "method": "subscribe",
        "result": {
            "channel": "trade",
            "snapshot": true,
            "symbol": "MATIC/USD"
        },
        "success": true,
        "time_in": "2023-09-25T09:21:10.428340Z",
        "time_out": "2023-09-25T09:21:10.428375Z"
    }
    ```
  </CodeGroup>

  <CodeGroup>
    ```json Snapshot theme={null}
    {
        "channel": "trade",
        "type": "snapshot",
        "data": [
            {
                "symbol": "MATIC/USD",
                "side": "buy",
                "price": 0.5147,
                "qty": 6423.46326,
                "ord_type": "limit",
                "trade_id": 4665846,
                "timestamp": "2023-09-25T07:48:36.925533Z"
            },
            {
                "symbol": "MATIC/USD",
                "side": "buy",
                "price": 0.5147,
                "qty": 1136.19677815,
                "ord_type": "limit",
                "trade_id": 4665847,
                "timestamp": "2023-09-25T07:49:36.925603Z"
            }
        ]
    }
    ```

    ```json Update theme={null}
    {
        "channel": "trade",
        "type": "update",
        "data": [
            {
                "symbol": "MATIC/USD",
                "side": "sell",
                "price": 0.5117,
                "qty": 40.0,
                "ord_type": "market",
                "trade_id": 4665906,
                "timestamp": "2023-09-25T07:49:37.708706Z"
            }
        ]
    }
    ```
  </CodeGroup>

  <CodeGroup>
    ```json Unsubscribe Request theme={null}
    {
        "method": "unsubscribe",
        "params": {
            "channel": "trade",
            "symbol": [
                "MATIC/USD"
            ],
            "snapshot": true
        }
    }
    ```

    ```json Unsubscribe Response theme={null}
    {
        "method": "unsubscribe",
        "result": {
            "channel": "trade",
            "symbol": "MATIC/USD"
        },
        "success": true,
        "time_in": "2023-09-25T09:21:10.428340Z",
        "time_out": "2023-09-25T09:21:10.428375Z"
    }
    ```
  </CodeGroup>
</Panel>
