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
Name | Type(s) | Description |
---|---|---|
token_address | string , required | The address of the token for which to fetch data for. This is a required parameter. |
pool_address | string , required | This 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. |
chain | string | The chain of token_address .The default is eth . Valid options are: eth , base . |
price_type | string | This 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. |
interval | string | This 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_timestamp | integer | Return results whose timestamp_open are greater than or equal to the provided value.Default: 0 . |
until_timestamp | integer | Return 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_size | integer | The maximum number of records to return. Must be between 1 and 2500 . Default is 100 . |
order | string | The 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 . |
fill | boolean | Determines 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_volume | boolean | Determines whether to include trading volume information in the response. Valid options: true and false .Default: false . |
open_method | string | Determines 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 Type | Description |
---|---|
price_token_usd_tick_1 | The 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_1 | The same as price_token_usd_tick_1 but with significant outliers removed. |
Using
pool_address=all
Using
pool_address=all
will 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 toNone
.
Response Fields
Response Field | Type | Description |
---|---|---|
timestamp_open | integer | This 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_close | integer | This field indicates the timestamp at the end of the interval (inclusive) for the returned OHLC data in Unix timestamp format. |
date_open | string | This 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_close | string | This field represents the date and time at the end of the interval for the returned OHLC data, in ISO 8601 format. |
price_open | double | This field represents the opening price of the token for the given interval. |
price_high | double | This field represents the highest price of the token reached within the given interval. |
price_low | double | This field represents the lowest price of the token reached within the given interval. |
price_close | double | This 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.