Coin OHLC candles
GET /api/coin-ohlcOHLC candles for a coin: days 1 (30-min candles), 7 or 14 (4-hour), 30 / 90 / 180 / 365 (daily), in any vs currency. Send GET /api/coin-ohlc with the required field coin and pay $0.008 per call over x402 or MPP (there is no free tier). It returns a JSON object with source, fetchedAt, cached, coin, currency and 5 more.
Returns aligned {time, open, high, low, close} bars plus the window's high/low/first/last and % change. The candle sibling of crypto-history, which returns close-only points: use OHLC for technical indicators, range/volatility work and charting. Cached in-process for 60 seconds.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
coin | string | yes | Coin id (bitcoin, ethereum, ...). Also accepted as symbol, id, ticker, asset. |
days | number | no | 1, 7, 14, 30, 90, 180 or 365 (default 7). |
currency | string | no | vs currency (default usd). |
Example request
curl -i "https://agent402.tools/api/coin-ohlc?coin=bitcoin&days=7¤cy=usd"
Without payment this returns HTTP 402 Payment Required with the exact price for coin-ohlc; any x402 v2 or MPP client pays it and retries.
Example response
{
"source": "coingecko",
"fetchedAt": "2026-08-22T13:20:00.000Z",
"cached": false,
"coin": "bitcoin",
"currency": "usd",
"days": 7,
"count": 42,
"granularity": "4h",
"summary": {
"first": 66120.4,
"last": 68210,
"high": 69850,
"low": 64995.9,
"changePct": 3.16
},
"bars": [
{
"time": "2026-08-15T16:00:00.000Z",
"open": 66120.4,
"high": 66500.1,
"low": 65900,
"close": 66210.3
}
]
}
| Field | Type | Always present | In the example |
|---|---|---|---|
source | string | yes | coingecko |
fetchedAt | string | yes | 2026-08-22T13:20:00.000Z |
cached | boolean | yes | false |
coin | string | yes | bitcoin |
currency | string | yes | usd |
days | number | yes | 7 |
count | number | yes | 42 |
granularity | string | yes | 4h |
summary | object | yes | 5 fields: first, last, high, low, changePct |
bars | array of objects | yes | 1 item in the example |
From an MCP client
catalog.call {
"slug": "coin-ohlc",
"params": {
"coin": "bitcoin",
"days": 7,
"currency": "usd"
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for coin-ohlc; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
coinis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement is cancelled when the tool fails. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key (
Authorization: Bearer a402_...) also pays it. - A
POSTwith a JSON body to /api/coin-ohlc is served as this GET, with the body as the input. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/coin-ohlc?coin=bitcoin&days=7¤cy=usd");
Related tools
Token price history (USD)
POST /api/token-price-historyHistorical USD price series for a token, by ticker symbol (ETH, BTC, SOL, ...) or by ERC-20 contract + network, at 5-min…
Coin market chart for a time window
GET /api/coin-market-chart-rangePrice, market cap and volume series for a coin over an ARBITRARY time window: `from`/`to` as unix seconds or ISO dates, …
Crypto technical indicators
POST /api/crypto-indicatorsTechnical indicators for one perpetual computed deterministically from Hyperliquid candles: RSI(14), MACD(12,26,9) with …
DeFi chain TVL history
POST /api/defi-chain-tvl-historyDaily TVL history for one chain (Ethereum, Base, Solana, Arbitrum...) or for all of DeFi (chain "all") from DefiLlama's …
DeFi yield pool history
POST /api/defi-yield-historyDaily APY and TVL history for one DeFi yield pool (DefiLlama pool id from defi-yields): per-day total/base/reward APY an…
Perp candles (OHLCV)
POST /api/perp-klinesOHLCV candles for one perpetual at intervals from 1m to 1M (1m 3m 5m 15m 30m 1h 2h 4h 8h 12h 1d 3d 1w 1M), newest last, …