# Get historical stock price data (OHLCV bars) with TickerLayer's API

TickerLayer's API returns historical OHLCV bars for one stock, currency pair, crypto pair, index, ETF or commodity between two UTC dates, at bar sizes from 1 minute to 1 day. The page size you set in `limit` sets the price of each request: $0.03 for up to 100 bars, $0.05 for up to 500 (the default) and $0.10 for up to 1,000. Send `GET https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/stocks/agg/{symbol}/{multiplier}/{timespan}/{from}/{to}` with `limit` and your agent credential, pay the 402 price quote, and retry.

## At a glance

- **Endpoint:** `GET https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/stocks/agg/{symbol}/{multiplier}/{timespan}/{from}/{to}`
- **Parameters:** path `symbol`, `multiplier`, `timespan` (`minute`, `hour`, `day`), `from` and `to` (`YYYY-MM-DD`, UTC, inclusive). Query `limit` (1 to 1000, default 500), `offset` and `sort` (`asc` or `desc`, default `desc`).
- **Price per request:** up to 100 bars $0.03, up to 500 $0.05, up to 1,000 $0.10
- **Payment:** a 402 price quote that you pay over x402 or MPP, the wallet rails that settle in USDC, and then retry
- **Credential:** an agent credential, sent as a bearer on every call. Registering one is a free call at [auth.md](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/auth.md).
- **Response:** `symbol`, `results` (bars with `o`, `h`, `l`, `c`, `v`, `t`), `results_count`, `total_count`, `next_offset`
- **Range per request:** from 31 days of 1-minute bars to 5,000 days of daily bars. A longer range returns `400`.
- **Full purchase flow:** [the buyer skill](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/SKILL.md)

## Request historical stock bars

1. Get an agent credential. [auth.md](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/auth.md) registers one anonymously in one free call and exchanges it for an access token, held below in `ACCESS_TOKEN`.

2. Send the request with `limit` set to the page size you need. This example asks for one month of daily bars:

   ```bash
   curl -s "https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/stocks/agg/US:KO/1/day/2026-10-01/2026-10-31?limit=100" \
     -H "Authorization: Bearer $ACCESS_TOKEN"
   ```

   The storefront answers `402` with the price for the `limit` tier in `payment.amountUsd`. It sends the signable challenges in the `payment-required` header for x402 and the `www-authenticate` header for MPP:

   ```json
   {"error": "payment_required", "payment": {"id": "apay_...", "amountUsd": "<price of the limit tier>"}, "protocols": {"x402": {"...": "..."}, "mpp": {"...": "..."}}}
   ```

   Nothing is charged at this point. You can stop here.

3. Pay and retry. A payment client does both. For example, `zero fetch` registers and sends a credential, pays the 402 and resends the request:

   ```bash
   zero fetch "https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/stocks/agg/US:KO/1/day/2026-10-01/2026-10-31?limit=100"
   ```

   Any x402 or MPP client works the same way, as long as it keeps the bearer on the paid retry. A page of up to 100 daily bars for `US:KO` for October 2026 paid $0.03.

4. Read the bars. The response is a JSON object with `symbol`, `results`, `results_count`, `total_count` and `next_offset`, and each bar in `results` carries `o`, `h`, `l`, `c`, `v` and `t`.

   ```json
   {
     "symbol": "US:KO",
     "results": [{"o": "<open>", "h": "<high>", "l": "<low>", "c": "<close>", "v": "<volume or null>", "t": "<bar start, Unix ms>"}],
     "results_count": "<bars on this page>",
     "total_count": "<bars in the whole range>",
     "next_offset": "<offset of the next page, or null>"
   }
   ```

   `v` is null when no consolidated volume exists for the interval. The data is derived and indicative. It comes from aggregated sources other than exchanges, so a value can lag or not match the official price.

## Choose the bar size and date range

Set `multiplier` and `timespan` together. Any other pair returns `400`.

| Bar size | `multiplier`/`timespan` | Longest range in one request |
| --- | --- | --- |
| 1 minute | `1/minute` | 31 days |
| 5 minutes | `5/minute` | 90 days |
| 15 minutes | `15/minute` | 180 days |
| 1 hour | `1/hour` | 365 days |
| 4 hours | `4/hour` | 730 days |
| 1 day | `1/day` | 5,000 days |

`from` and `to` are UTC dates and both are included. `to` must not be before `from`.

## Set limit to the page you need

The `limit` tier sets the price of a request. The number of bars in the range does not change it. For the October month above, the 402 quotes $0.03 with `limit=100`. For the same month with `limit=1000`, the 402 quotes $0.10. If you leave `limit` out, the request is billed at the default tier, $0.05.

Set `limit` to the bars the range needs. For a range larger than one page, compare the number of pages times the tier price:

| Range | `limit` | Requests | Cost |
| --- | --- | --- | --- |
| Up to 100 bars | `100` | 1 | $0.03 |
| Up to 100 bars | default | 1 | $0.05 |
| 3,000 bars | `1000` | 3 | $0.30 |
| 3,000 bars | `500` | 6 | $0.30 |
| 3,000 bars | `100` | 30 | $0.90 |

