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

# Public Trades Stream

This stream provides real-time public trade executions for a single **contract**. Subscribe
with the `publicTrades` subscription. New executions arrive as `publicCompletedOrdersDelta`
messages, and you can request a snapshot of recent trades with `emitPublicCompletedOrders`.

Upon subscription to this stream, you will receive `publicCompletedOrdersDelta` messages
whenever new trades are executed:

```json theme={null}
{
  "resultType": "publicCompletedOrdersDelta",
  "market": "BTC-10JUL26-55000-C",
  "data": {
    "orders": [
      {
        "executionType": "taker",
        "matchId": "01KWM432SK16GA5ZV3H6TQSDRC:01KWW1ERZ59PWXTRVP2YSDA2SB",
        "price": "7204.26",
        "quantity": "1",
        "side": "sell",
        "updatedAt": 1783352484913
      }
    ],
    "statusCode": 200
  }
}
```

| Field                         | Type   | Required | Description                                                            |
| ----------------------------- | ------ | -------- | ---------------------------------------------------------------------- |
| `resultType`                  | string | Yes      | `publicCompletedOrdersDelta`                                           |
| `market`                      | string | Yes      | Contract name                                                          |
| `data.orders`                 | array  | Yes      | New trade executions since the last update                             |
| `data.orders[].executionType` | string | Yes      | Execution role: `taker` or `maker`                                     |
| `data.orders[].matchId`       | string | Yes      | Identifier for the trade match (shared by the taker and maker entries) |
| `data.orders[].price`         | string | Yes      | Execution price                                                        |
| `data.orders[].quantity`      | string | Yes      | Execution quantity                                                     |
| `data.orders[].side`          | string | Yes      | Side of the order: `buy` or `sell`                                     |
| `data.orders[].updatedAt`     | number | Yes      | Execution timestamp (ms since epoch)                                   |
| `data.statusCode`             | number | Yes      | `200`                                                                  |

### Recent Trades Snapshot Request

Request recent trade history with `emitPublicCompletedOrders`, which returns a
`publicCompletedOrders` message. Use it to hydrate recent trades when you first subscribe, or
to resynchronize after a gap.

#### Request

```json theme={null}
{
  "message": "emitPublicCompletedOrders",
  "content": {
    "clientRequestId": "f45cf3c8-3f2d-4ace-80de-8cb4da0a63bb",
    "market": "BTC-10JUL26-55000-C"
  }
}
```

| Field                     | Type   | Required | Description                           |
| ------------------------- | ------ | -------- | ------------------------------------- |
| `message`                 | string | Yes      | `emitPublicCompletedOrders`           |
| `content.clientRequestId` | string | No       | Client-generated UUID for correlation |
| `content.market`          | string | Yes      | Contract name                         |

#### Response

```json theme={null}
{
  "resultType": "publicCompletedOrders",
  "market": "BTC-10JUL26-55000-C",
  "data": {
    "clientRequestId": "f45cf3c8-3f2d-4ace-80de-8cb4da0a63bb",
    "orders": [
      {
        "executionType": "taker",
        "matchId": "9b8e7bc6-c111-46e7-81f2-04691780c1fd-1",
        "price": "7204.26",
        "quantity": "1",
        "side": "sell",
        "updatedAt": 1783352484840
      },
      {
        "executionType": "maker",
        "matchId": "9b8e7bc6-c111-46e7-81f2-04691780c1fd-1",
        "price": "7204.26",
        "quantity": "1",
        "side": "buy",
        "updatedAt": 1783086811956
      },
      {
        "executionType": "taker",
        "matchId": "a9716fab-8ac2-47fd-803e-44e2ca22b948-1",
        "price": "7210.97",
        "quantity": "1",
        "side": "buy",
        "updatedAt": 1783339818825
      },
      {
        "executionType": "maker",
        "matchId": "a9716fab-8ac2-47fd-803e-44e2ca22b948-1",
        "price": "7210.97",
        "quantity": "1",
        "side": "sell",
        "updatedAt": 1783086557575
      }
    ],
    "statusCode": 200
  }
}
```

| Field                         | Type   | Required | Description                                                            |
| ----------------------------- | ------ | -------- | ---------------------------------------------------------------------- |
| `resultType`                  | string | Yes      | `publicCompletedOrders`                                                |
| `market`                      | string | Yes      | Contract name                                                          |
| `data.clientRequestId`        | string | No       | Client-generated UUID for correlation                                  |
| `data.orders`                 | array  | Yes      | Snapshot of recent trade executions                                    |
| `data.orders[].executionType` | string | Yes      | Execution role: `taker` or `maker`                                     |
| `data.orders[].matchId`       | string | Yes      | Identifier for the trade match (shared by the taker and maker entries) |
| `data.orders[].price`         | string | Yes      | Execution price                                                        |
| `data.orders[].quantity`      | string | Yes      | Execution quantity                                                     |
| `data.orders[].side`          | string | Yes      | Side of the order: `buy` or `sell`                                     |
| `data.orders[].updatedAt`     | number | Yes      | Execution timestamp (ms since epoch)                                   |
| `data.statusCode`             | number | Yes      | `200`                                                                  |
