History (bulk)

Many assets over many dates, in one request

GET https://api.tickerdb.com/v1/history

History returns one row per asset per date, with the fields you choose, for a list of tickers or a whole group of assets over a date range. It's for research and backtests: seven years of weekly P/E for every stock is one request, read in pages, instead of 409 Universe calls. It costs the same credits as those separate calls would.

curl
curl -G "https://api.tickerdb.com/v1/history" \ --data-urlencode 'tickers=AAPL' \ --data-urlencode 'fields=fundamentals_pe_ratio,momentum_rsi_zone,trend_direction' \ --data-urlencode 'timeframe=weekly' \ --data-urlencode 'start=2019-01-01' \ -H "Authorization: Bearer YOUR_API_KEY"
Response
{ "timeframe": "weekly", "scope": "tickers", "tickers_requested": 1, "unknown_tickers": [], "fields": ["ticker", "date", "asset_id", "fundamentals_pe_ratio", "momentum_rsi_zone", "trend_direction"], "page_size": 90000, "band_contract": "bands-2.15.0", "knowledge_cutoff": "04:00 UTC on the calendar day after the snapshot date", "history_start": "2019-01-01", "plan": "Pro", "start": "2019-01-06", "end": "2026-11-01", "cost": { "credits": 9, "scope": "tickers", "dates": 409, "rows": 409, "assets": 1, "field_blocks": 1, "by_date": 10225, "by_ticker": 9, "multiplier": 1 }, "pages": 1, "page_tokens": [], "row_count": 409, "has_more": false, "next_page_token": null, "rows": [ { "ticker": "AAPL", "date": "2019-01-06", "asset_id": 1042, "fundamentals_pe_ratio": 12.9, "momentum_rsi_zone": "neutral_low", "trend_direction": "downtrend" }, { "ticker": "AAPL", "date": "2019-01-13", "asset_id": 1042, "fundamentals_pe_ratio": 13.1, "momentum_rsi_zone": "neutral", "trend_direction": "downtrend" } ] }

Parameters

Send either tickers or a group (asset_class, member_of, held_by), not both. With neither, you get every asset. For a long ticker list, send the same parameters as a JSON body with POST.

ParameterDefaultDescription
tickers—Up to 5,000, as a comma-separated list or a JSON array. Unknown tickers are listed in unknown_tickers and cost nothing
asset_classallstock, etf or crypto
member_of, held_by—Members of an index, or holdings of a fund, on each row's date, as in Search
fields—Required unless ohlcv=true. Up to 30 fields from Schema, as in Universe. ticker, date and asset_id always come. Market fields aren't available here; get them from Market and join on date
timeframedailydaily or weekly
start, endyour plan's first date, todayInclusive dates, YYYY-MM-DD. How far back you can read depends on your plan
ohlcvfalsetrue adds the price bar to each row: ohlcv_open, ohlcv_high, ohlcv_low, ohlcv_close, ohlcv_volume, as on OHLCV
adjustmentsplitWith ohlcv: split, split_dividend or raw. See OHLCV
limitthe page sizeRows per page. A page holds up to 20,000 rows on Free and Plus and 90,000 on Pro and Commercial, fewer with many fields. A larger limit is lowered, not refused; page_size says what was used
page_token—A token from the first page, to read another page. See Pages
dry_runfalsetrue returns the price and the number of pages, without rows and without charging
A ticker list with daily price bars, as POST
curl "https://api.tickerdb.com/v1/history" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"tickers": ["AAPL", "MSFT", "NVDA"], "fields": ["trend_direction"], "ohlcv": true, "start": "2021-01-01"}'

Rows

Rows come grouped by asset, then in date order. ticker is the symbol the asset had on that date, so a 2020 row for today's META says FB. Group by asset_id, which never changes for an asset and never joins two companies that shared a symbol. Delisted assets keep their rows.

A row for date D includes everything known by 04:00 UTC the next morning, so a backtest acting on it should trade at the next session's open.

Pages

The first page carries pages (how many there are) and page_tokens, one token for each of the others. Send the same request with page_token to read one. Pages hold whole assets, so you can fetch them in any order, up to four at a time; in token order they keep the asset and date order.

When a single asset has more rows than a page holds, its page continues with next_page_token: send it as page_token until it comes back null. Tokens last 24 hours and only work for your account.

