Token price candles (OHLCV)
const url = 'https://api.chainmetric.io/v2/token/1/c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2/ohlcv?interval=1h&pool=88e6a0c2ddd26feeb64f039a2c41296fcb3f5640&from=1795887600000000&to=1796037600000000&limit=500';const options = {method: 'GET', headers: {Authorization: '<Authorization>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://api.chainmetric.io/v2/token/1/c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2/ohlcv?interval=1h&pool=88e6a0c2ddd26feeb64f039a2c41296fcb3f5640&from=1795887600000000&to=1796037600000000&limit=500' \ --header 'Authorization: <Authorization>'Returns price candles for one token at one interval, oldest first.
Use it to draw a price chart or to read the price at a past time.
Without pool, the series follows the token’s main pool.
A candle exists only for a bucket that had at least one trade; empty buckets are not filled.
To page back in time, send an earlier to.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Chain id: 1 Ethereum, 56 BNB Chain, 8453 Base, 1399811149 Solana.
Example
1Token address. EVM is 40 lowercase hex characters without 0x; Solana is base58.
Example
c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2Query Parameters
Section titled “Query Parameters”Candle width.
Example
1hOnly this pool’s rows. A pool that is not the token’s gives an empty answer.
Example
88e6a0c2ddd26feeb64f039a2c41296fcb3f5640Earliest bucket start, Unix microseconds.
Example
1795887600000000Latest bucket start, Unix microseconds, inclusive.
Example
1796037600000000Candles per answer.
Example
500Responses
Section titled “Responses”The candles.
object
The document type, for example token_stats.
The document schema version.
The chain the document is about.
The token or wallet the document is about.
The stream topic of this document: <kind>.<chain_id>.<address>.
fast data is published as soon as a block is seen. safe data is published again once the block is final and replaces it.
How settled the data is: processed (Solana fast), confirmed (EVM fast) or finalized (safe).
The block height (or Solana slot) the document reflects.
Increases with every newer version of the document. Keep the highest.
When the document was built, Unix microseconds.
The document body. Its shape depends on kind.
object
object
object
Bucket start, Unix microseconds.
Price in quote-token units. Also high, low, close.
USD price. Also high_usd, low_usd, close_usd.
Volume in whole tokens.
Volume in whole quote tokens.
Volume in USD.
Swaps in the bucket.
The pool the candle was read from.
Examples
WETH on Ethereum, 5m
{ "kind": "token_ohlcv", "version": 1, "chain_id": 1, "address": "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "subject": "token_ohlcv.1.c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.5m", "lane": "fast", "commitment": "confirmed", "seq": 1796037600000, "updated_us": 1796037750364351, "data": { "candles": [ { "time_us": 1795887600000000, "open": 1647.7789049068542, "high": 1648.3065379720567, "low": 1647.4683169924433, "close": 1647.7960438688235, "open_usd": 1647.5482158601671, "high_usd": 1648.0757750567407, "low_usd": 1647.2376714280642, "close_usd": 1647.5653524226818, "volume_token": 30.080292851519083, "volume_quote": 49563.494918, "volume_usd": 49556.55602871148, "trades": 14, "pool": "88e6a0c2ddd26feeb64f039a2c41296fcb3f5640" }, { "time_us": 1795887900000000, "open": 1647.6538931195128, "high": 1647.6538931195128, "low": 1642.5918730202952, "close": 1643.1482367238566, "open_usd": 1647.423221574476, "high_usd": 1647.423221574476, "low_usd": 1642.3619101580723, "close_usd": 1642.9181959707153, "volume_token": 158.8748922578638, "volume_quote": 261096.127194, "volume_usd": 261059.57373619283, "trades": 28, "pool": "88e6a0c2ddd26feeb64f039a2c41296fcb3f5640" } ], "interval": "5m" }}A Solana token, 5m
{ "kind": "token_ohlcv", "version": 1, "chain_id": 1399811149, "address": "Fgpu9KDN2zREYHKSvSxp7LyYqUCL4ys8yKLH2v9vHDPe", "subject": "token_ohlcv.1399811149.Fgpu9KDN2zREYHKSvSxp7LyYqUCL4ys8yKLH2v9vHDPe.5m", "lane": "safe", "commitment": "finalized", "seq": 1796037300000, "updated_us": 1796037739027198, "data": { "candles": [ { "time_us": 1796037300000000, "open": 0.00000102187505819113, "high": 0.0000011634864587759332, "low": 2.0989355118494913e-10, "close": 2.568621532549536e-9, "open_usd": 0.0000730129495964669, "high_usd": 0.00008313108093777363, "low_usd": 1.4996889444016335e-8, "close_usd": 1.835279499045774e-7, "volume_token": 266289961.295747, "volume_quote": 193.033879168, "volume_usd": 13792.266263012703, "trades": 81, "pool": "388ab497b65abcf6336c5bbc406c23e9d06088e1cccd4b8d617b007f28c84b75" } ], "interval": "5m" }}The request is malformed, for example a bad address, an unknown chain or an out-of-range parameter. Do not retry unchanged.
Every error answer has this shape. error and message carry the same text.
object
What went wrong. For 5xx answers this is the status text.
The same text as error.
The HTTP status.
Examples
{ "error": "blockchain: unknown chain: \"ethereum\"", "message": "blockchain: unknown chain: \"ethereum\"", "statusCode": 400}The key is missing (api key missing), unknown (api key unknown) or revoked (api key revoked). Send Authorization: <key>.
Every error answer has this shape. error and message carry the same text.
object
What went wrong. For 5xx answers this is the status text.
The same text as error.
The HTTP status.
Examples
{ "error": "api key missing", "message": "api key missing", "statusCode": 401}The key’s request rate limit is reached. No Retry-After is sent; back off and retry.
Every error answer has this shape. error and message carry the same text.
object
What went wrong. For 5xx answers this is the status text.
The same text as error.
The HTTP status.
Examples
{ "error": "api key rate limit reached", "message": "api key rate limit reached", "statusCode": 429}The service is busy or catching up. Wait for the Retry-After header’s seconds when present (5 or 10), then retry. Without it, retry with exponential backoff.
Every error answer has this shape. error and message carry the same text.
object
What went wrong. For 5xx answers this is the status text.
The same text as error.
The HTTP status.
Examples
{ "error": "Service Unavailable", "message": "Service Unavailable", "statusCode": 503}Headers
Section titled “Headers”Seconds to wait before retrying.