# Streams ## Available Streams See below the available streams you can subscribe to: ```rust pub enum StreamSubscription { // pass `null` product_id to subscribe to all products OrderUpdate { product_id: Option, subaccount: H256 }, Trade { product_id: u32 }, BestBidOffer { product_id: u32 }, // pass `null` product_id to subscribe to all products Fill { product_id: Option, subaccount: H256 }, // pass `null` product_id to subscribe to all products PositionChange { product_id: Option, subaccount: H256}, BookDepth { product_id: u32 }, // pass `null` product_id to subscribe to all products Liquidation { product_id: Option }, LatestCandlestick { product_id: u32, // time interval in seconds (e.g., 60, 300, 900, 3600) granularity: i32 }, FundingPayment { product_id: u32 }, // pass `null` product_id to subscribe to all products FundingRate { product_id: Option } } ``` ## **Subscribing to a stream** {% tabs %} {% tab title="Order Update" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** *Requires Authentication: Yes.* {% hint style="info" %} **Note**: Set `product_id` to `null` to subscribe to order updates across all products for the subaccount. {% endhint %} ```json { "method": "subscribe", "stream": { "type": "order_update", "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000", "product_id": 1 }, "id": 10 } ``` **Subscribe to all products:** ```json { "method": "subscribe", "stream": { "type": "order_update", "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000", "product_id": null }, "id": 10 } ``` {% endtab %} {% tab title="Trade" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** *Requires Authentication: No.* ```json { "method": "subscribe", "stream": { "type": "trade", "product_id": 0 }, "id": 10 } ``` {% endtab %} {% tab title="Best Bid Offer" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** *Requires Authentication: No.* ```json { "method": "subscribe", "stream": { "type": "best_bid_offer", "product_id": 0 }, "id": 10 } ``` {% endtab %} {% endtabs %} {% tabs %} {% tab title="Fill" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** *Requires Authentication: No.* {% hint style="info" %} **Note**: Set `product_id` to `null` to subscribe to fills across all products for the subaccount. {% endhint %} ```json { "method": "subscribe", "stream": { "type": "fill", "product_id": 1, "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000" }, "id": 10 } ``` **Subscribe to all products:** ```json { "method": "subscribe", "stream": { "type": "fill", "product_id": null, "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000" }, "id": 10 } ``` {% endtab %} {% tab title="Position Change" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** *Requires Authentication: No.* {% hint style="info" %} **Note**: Set `product_id` to `null` to subscribe to position changes across all products for the subaccount. {% endhint %} ```json { "method": "subscribe", "stream": { "type": "position_change", "product_id": 0, "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000" }, "id": 10 } ``` **Subscribe to all products:** ```json { "method": "subscribe", "stream": { "type": "position_change", "product_id": null, "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000" }, "id": 10 } ``` {% endtab %} {% tab title="Book Depth" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** *Requires Authentication: No.* ```json { "method": "subscribe", "stream": { "type": "book_depth", "product_id": 0 }, "id": 10 } ``` {% endtab %} {% endtabs %} {% tabs %} {% tab title="Liquidation" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** *Requires Authentication: No.* {% hint style="info" %} **Note**: Set `product_id` to `null` to subscribe to liquidations across all products. {% endhint %} ```json { "method": "subscribe", "stream": { "type": "liquidation", "product_id": 1 }, "id": 10 } ``` **Subscribe to all products:** ```json { "method": "subscribe", "stream": { "type": "liquidation", "product_id": null }, "id": 10 } ``` {% endtab %} {% tab title="Latest Candlestick" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** {% hint style="info" %} See all supportes `granularity` values in [Available Granularities](https://docs.nado.xyz/developer-resources/archive-indexer/candlesticks#available-granularities) {% endhint %} *Requires Authentication: No.* ```json { "method": "subscribe", "stream": { "type": "latest_candlestick", "product_id": 1, "granularity": 60 }, "id": 10 } ``` {% endtab %} {% tab title="Funding Payment" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** *Requires Authentication: No.* ```json { "method": "subscribe", "stream": { "type": "funding_payment", "product_id": 2 }, "id": 10 } ``` {% endtab %} {% tab title="Funding Rate" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** *Requires Authentication: No.* {% hint style="info" %} **Note**: Set `product_id` to `null` to subscribe to funding rate updates across all products. {% endhint %} ```json { "method": "subscribe", "stream": { "type": "funding_rate", "product_id": 2 }, "id": 10 } ``` **Subscribe to all products:** ```json { "method": "subscribe", "stream": { "type": "funding_rate", "product_id": null }, "id": 10 } ``` {% endtab %} {% endtabs %} ### **Response** ```json { "result": null, "id": 10 } ``` ## **Unsubscribing** {% tabs %} {% tab title="Order Update" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** ```json { "method": "unsubscribe", "stream": { "type": "order_update", "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000", "product_id": 1 }, "id": 10 } ``` **Unsubscribe from all products:** ```json { "method": "unsubscribe", "stream": { "type": "order_update", "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000", "product_id": null }, "id": 10 } ``` {% endtab %} {% tab title="Trade" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** ```json { "method": "unsubscribe", "stream": { "type": "trade", "product_id": 0 }, "id": 10 } ``` {% endtab %} {% tab title="Best Bid Offer" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** ```json { "method": "unsubscribe", "stream": { "type": "best_bid_offer", "product_id": 0 }, "id": 10 } ``` {% endtab %} {% tab title="Fill" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** ```json { "method": "unsubscribe", "stream": { "type": "fill", "product_id": 0, "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000" }, "id": 10 } ``` {% endtab %} {% tab title="Position Change" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** ```json { "method": "unsubscribe", "stream": { "type": "position_change", "product_id": 0, "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000" }, "id": 10 } ``` {% endtab %} {% tab title="Book Depth" %} **Connect** `WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]` **Message** ```json { "method": "unsubscribe", "stream": { "type": "book_depth", "product_id": 0, }, "id": 10 } ``` {% endtab %} {% endtabs %} ### **Response** ```json { "result": null, "id": 10 } ``` ## **Listing subscribed streams** ```json { "method": "list", "id": 10 } ``` ### Response ```json { "result": [ { "type": "default" }, { "type": "trade", "product_id": 0 } ], "id": 10 } ```