> For the complete documentation index, see [llms.txt](https://sodex.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sodex.com/documentation/trading-api/websocket-v1/all-coin-prices.md).

# All Coin Prices Stream

Coin price and margin ratio for all coins pushed on updating. This stream is available for perps only. **Note that only coin prices that have changed will be present in the update array**.

## Update Speed

* Pushed on each block that is at least 1 second since the last push when price or margin ratio changes.

## Subscribe Request

* Subscribe Schema

See [`WsAllCoinPriceSubscriptionParams`](/documentation/trading-api/rest-v1/schema.md#wsallcoinpricesubscriptionparams) in [Schema](/documentation/trading-api/rest-v1/schema.md).

```typescript
interface SubscribeRequest {
  op: "subscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  params: WsAllCoinPriceSubscriptionParams;
}
```

* Subscribe Ack Schema

See [`WsAllCoinPriceSubscriptionResult`](/documentation/trading-api/rest-v1/schema.md#wsallcoinpricesubscriptionresult) in [Schema](/documentation/trading-api/rest-v1/schema.md).

```typescript
interface SubscriptionResult {
  op: "subscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  result: WsAllCoinPriceSubscriptionResult | null;
  success: boolean; // Indicates if the request was successfully processed by the engine.
  connID: string;
  error: string | null; // Condition: If success is false. Error message.
  time_in: number; // The timestamp when the subscription was received on the wire, just prior to parsing data, in milliseconds.
  time_out: number; // The timestamp when the acknowledgement was sent on the wire, just prior to transmitting data, in milliseconds.
}
```

* Example: Subscribe

```json
{
  "op": "subscribe",
  "params": {
    "channel": "allCoinPrice"
  }
}
```

* Example: Subscribe Ack

```json
{
  "op": "subscribe",
  "result": {
    "channel": "allCoinPrice"
  },
  "success": true,
  "connID": "0xb0922dfe2b14dadb1195ea4db2b45508",
  "time_in": 1672515782130,
  "time_out": 1672515782136
}
```

## Unsubscribe Request

* Unsubscribe Schema

See [`WsAllCoinPriceSubscriptionParams`](/documentation/trading-api/rest-v1/schema.md#wsallcoinpricesubscriptionparams) in [Schema](/documentation/trading-api/rest-v1/schema.md).

```typescript
interface UnsubscribeRequest {
  op: "unsubscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  params: WsAllCoinPriceSubscriptionParams;
}
```

* Unsubscribe Ack Schema

See [`WsAllCoinPriceSubscriptionResult`](/documentation/trading-api/rest-v1/schema.md#wsallcoinpricesubscriptionresult) in [Schema](/documentation/trading-api/rest-v1/schema.md).

```typescript
interface UnsubscriptionResult {
  op: "unsubscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  result: WsAllCoinPriceSubscriptionResult | null;
  success: boolean; // Indicates if the request was successfully processed by the engine.
  connID: string;
  error: string | null; // Condition: If success is false. Error message.
  time_in: number; // The timestamp when the subscription was received on the wire, just prior to parsing data, in milliseconds.
  time_out: number; // The timestamp when the acknowledgement was sent on the wire, just prior to transmitting data, in milliseconds.
}
```

* Example: Unsubscribe

```json
{
  "op": "unsubscribe",
  "params": {
    "channel": "allCoinPrice"
  }
}
```

* Example: Unsubscribe Ack

```json
{
  "op": "unsubscribe",
  "result": {
    "channel": "allCoinPrice"
  },
  "success": true,
  "connID": "0xb0922dfe2b14dadb1195ea4db2b45508",
  "time_in": 1672515782130,
  "time_out": 1672515782136
}
```

## Snapshot / Update Response

* Snapshot / Update Schema

See [`WsCoinPriceData`](/documentation/trading-api/rest-v1/schema.md#wscoinpricedata) in [Schema](/documentation/trading-api/rest-v1/schema.md).

```typescript
interface AllCoinPriceResponse {
  channel: "allCoinPrice";
  type: "snapshot" | "update";
  data: Array<WsCoinPriceData>;
}
```

* Example: Snapshot

```json
{
  "channel": "allCoinPrice",
  "type": "snapshot",
  "data": [
    {
      "E": 1781104148461,
      "i": 1,
      "a": "vBTC",
      "p": "61984.5",
      "mr": "0.9"
    },
    {
      "E": 1781104148461,
      "i": 2,
      "a": "vETH",
      "p": "1640.66",
      "mr": "0.85"
    }
  ]
}
```

* Example: Update

```json
{
  "channel": "allCoinPrice",
  "type": "update",
  "data": [
    {
      "E": 1781104149161,
      "i": 2,
      "a": "vETH",
      "p": "1640.66",
      "mr": "0.85"
    },
    {
      "E": 1781104149161,
      "i": 44,
      "a": "vDEFI.ssi",
      "p": "0.3307316954868111",
      "mr": "0"
    }
  ]
}
```
