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, dataset and 4 more.
Daily only, no intraday. Built from the official consolidated end-of-day summary across all US exchanges and ATSs, so price, range and volume are market totals. If that dataset is unavailable for a read, the answer comes from a consolidation of three U.S. exchange venues instead and says so: coverage reads three-venue, venueVolume counts those venues only and volume is null. On that fallback each bar's high and low are the extremes across the three venues and open and close come from the venue that traded the most that session. 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-10-12",
"open": 338.215,
"high": 342.63,
"low": 337.6,
"close": 340.97,
"venueVolume": 25900599,
"volume": 25900599
},
{
"day": "2026-10-13",
"open": 344.665,
"high": 348.1499,
"low": 340.74,
"close": 341.27,
"venueVolume": 38983839,
"volume": 38983839
}
],
"asOf": "2026-10-13",
"dataset": "EQUS.SUMMARY",
"coverage": "consolidated",
"venues": "All US exchanges and ATSs (consolidated end-of-day summary)",
"source": "databento.com EQUS.SUMMARY",
"note": "Official consolidated end-of-day bars across all US exchanges and ATSs; volume is the consolidated total and includes post-market trading. Prices are unadjusted for splits and dividends."
}
| 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-10-13 |
dataset | string | yes | EQUS.SUMMARY |
coverage | string | yes | consolidated |
venues | string | yes | All US exchanges and ATSs (consolidated end-of-day summary) |
source | string | yes | databento.com EQUS.SUMMARY |
note | string | yes | Official consolidated end-of-day bars across all US exchanges and ATSs; volum... |
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 an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y [email protected].
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 canceled 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?.({ maxAmountPerPayment: "$0.005" }); // refuse any quote above this tool's price
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, consolidated volume, previous close and the change between them.
Amortization schedule
POST /api/amortizationBuild the full per-period amortization schedule for a fully-amortizing loan.
Annuity present/future value
POST /api/annuityPresent and future value of a level annuity (equal periodic payments).
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.
Bond price
POST /api/bond-pricePrice a fixed-coupon bond from its yield to maturity: present-value the coupons plus face.
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.