Cambrian OHLCV (Token) API

By Cambrian Network evm

GET /evm/ohlcv/token

OHLCV (Token)

Overview

This endpoint retrieves OHLCV (Open, High, Low, Close, Volume) candles for an EVM token, computed from Base Uniswap v3-style swap data. Candles are available at intervals from 1 minute to 1 week, and an optional consensus filter can be applied to reduce noisy data.

Business Value

  • Price Charting: Powers candlestick charts and technical analysis tools for any EVM token across supported chains.
  • Backtesting & Strategy Development: Historical OHLCV series enable quantitative traders to backtest strategies over precise time windows.
  • Volatility & Liquidity Analysis: Combined price and volume data (in both USD and token terms) supports volatility and liquidity assessments.
  • Noise Reduction: The optional MAD filter helps produce cleaner candles by filtering out anomalous swap-driven price spikes.
  • Flexible Granularity: Interval options from 1 minute to 1 week let consumers tailor data resolution to their use case.

Endpoint Details

URL:

https://api.cambrian.org/evm/ohlcv/token

Method: GET
Authentication: Required via X-API-Key header

Query Parameters

Parameter Type Required Default Description
chain_id integer No 8453 EVM chain ID. One of: 1, 8453, 42161, 4663, 56
token_address string Yes - EVM token contract address, pattern ^0x[a-fA-F0-9]{40}$
after_time integer Yes - Unix timestamp (seconds) after which to retrieve OHLCV data
before_time integer Yes - Unix timestamp (seconds) before which to retrieve OHLCV data
interval string Yes - Candle interval. One of: 1m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w
use_filter boolean Yes - Whether to use the RWM7+pool consensus filter for the OHLCV query
limit integer No 100 Limit the number of results (max 10000)
offset integer No 0 Offset the results, allows skipping a number of rows before returning rows

Response Field Descriptions

Response Field Type Description
chainId UInt16 EVM chain ID the candle belongs to
openPriceUsd Float32 Opening price in USD for the interval
highPriceUsd Float32 Highest price in USD during the interval
lowPriceUsd Float32 Lowest price in USD during the interval
closePriceUsd Float32 Closing price in USD for the interval
volumeBoughtUsd Float64 Buy-side volume in USD during the interval
volumeSoldUsd Float64 Sell-side volume in USD during the interval
volumeBoughtToken Float64 Buy-side volume denominated in the token during the interval
volumeSoldToken Float64 Sell-side volume denominated in the token during the interval
unixTime UInt32 Unix timestamp (seconds) marking the start of the candle interval
interval String Candle interval represented by this row (e.g. "1h")
tokenAddress FixedString(42) EVM token contract address the candle data corresponds to

Examples

1. Retrieve hourly OHLCV candles for WETH on Base

This fetches 1-hour OHLCV candles for the WETH token on Base (chain ID 8453) between two Unix timestamps, using the consensus filter.

curl -X GET "https://api.cambrian.org/evm/ohlcv/token?token_address=0x4200000000000000000000000000000000000006&after_time=1735689600&before_time=1735776000&interval=1h&use_filter=True&limit=10" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json"

Response:

