Stock historical bars
GET /api/stock-historyDaily OHLCV bars for a US equity: the last `days` sessions, 1 to 250, default 30. Send GET /api/stock-history with the required field symbol and pay $0.005 per call over x402 or MPP (there is no free tier). It returns a JSON object with symbol, days, bars, asOf, venues and 2 more.
Daily only, no intraday. Built from a three-venue consolidation (Databento DBEQ.BASIC), so each bar's high and low are the extremes across those venues, open and close come from the venue that traded the most that session, and venueVolume sums those three venues rather than the consolidated tape. A flat ascending array ready for charting or backtests. Set indicators to also get technical analysis computed from the same bars: RSI(14), MACD(12,26,9), EMA 20/50/200, SMA 20/50, Bollinger(20,2) and ATR(14), with a plain summary (close vs EMA50, RSI zone, MACD cross). Indicators need enough sessions (EMA200 needs days >= 200) and are descriptive, not a trading recommendation.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
symbol | string | yes | US equity ticker, e.g. AAPL. Indices, FX and crypto are not covered. Also accepted as ticker, coin, asset. |
days | integer | no | Trading sessions to return, 1 to 250 (default 30). |
indicators | any | no | true for all, or a list of: rsi, macd, ema, sma, bollinger, atr. Computed from the returned bars (default none). |
points | integer | no | Series points per indicator, newest last (default 5, max 100). Only with indicators. |
Example request
curl -i "https://agent402.tools/api/stock-history?symbol=AAPL&days=30"
Without payment this returns HTTP 402 Payment Required with the exact price for stock-history; any x402 v2 or MPP client pays it and retries.
Example response
{
"symbol": "AAPL",
"days": 2,
"bars": [
{
"day": "2026-09-17",
"open": 218.2,
"high": 220.3,
"low": 217.65,
"close": 219.8,
"venueVolume": 1481234
},
{
"day": "2026-09-18",
"open": 219.9,
"high": 221.05,
"low": 219.1,
"close": 220.4,
"venueVolume": 1630155
}
],
"asOf": "2026-09-18",
"venues": "NYSE Texas (formerly NYSE Chicago), NYSE National, IEX",
"source": "databento.com DBEQ.BASIC",
"note": "Daily bars from a three-venue consolidation; venueVolume counts those venues only, not the consolidated tape."
}
| Field | Type | Always present | In the example |
|---|---|---|---|
symbol | string | yes | AAPL |
days | number | yes | 2 |
bars | array of objects | yes | 2 items in the example |
asOf | string | yes | 2026-09-18 |
venues | string | yes | NYSE Texas (formerly NYSE Chicago), NYSE National, IEX |
source | string | yes | databento.com DBEQ.BASIC |
note | string | yes | Daily bars from a three-venue consolidation; venueVolume counts those venues ... |
From an MCP client
catalog.call {
"slug": "stock-history",
"params": {
"symbol": "AAPL",
"days": 30
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for stock-history; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
symbolis 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 issued earlier (
Authorization: Bearer a402_...) also pays it. - A
POSTwith a JSON body to /api/stock-history 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/stock-history?symbol=AAPL&days=30");
Part of these workflows
Stock historical bars is one step in these 6 skill packs, each sold as a single call:
- Options analytics - Price a European option on a live stock: pull the current quote, estimate volatility from recent history, run Black-Scholes for fair value + the full greeks, and check the news for catalysts.
- Financial analysis - Quick company snapshot: latest close, 9 key financial metrics (revenue through cash flow), and upcoming earnings - one call, one payment.
- Financial research - Pull SEC filings, the latest close, historical prices, and macro context for a single ticker in one pass.
- Trend analysis - Take any numeric time series - a stock's daily close, a FRED macro indicator, a treasury yield history - and run it through the full quantitative workup: descriptives, moving averages, trend line, outliers, optional correlation against a benchmark, and a deterministic forecast forward with a 95% prediction interval. Everything an analyst writes a notebook for, in one chain of cheap calls.
- Forecasting bake-off - Don't guess which forecasting method to trust. Backtest all four (naive/drift, SES, Holt, Holt-Winters) on a real series, rank by out-of-sample RMSE, then forecast forward with the winner and its 95% prediction interval. Method selection without the hand-waving.
- Cross-asset price monitor - Side-by-side snapshot of a stock and a crypto asset: the equity's latest close against a live crypto quote, a trailing-year series for each, and a date-stamped comparison.
Related tools
Stock quote
GET /api/stock-quoteEnd-of-day US equity quote: last close, day range, previous close and the change between them. US equities only; indices…
Amortization schedule
POST /api/amortizationBuild the full per-period amortization schedule for a fully-amortizing loan. Each row reports the period number, payment…
Annuity present/future value
POST /api/annuityPresent and future value of a level annuity (equal periodic payments). Supports an ordinary annuity (payments at period …
Black-Scholes option price
POST /api/black-scholesPrice a European option (call or put) with the Black-Scholes-Merton model, plus the greeks (delta, gamma, vega, theta, r…
Bond price
POST /api/bond-pricePrice a fixed-coupon bond from its yield to maturity: present-value the coupons plus face. Returns clean price, coupon p…
Bond yield to maturity
POST /api/bond-ytmSolve a bond's yield to maturity from its market price - the annual rate that present-values the coupons plus face to th…