Read every page in Python
import requests, pandas as pd from concurrent.futures import ThreadPoolExecutor URL = "https://api.tickerdb.com/v1/history" H = {"Authorization": "Bearer YOUR_API_KEY"} params = {"asset_class": "stock", "fields": "fundamentals_pe_ratio", "timeframe": "weekly", "start": "2019-01-01"} def page(token=None): rows = [] while True: # next_page_token appears only when one asset outgrows a page body = requests.get(URL, headers=H, params={**params, **({"page_token": token} if token else {})}).json() rows += body["rows"] token = body["next_page_token"] if not token: return body, rows first, rows = page() # the whole request is charged here, once with ThreadPoolExecutor(4) as pool: # the other pages are free, in any order rest = list(pool.map(lambda t: page(t)[1], first["page_tokens"])) pe = pd.DataFrame(rows + [r for part in rest for r in part])

Credits

The whole request is charged once, on the first page; the other pages are free. It costs exactly what the same data would cost through separate calls:

  • A group (or every asset): one Universe call per date, so dates × 25 credits per 10 fields, however many assets.
  • A ticker list: per ticker, 1 credit per 50 dates (a Summary range call), plus 1 per 100 dates with ohlcv (OHLCV bars). At most the Universe price for the same dates.

ohlcv=true counts as 5 fields in the Universe price. Use dry_run=true to see the price before you pay it.

RequestCreditsThe same as
tickers=AAPL, 7 years weekly (409 dates), any fields99 Summary range calls
asset_class=stock, 7 years weekly, 10 fields10,225409 Universe calls at 25
500 tickers, 5 years daily (about 1,258 sessions), 10 fields13,000500 × 26 Summary range calls
Every asset, 3 years weekly, 10 fieldsabout 3,900about 157 Universe calls at 25
Price every stock's weekly P/E before paying
curl -G "https://api.tickerdb.com/v1/history" \ --data-urlencode 'asset_class=stock' \ --data-urlencode 'fields=fundamentals_pe_ratio' \ --data-urlencode 'timeframe=weekly' \ --data-urlencode 'dry_run=true' \ -H "Authorization: Bearer YOUR_API_KEY"

Limits

  • Up to 5,000 tickers and 30 fields per request.
  • Up to 2 million rows per request on Free, 6 million on Plus, and 25 million on Pro and Commercial. Split anything larger by dates, asset class or tickers.
  • Up to 40 pages per 10 seconds per API key. This is counted separately from your other calls, so a large pull doesn't slow them down.

Response fields

FieldTypeDescription
rowsobject[]The rows, with the keys in fields. See Rows
fieldsstring[]ticker, date, asset_id, your fields, then the ohlcv_* keys
scopestringtickers or universe. With tickers, also tickers_requested and unknown_tickers; with a group, asset_class and membership
start, endstringThe first and last dates covered
costobjectOn the first page and a dry run: credits charged, plus the counts behind them (dates, rows, assets) and both prices (by_date for Universe calls, by_ticker for per-ticker calls). Later pages say credits: 0
pages, page_tokensinteger, string[]First page only: how many pages, and a token for each of the others
row_count, has_more, next_page_tokeninteger, boolean, string | nullRows on this page, and whether this page continues
page_size, limit_noteinteger, stringRows per page, and a note when your limit was lowered
adjustmentstringWith ohlcv: the price basis used
history_start, planstringYour plan's first readable date, and your plan
knowledge_cutoff, band_contractstringAs on Universe

Errors

Statuserror.typeCauseWhat to do
400invalid_parameterNo fields, an unknown field, too many tickers or fields, tickers together with a group, start after end, adjustment without ohlcv, or a bad page_token.Read the message: it names the problem.
400request_too_largeMore rows than your plan allows in one request. The message gives the row count and price.Split it by dates, asset class or tickers.
402insufficient_credit_balanceNot enough credits for the whole request. Nothing is charged.Check the price with dry_run=true, then add credits or narrow the request.
403tier_restrictedstart is before your plan's first readable date.Start at history_start or later, or upgrade.
404ticker_not_foundNone of the tickers exist.Check the symbols, or find them with Search.
404no_dataNo rows in the range for these assets. Not charged.Widen the range, or try the other timeframe.
413, 415payload_too_large, unsupported_media_typeA POST body over 256 KB, or not sent as JSON.Send a smaller list with Content-Type: application/json.
429rate_limit_exceededMore than 40 pages in 10 seconds.Wait 10 seconds. Fetch at most four pages at a time.
429too_many_concurrent_queriesRequests for more than 15 fields, or with member_of or held_by, share a limited pool, and it's busy.Wait for the Retry-After seconds and send it again.

Errors aren't charged. Authentication and other rate-limit errors are on Authentication and Errors & Caching.