Bar requests are each below the $0.50 minimum for paying a single call by card. To pay by card, buy prepaid Credits with `POST https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/plans/{planId}/purchase`, using the plan id from [the catalog](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/manifest.json). The minimum purchase is $0.50, or $0.50 by card. Each call then draws down the balance.

## Page through a longer range

`total_count` is the number of bars in the whole range, and `results_count` is the number on this page. While `next_offset` is not null, send the same request again with `&offset=<next_offset>` and the same `limit`. Each page is a separate paid request. `sort` orders the bars by timestamp before paging, and `offset` is zero-based. Send `sort=asc` to read oldest first.

## Forex, crypto, indices, ETFs and commodities

Forex and crypto take the same bars request on their own routes, with the same parameters, range limits and three `limit` tiers. Indices, ETFs and commodities also serve historical OHLCV bars priced in the same three page-size tiers, and each service's API reference gives its path.

| Asset class | Symbol form | Example | Route or reference | Up to 100 / 500 / 1,000 |
| --- | --- | --- | --- | --- |
| Stocks | Market-qualified `CC:SYMBOL` | `US:KO`, `DE:BMW` | `/stocks/agg/{symbol}/{multiplier}/{timespan}/{from}/{to}` | $0.03 / $0.05 / $0.10 |
| Forex | Six-letter pair | `EURUSD` | `/forex/agg/{symbol}/{multiplier}/{timespan}/{from}/{to}` | $0.03 / $0.05 / $0.10 |
| Crypto | Spot pair | `BTCUSD` | `/crypto/agg/{symbol}/{multiplier}/{timespan}/{from}/{to}` | $0.03 / $0.05 / $0.10 |
| Indices | Code with no market prefix | `US500` | [Indices reference](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/services/indices/openapi.json) | $0.03 / $0.05 / $0.10 |
| ETFs | Reference code, or a prefixed Asian listing | `US500ETF`, `HK:2800` | [ETFs reference](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/services/etfs/openapi.json) | $0.03 / $0.05 / $0.10 |
| Commodities | Reference code | `XAUUSD` | [Commodities reference](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/services/commodities/openapi.json) | $0.03 / $0.05 / $0.10 |

`GET https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/stocks/symbols` lists the enabled stock symbols for $0.02.

## Boundaries

- One symbol per request. There is no batch call for bars.
- A bare stock ticker without a market prefix is refused. Stock symbols take the `CC:SYMBOL` form, such as `US:KO`.
- An unpaid 402 charges nothing. Payment happens only when you settle it.

## Errors

| Response | Meaning | Action |
| --- | --- | --- |
| `401 bearer_required` | The call carried no agent credential | Register at [auth.md](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/auth.md) and retry with the bearer |
| `402` | The price quote | Pay and retry the same request, or stop |
| `400` | Unsupported bar size, `to` before `from`, or a range longer than the size allows. `message` lists the valid values. | Fix the path or query and resend |
| `404` | Symbol not available. On stock and forex routes, `hint` names the routes for a symbol from another asset class. | Use the route in `hint`, or check the symbol list |
| `429` `REST_RATE_LIMIT_EXCEEDED` | Per-second limit reached | Wait `retryAfterMs` milliseconds, then retry |
| `settlement_failed` | The payment did not settle | Fix the wallet and send a fresh request |

## Frequently asked questions

### How much does historical stock price data cost on TickerLayer?

Each request costs the price of its `limit` tier: $0.03 for up to 100 bars, $0.05 for up to 500 and $0.10 for up to 1,000. A range that needs several pages costs the number of pages times the tier price. The 402 states the exact amount before you pay.

### Is TickerLayer's OHLCV data official exchange data?

No. The data is derived and indicative. It comes from aggregated sources other than exchanges, so values can lag or not match official prices.

### Can I get intraday stock data, such as 1-minute bars?

Yes. Set `1/minute`, `5/minute`, `15/minute`, `1/hour` or `4/hour` in the path. One request covers up to 31 days of 1-minute bars, and more at the larger sizes.

### Does the historical bars API work for forex and crypto prices?

Yes. Send the same request on `/forex/agg/{symbol}/{multiplier}/{timespan}/{from}/{to}` with a pair such as `EURUSD`, or on `/crypto/agg/{symbol}/{multiplier}/{timespan}/{from}/{to}` with a pair such as `BTCUSD`. Pricing uses the same three `limit` tiers.

### Do I need a TickerLayer API key?

No. Every call carries an agent credential that you register in one free call, and you pay each request through its 402 or from prepaid Credits.

## Keep reading

- [Buyer skill](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/SKILL.md): the full purchase flow
- [How to pay](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/payment.md): x402, MPP, card and Credits
- [Stocks API reference](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/services/stocks/openapi.json): every parameter and response field
- [Error reference](https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/errors.md): every error code and how to react

---

Updated 2026-11-17. All TickerLayer guides: https://agents.tickerlayer.com/guides.md. Storefront: https://agents.tickerlayer.com/zcj/qcv1mh1ijolw/llms.txt.
