Use this endpoint to return aggregated Open-High-Low-Close historical token prices.

Method: GET

Endpoint: https://api.syve.ai/v1/price/historical/ohlc

Request Parameters

NameType(s)Description
token_addressstring, requiredThe address of the token for which to fetch data for.

This is a required parameter.
pool_addressstring, requiredThis is the address of the liquidity pool from which the OHLC prices will be fetched.

The default is all, which will consider all pools when calculating OHLC.
chainstringThe chain of token_address.

The default is eth. Valid options are: eth, matic.
price_typestringThis parameter determines what price to use to create OHLC with.

The default is price_token_usd_robust_tick_1. All possible options for price_type are given in the table below.
intervalstringThis parameter determines the time interval for each bucket of OHLC data.

The format should be <value><freq>, where freq can be, "m" (minutes), "h" (hours), or "d" (days).

For example, "10m" would represent a 10-minute interval, and "1d" would represent a 1-day interval. The default value is "1d" (1 day).
from_timestampintegerReturn results whose timestamp_open are greater than or equal to the provided value.

Default: 0.
until_timestampintegerReturn results whose timestamp_open are less than or equal to the provided value.

Default: The current timestamp (at the time the request is made).
max_sizeintegerThe maximum number of records to return.

Must be between 1 and 2500. Default is 100.
orderstringThe order in which data is returned. Valid options are desc and asc.

If desc more recent data is returned first. If asc older data is returned first.

Default: desc.
fillbooleanDetermines what to do if no trades occurred in an interval.

If true the gap is filled by using the close price of the previous interval.

If false all prices are null in the interval.

Default: true.
with_volumebooleanDetermines whether to include trading volume information in the response. Valid options: true and false.

Default: false.
open_methodstringDetermines how to calculate the open price. Valid options: prev_close and first_trade.

If prev_close the open price is the close price of the previous interval.

If first_trade the open price is the first trade that occurs in the current interval.

Default: prev_close.

📘

Possible Price Types

The possible price types you can calculate OHLC prices from correspond to the prices returned by our DEX Trades table.

Price TypeDescription
price_token_usd_tick_1The price at which a token was traded based on the most recent swap.

Note: The price on a given swap can be a significant outlier; therefore it is not recommended for calculating OHLC.
price_token_usd_robust_tick_1The same as price_token_usd_tick_1 but with significant outliers removed.
price_token_usd_robust_total_{1h|24h}This provides the total price, in USD, based on both buy and sell trades executed in the last 1 or 24 hour(s).
price_token_usd_robust_buy_{1h|24h}This metric gives the total price, in USD, based solely on buy trades that have occurred in the last 1 or 24 hour(s).
price_token_usd_robust_sell_{1h|24}This shows the total price, in USD, accumulated from all sell trades in the last 1 or 24 hour(s).
price_token_usd_robust_mid_{1h|24h}The mid price is the average of the buy price and the sell price.

📘

Using pool_address=all

Using pool_address=allwill consider all pools when calculating OHLC prices.

Example request: https://api.syve.ai/v1/price/historical/ohlc?token_address=0xf819d9cb1c2a819fd991781a822de3ca8607c3c9&pool_address=all

Using pool_address=all is recommended. It is particularly useful for (1) calculating OHLC for low volume tokens and (2) when you don't know which pools a token is traded in beforehand.

📘

Using fill=true

During a lot of periods there will be no trades made. If no trades are made in a period then no price will exist for that period.

  • If fill=true then open, high, low, close of a period with no trades will all equal to the previous period close.
  • If fill=false then a period with no trades will have open, high, low, close equal to None.

Response Fields

Response FieldTypeDescription
timestamp_openintegerThis field indicates the timestamp at the beginning of the interval (inclusive) for the returned OHLC data.

It's in Unix timestamp format (seconds since the Unix Epoch, 1970-01-01 00:00:00 UTC).
timestamp_closeintegerThis field indicates the timestamp at the end of the interval (inclusive) for the returned OHLC data in Unix timestamp format.
date_openstringThis field represents the date and time at the beginning of the interval for the returned OHLC data, in ISO 8601 format (yyyy-mm-ddThh:mm:ssZ).
date_closestringThis field represents the date and time at the end of the interval for the returned OHLC data, in ISO 8601 format.
price_opendoubleThis field represents the opening price of the token for the given interval.
price_highdoubleThis field represents the highest price of the token reached within the given interval.
price_lowdoubleThis field represents the lowest price of the token reached within the given interval.
price_closedoubleThis field represents the closing price of the token for the given interval. It's based on the last trade that occurred within the interval.

Example: Hourly OHLC for the last week for $UNIBOT

📘

Try it out

In the Live Example section you can try out the request with different arguments.

Query

curl --location 'https://api.syve.ai/v1/price/historical/ohlc'\
'?token_address=0xf819d9cb1c2a819fd991781a822de3ca8607c3c9'\
'&pool_address=0x8dbee21e8586ee356130074aaa789c33159921ca'\
'&interval=1h'

Here 0xf819d9cb1c2a819fd991781a822de3ca8607c3c9 is the address of $UNIBOT token, and 0x8dbee21e8586ee356130074aaa789c33159921ca the Uniswap V2 pool that contains it.

Response

{
  	"token_address": "0xf819d9cb1c2a819fd991781a822de3ca8607c3c9",
  	"data": [
        {
            "timestamp_open": 1690527600,
            "timestamp_close": 1690531199,
            "date_open": "2023-07-28T07:00:00Z",
            "date_close": "2023-07-28T07:59:59Z",
            "price_open": 170.40256496400727,
            "price_high": 172.97458845396704,
            "price_low": 170.01828954994824,
            "price_close": 170.01828954994824
        },
      	...
        {
            "timestamp_open": 1690563600,
            "timestamp_close": 1690567199,
            "date_open": "2023-07-28T17:00:00Z",
            "date_close": "2023-07-28T17:59:59Z",
            "price_open": 157.68641915551052,
            "price_high": 160.33296473989554,
            "price_low": 152.1719143867401,
            "price_close": 156.23746998564206
        }
    ]
}

Live Example

Press Try It to make a request and see what the response looks like. Feel free to try different query parameters.

Language
Click Try It! to start a request and see the response here!