[
  {
    "columns": [
      {
        "name": "chainId",
        "type": "UInt16"
      },
      {
        "name": "openPriceUsd",
        "type": "Float32"
      },
      {
        "name": "highPriceUsd",
        "type": "Float32"
      },
      {
        "name": "lowPriceUsd",
        "type": "Float32"
      },
      {
        "name": "closePriceUsd",
        "type": "Float32"
      },
      {
        "name": "volumeBoughtUsd",
        "type": "Float64"
      },
      {
        "name": "volumeSoldUsd",
        "type": "Float64"
      },
      {
        "name": "volumeBoughtToken",
        "type": "Float64"
      },
      {
        "name": "volumeSoldToken",
        "type": "Float64"
      },
      {
        "name": "unixTime",
        "type": "UInt32"
      },
      {
        "name": "interval",
        "type": "String"
      },
      {
        "name": "tokenAddress",
        "type": "FixedString(42)"
      }
    ],
    "data": [
      [
        8453,
        3330.990478515625,
        3364.1650390625,
        3329.244873046875,
        3355.182373046875,
        11671535.248008711,
        5507519.430472437,
        3488.2146569223637,
        1646.954404558065,
        1735689600,
        "1h",
        "0x4200000000000000000000000000000000000006"
      ],
      [
        8453,
        3357.3486328125,
        3365.47119140625,
        3335.1826171875,
        3339.875,
        6751136.450000179,
        10180055.82014424,
        2015.1833968635947,
        3041.051452456663,
        1735693200,
        "1h",
        "0x4200000000000000000000000000000000000006"
      ],
      [
        8453,
        3338.6494140625,
        3363.337158203125,
        3337.80517578125,
        3354.95263671875,
        9739772.744918142,
        7228014.350250291,
        2908.0411885952317,
        2159.3021282572067,
        1735696800,
        "1h",
        "0x4200000000000000000000000000000000000006"
      ],
      [
        8453,
        3354.678466796875,
        3360.015380859375,
        3339.6748046875,
        3348.86181640625,
        6269153.96153974,
        7260200.927784716,
        1870.8947318233345,
        2167.935624969013,
        1735700400,
        "1h",
        "0x4200000000000000000000000000000000000006"
      ],
      [
        8453,
        3348.94580078125,
        3353.947021484375,
        3331.03076171875,
        3334.624267578125,
        5133926.383942099,
        8521547.333653519,
        1536.0399937461798,
        2551.3398254204767,
        1735704000,
        "1h",
        "0x4200000000000000000000000000000000000006"
      ],
      [
        8453,
        3333.260009765625,
        3349.83251953125,
        3331.072509765625,
        3338.666259765625,
        5074005.124108528,
        4045804.8826495465,
        1519.4843246643168,
        1212.2628352951108,
        1735707600,
        "1h",
        "0x4200000000000000000000000000000000000006"
      ],
      [
        8453,
        3338.902099609375,
        3344.451904296875,
        3326.92626953125,
        3336.0771484375,
        5410414.438194079,
        6205576.359512242,
        1621.5214982189252,
        1861.1007649527567,
        1735711200,
        "1h",
        "0x4200000000000000000000000000000000000006"
      ],
      [
        8453,
        3336.07666015625,
        3345.383544921875,
        3328.646240234375,
        3339.3974609375,
        4472285.575046726,
        4182876.031031919,
        1340.1214673358313,
        1254.3106417491688,
        1735714800,
        "1h",
        "0x4200000000000000000000000000000000000006"
      ],
      [
        8453,
        3339.83447265625,
        3347.17724609375,
        3323.121337890625,
        3331.64501953125,
        6016235.769028442,
        7807414.169115474,
        1804.5203262579714,
        2342.917232980187,
        1735718400,
        "1h",
        "0x4200000000000000000000000000000000000006"
      ],
      [
        8453,
        3328.861083984375,
        3338.7724609375,
        3305.47998046875,
        3327.57763671875,
        9600376.976409936,
        10962750.725147905,
        2890.67762941904,
        3302.515419442688,
        1735722000,
        "1h",
        "0x4200000000000000000000000000000000000006"
      ]
    ],
    "rows": 10
  }
]

Note: Result collections are limited to 10 items. The response shown here returns 10 sequential 1-hour candles for WETH on Base. Values in the data array follow the same order as the columns definitions above.

x402 Payment Option

This endpoint supports pay-per-use access via the x402 payment protocol (v2): pay $0.05 USDC per request using blockchain micropayments. No API key required.

Quick Start (TypeScript)

npm install @x402/fetch @x402/evm viem
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { wrapFetchWithPayment } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const client = new x402Client();
client.register("eip155:*", new ExactEvmScheme(signer));

const fetchWithPayment = wrapFetchWithPayment(fetch, client);
const response = await fetchWithPayment(
  "https://x402.cambrian.org/evm/ohlcv/token"
);
const data = await response.json();

Quick Start (Python)

pip install "x402[httpx]"
import asyncio, os
from eth_account import Account
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client

async def main():
    client = x402Client()
    account = Account.from_key(os.getenv("EVM_PRIVATE_KEY"))
    register_exact_evm_client(client, EthAccountSigner(account))

    async with x402HttpxClient(client) as http:
        response = await http.get("https://x402.cambrian.org/evm/ohlcv/token")
        print(response.json())

asyncio.run(main())

Payment Flow

  1. Send a normal request to the endpoint (no API key needed)
  2. Server returns 402 Payment Required with payment details
  3. The x402 SDK automatically signs a payment authorization with your wallet
  4. The SDK resubmits the request with the signed payment
  5. Server verifies payment and returns the API response

The x402 SDK handles steps 2 through 5 automatically.

Network: Base (chain ID 8453) | Currency: USDC | Price: $0.05 per request