📊Candle Chart Data

Endpoint

GET /api/v1/candles

Description

This endpoint returns data for a given token and liquidity pair that can be used to create a candlestick chart. This endpoint is designed seamlessly with Trading View advanced charts.

Understanding the asset_id Parameter

The choice of asset_id determines the viewpoint from which market data is analyzed and presented in the candlestick chart:

  • Chart Perspective: The orientation of the chart is directly influenced by the asset_id.

    • When the asset_id corresponds to the first token in the pair (token0), the chart displays the price movements and trading activity with this token as the focal point.

    • Conversely, if the asset_id is set to the second token in the pair (token1), the chart is oriented to highlight the price dynamics and transactions from the perspective of this token.

For example, with a trading pair of BNB (token0) and USDT (token1):

  • If asset_id is BNB:

    • The chart will showcase the price fluctuations and trade volumes of BNB, with each candlestick representing BNB's price performance against USDT over the specified time intervals.

  • If asset_id is USDT:

    • The perspective shifts to USDT's standpoint, with the chart illustrating how USDT's price moves relative to BNB, effectively making BNB the base token in this context.

Query String Parameters

  • asset_id (required): A string in the format <TOKEN_CONTRACT_ADDRESS>:<NETWORK_ID> that identifies the token you are interested in, in the LP pair. This should be either the token1_id or token0_id on the trading pair.

  • from (required): The date should be in ISO 8601 format (e.g., 2024-02-16T02:00:00Z).

  • to (required): The date should be in ISO 8601 format (e.g., 2024-02-16T02:00:00Z).

  • pair_id (required): A string in the format <PAIR_CONTRACT_ADDRESS>:<NETWORK_ID>.

  • interval (required): Interval you are interested in. (1m, 5m, 15m, 30m, 1h, 4h, 1d).

Headers

  • x-api-key (required): A valid API key.

Example

curl -X GET 'https://data.lynxcrypto.app/api/v1/candles?target_asset_id=0xd16fd95d949f996e3808eeea0e3881c59e76ef1e%3A1&from=2024-02-16T12%3A18%3A00.000Z&pair_id=0xbcc900232730a6bff08edeb0b9baccdd28a335ff%3A1&interval=1h&to=2024-02-19T02%3A00%3A00.000Z'
-H 'x-api-key: <YOUR_API_KEY>'

Response

[
        "open": 0.00013566256926221892,
        "high": 0.00013566256926221892,
        "low": 0.00013566256926221892,
        "close": 0.00013566256926221892,
        "volume": 0.0,
        "date": "2024-02-18T19:00:00Z",
        "time": 1708282800000
    },
    {
        "open": 0.00013566256926221892,
        "high": 0.00013557382650941245,
        "low": 0.00013557382650941245,
        "close": 0.00013557382650941245,
        "volume": 530.0872222416165,
        "date": "2024-02-18T20:00:00Z",
        "time": 1708286400000
    },
    {
        "open": 0.00013557382650941245,
        "high": 0.00013557382650941245,
        "low": 0.00013557382650941245,
        "close": 0.00013557382650941245,
        "volume": 0.0,
        "date": "2024-02-18T21:00:00Z",
        "time": 1708290000000
    },
]

Response Object

  • high: The highest price over the interval.

  • low: The lowest price over the interval.

  • open: The opening price for the interval (first data point).

  • close: The closing price for the interval (last data point).

  • volume: The volume of the token over the interval.

Response Codes

  • 200: Success. Returns the USD price for the given token.

  • 400: Bad Request. The tokenId, interval, or days query string parameter is not provided or days is greater than 90 or less than 1.

  • 403: Forbidden. The x-api-key header is not provided or is invalid.

  • 404: Not Found. No price updates found within the given time range

Last updated