# Prices

#### Subscribing and Unsubscribing to Prices

Our WebSocket API provides real-time price data, allowing you to subscribe and receive price updates for one or many assets. To manage your subscriptions, you'll need to send structured messages over your established WebSocket connection. Below are the details on subscribing to and unsubscribing from price updates on specified asset\_ids.

**Subscribing to Price Updates**

To start receiving real-time updates for a token, you need to send a subscription message over your WebSocket connection. The message should specify that you wish to subscribe (`"action": "subscribe"`) to prices (`"subscription_type": "Prades"`) for an array of asset IDs.

Here's the structure of the subscription message you should send:

```json
{
    "action": "subscribe",
    "subscription_type": "Prices",
    "asset_ids": ["YourAssetID"]
}
```

Replace `YourAssetID` with the identifiers of the assets you are interested in. For example, if you want to subscribe to two tokens on BSC, your message might look like this:

```json
{
        "action": "subscribe",
        "subscription_type": "Prices",
        "asset_ids": [
                "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c:56", 
                "0x16b9a82891338f9ba80e2d6970fdda79d1eb0dae:56"
        ]
}
```

**Unsubscribing from Price Updates**

If you wish to stop receiving updates for an asset, you can unsubscribe by sending a similar message with the action set to `"unsubscribe"`:

```json
{
        "action": "subscribe",
        "subscription_type": "Prices",
        "asset_ids": [
                "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c:56", 
                "0x16b9a82891338f9ba80e2d6970fdda79d1eb0dae:56"
        ]
}
```

**Receiving Price Updates**

Once you've successfully subscribed, trade updates will be sent to your WebSocket connection in real-time. These messages will follow this format:

{% hint style="info" %}
Please note, that these updates will be for any trade involving this token across all liquidity pools on our supported dexes.
{% endhint %}

```json
{
    "channel": "prices::0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c:56",
    "subscription_type": "Prices",
    "data": {
        "pair_id": "0xfba77f6859288cda1354a5699a51705fe3db7a0d:56",
        "date": "2024-09-10T18:46:41Z",
        "block_number": 42138999,
        "chain": 56,
        "exchange": "0x10ed43c718714eb63d5aa57b78b54704e256024e",
        "factory_address": "0xca143ce32fe78f1f7019d7d551a6402fc5350c73",
        "hash": "0x35e5002be29581ad6063a3ba02626f75a135ba9280e1a2c17f041e4ee9760de1",
        "log_index": 285,
        "maker": "0xbbc6596be645b2eb35215edb2bea6cd8a2fc48e3",
        "pair_address": "0xfba77f6859288cda1354a5699a51705fe3db7a0d",
        "token0_address": "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
        "token0_amount": 0.338342626735313,
        "token0_price": 523.62,
        "token0_reserves": 24.440651386166984,
        "token0_symbol": "wbnb",
        "token1_address": "0xbe7c63b293ef0efaaf9a80c595a4cbc926ea54f6",
        "token1_amount": 110.0633649824218,
        "token1_price": 1.6096451915625083,
        "token1_reserves": 8040.767541929579,
        "token1_symbol": "CLT",
        "side": "buy",
        "price": 523.62,
        "volume": 177.1629662111446
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lynx-4.gitbook.io/api/websockets/prices.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
