> ## 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 Trade Stream

This stream provides real-time trade updates for a specified market.

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

```json theme={null}
{
    "resultType": "publicCompletedOrdersDelta",
    "market": "ETH-USDT",
    "data": {
        "orders": [
            {
                "executionType": "taker",
                "matchId": "9eb783a6-7abc-4e94-9d9c-fd404e7580eb",
                "orderType": "buy",
                "price": "3181.41",
                "quantity": "0.01",
                "updatedAt": 1767762810250
            },
            {
                "executionType": "maker",
                "matchId": "d65966ab-109c-491f-bb55-a6ccd0453153",
                "orderType": "sell",
                "price": "3181.42",
                "quantity": "0.02",
                "updatedAt": 1767762904115
            }
        ],
        "statusCode": 200
    }
}
```

| Field                         | Type   | Required | Description                                    |
| ----------------------------- | ------ | -------- | ---------------------------------------------- |
| `resultType`                  | string | Yes      | `publicCompletedOrdersDelta`                   |
| `market`                      | string | Yes      | Market name                                    |
| `data.orders`                 | array  | Yes      | New trade executions since last update         |
| `data.orders[].executionType` | string | Yes      | Order execution role: `taker` or `maker`       |
| `data.orders[].matchId`       | string | Yes      | Unique identifier for the trade match          |
| `data.orders[].orderType`     | string | Yes      | Order side: `buy` or `sell`                    |
| `data.orders[].price`         | string | Yes      | Execution price                                |
| `data.orders[].quantity`      | string | Yes      | Execution quantity                             |
| `data.orders[].updatedAt`     | number | Yes      | Execution timestamp (milliseconds since epoch) |
| `data.statusCode`             | number | Yes      | `200`                                          |

### Completed Orders Snapshot Request

There is one request called **emitPublicCompletedOrders** that returns a list of recent completed orders with `publicCompletedOrders` response messages. This request is useful for:

* Initial state hydration when first connecting to the stream
* Recovery after reconnects or connection interruptions
* Verifying historical execution completeness
* Getting recent trade history before processing real-time delta updates
* Reconciling local order state with server state

#### Request

```json theme={null}
{
  "message":"emitPublicCompletedOrders",
  "content": {
    "clientRequestId": "4cc68b60-ed2d-42aa-a21e-cb5486f8fd1a",
    "market": "ETH-USDT"
  }
}
```

| Field                     | Type   | Required | Description                                                  |
| ------------------------- | ------ | -------- | ------------------------------------------------------------ |
| `message`                 | string | Yes      | `emitPublicCompletedOrders`                                  |
| `content.clientRequestId` | string | No       | Client-generated UUID for correlation                        |
| `content.market`          | string | No       | Market name, only required when connecting with `market=ALL` |

#### Response

```json theme={null}
{
    "resultType": "publicCompletedOrders",
    "market": "ETH-USDT",
    "data": {
        "clientRequestId": "4cc68b60-ed2d-42aa-a21e-cb5486f8fd1a",
        "orders": [
            {
                "executionType": "taker",
                "matchId": "d65966ab-109c-491f-bb55-a6ccd0453153",
                "orderType": "buy",
                "price": "3181.41",
                "quantity": "0.01",
                "updatedAt": 1767762904115
            },
            {
                "executionType": "maker",
                "matchId": "9eb783a6-7abc-4e94-9d9c-fd404e7580eb",
                "orderType": "sell",
                "price": "3181.42",
                "quantity": "0.02",
                "updatedAt": 1767762810250
            }
        ],
        "statusCode": 200
    }
}
```

| Field                         | Type   | Required | Description                                    |
| ----------------------------- | ------ | -------- | ---------------------------------------------- |
| `resultType`                  | string | Yes      | `publicCompletedOrders`                        |
| `market`                      | string | Yes      | Market name                                    |
| `data.clientRequestId`        | string | No       | Client-generated UUID for correlation          |
| `data.orders`                 | array  | Yes      | Snapshot of recent trade executions            |
| `data.orders[].executionType` | string | Yes      | Order execution role: `taker` or `maker`       |
| `data.orders[].matchId`       | string | Yes      | Unique identifier for the trade match          |
| `data.orders[].orderType`     | string | Yes      | Order side: `buy` or `sell`                    |
| `data.orders[].price`         | string | Yes      | Execution price                                |
| `data.orders[].quantity`      | string | Yes      | Execution quantity                             |
| `data.orders[].updatedAt`     | number | Yes      | Execution timestamp (milliseconds since epoch) |
| `data.statusCode`             | number | Yes      | `200`                                          |
