> For the complete documentation index, see [llms.txt](https://lynx-4.gitbook.io/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lynx-4.gitbook.io/api/websockets/candles.md).

# Candles

#### Subscribing and Unsubscribing to Candlestick Data

Our WebSocket API provides real-time candlestick data, enabling you to track market trends with high granularity. To receive updates for candlestick data, you will need to subscribe to a specific interval and pair. Here's how you can manage your candlestick data subscriptions:

**Subscribing to Candlestick Updates**

To receive real-time candlestick data, send a subscription request over your WebSocket connection. Your message should specify the desire to subscribe (`"action": "subscribe"`), indicate the type of subscription (`"subscription_type": "Candles"`), and provide the necessary details like the `interval`, `pair_id`, and `asset_id`.

The subscription message format is as follows:

```json
{
    "action": "subscribe",
    "subscription_type": "Candles",
    "interval": "YourInterval",
    "pair_id": "YourPairID",
    "asset_id": "YourAssetID"
}
```

* `YourInterval`: Set this to the desired candlestick interval (1m, 5m, 15m, 30m, 1h, 4h, 1d).
* `YourPairID`: The identifier for the trade pair.
* `YourAssetID`: The identifier for the asset.

For example, to subscribe to 15-minute candlestick data for a specific pair:

```json
{
    "action": "subscribe",
    "subscription_type": "Candles",
    "interval": "15m",
    "pair_id": "0x16b9a82891338f9ba80e2d6970fdda79d1eb0dae:56",
    "asset_id": "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c:56"
}
```

**Unsubscribing from Candlestick Updates**

If you wish to stop receiving candlestick data, you can unsubscribe by sending a message similar to the subscription request but with the action set to `"unsubscribe"`:

```json
{
    "action": "unsubscribe",
    "subscription_type": "Candles",
    "interval": "YourInterval",
    "pair_id": "YourPairID",
    "asset_id": "YourAssetID"
}
```

Replace the placeholders with the same details you used to subscribe.

**Receiving Candlestick Data**

Once subscribed, you will receive the most recent candlestick data in real time. The messages follow this format:

```json
{
    "channel": "candles::0x16b9a82891338f9ba80e2d6970fdda79d1eb0dae:56::15m::0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c:56",
    "subscription_type": "Candles",
    "data": {
        "open": 579.617,
        "high": 579.7306000000002,
        "low": 573.4459999999999,
        "close": 578.9962,
        "volume": 42357.15760313226,
        "date": "2024-03-15T11:00:00Z",
        "time": 1710500400000
    }
}
```
