AI stock index API
Daily historical data for the HAI Composite, an equal-weighted index of 53 publicly traded AI stocks, and for every constituent: index levels, OHLCV prices and a one-call matrix of closes. JSON or CSV, over plain HTTPS GET. Free and open: no sign-up and no key for up to 10 requests per 5 minutes.
curl "https://happyai.today/api/v1/index/history?range=1y"Quick start
- Call any endpoint under
https://happyai.today/api/v1. No key and no sign-up: you get 10 requests per 5 minutes per IP address. - Need more? Ask for an API key and send it in the
X-API-Keyheader. Requests with a key are not rate limited.
curl "https://happyai.today/api/v1/index/history?range=1y"curl -H "X-API-Key: $HAI_API_KEY" \
"https://happyai.today/api/v1/index/history?range=1y"{
"index": "HAI Composite",
"range": "1m",
"base": 1000,
"baseDate": "2025-10-23",
"from": "2026-10-26",
"to": "2026-11-25",
"count": 22,
"data": [
{
"date": "2026-10-26",
"level": 1251.08
},
{
"date": "2026-10-27",
"level": 1263.9
}
]
}Access & keys
The API is public. Past the limit, requests without a key get 429 with a Retry-After header until the five-minute window clears. The limit is enforced at the edge and is approximate: a short burst can slip a few requests over before it takes hold.
For higher rates, request an API key: write to admin@lunaratech.com and say what you are building. A key looks like hai_ followed by 40 letters and digits. It is shown once when it is created; only a hash of it is stored, so a lost key is replaced, not recovered. Send it one of three ways:
| Where | How | Use it for |
|---|---|---|
| Header | X-API-Key: hai_… | Recommended. |
| Bearer token | Authorization: Bearer hai_… | Clients that only speak bearer auth. |
| Query string | ?api_key=hai_… | Spreadsheets and tools that cannot set headers. URLs end up in logs and history, so prefer a header. |
Treat a key like a password: keep it on your server, out of browser code and public repositories. If one leaks, ask for it to be revoked; a revoked key stops working within a few minutes. A request that sends an unknown or expired key is refused with 403, not served at the public rate.
Every response carries Access-Control-Allow-Origin: *, so a web page can call the API without a key. Requests that set a key header are not supported from a browser.
Endpoints
| Endpoint | Returns | Formats |
|---|---|---|
| GET /index | The HAI Composite's latest level, base and constituent count. | JSON |
| GET /index/history | Daily HAI Composite levels. | JSON, CSV |
| GET /constituents | Every stock in the index, with its segment, weight and the dates its history covers. | JSON |
| GET /constituents/{symbol}/history | Daily open, high, low, close and volume for one constituent. | JSON, CSV |
| GET /constituents/history | Daily closes for every constituent on one shared date axis. As CSV: one row per day, one column per symbol. | JSON, CSV |
Base URL https://happyai.today/api/v1. All endpoints are read-only GET requests over HTTPS.
Index summary
The HAI Composite's latest level, base and constituent count.
- base, baseDate
- The index was set to base on baseDate. Levels are comparable across the whole history.
- asOf
- Date of the latest level (New York trading day).
- level
- Latest index level.
- changePct
- Percent change from the previous level.
{
"index": "HAI Composite",
"description": "Equal-weighted index of the AI stocks tracked by HAI Terminal. Each day's return is the mean of the constituents' daily returns.",
"weighting": "equal",
"currency": "USD",
"base": 1000,
"baseDate": "2025-10-23",
"constituents": 53,
"asOf": "2026-11-25",
"level": 1284.37,
"changePct": 0.4132
}Index history
Daily HAI Composite levels.
- from, to, count
- First date, last date and number of rows returned.
- data[].date
- Trading day, YYYY-MM-DD.
- data[].level
- Index level at the close.
{
"index": "HAI Composite",
"range": "1m",
"base": 1000,
"baseDate": "2025-10-23",
"from": "2026-10-26",
"to": "2026-11-25",
"count": 22,
"data": [
{
"date": "2026-10-26",
"level": 1251.08
},
{
"date": "2026-10-27",
"level": 1263.9
}
]
}date,level
2026-10-26,1251.08
2026-10-27,1263.9Constituents
Every stock in the index, with its segment, weight and the dates its history covers.
- data[].symbol
- Ticker. Use it in the constituent history endpoint.
- data[].segment
- One of semis, platforms, software, infra, robotics.
- data[].weight
- Index weight. Equal weighting: 1 ÷ the number of constituents.
- data[].firstDate, lastDate
- The span of daily history available for the symbol.
{
"index": "HAI Composite",
"weighting": "equal",
"count": 53,
"data": [
{
"symbol": "NVDA",
"name": "NVIDIA",
"segment": "semis",
"segmentLabel": "Semiconductors",
"weight": 0.0189,
"thesis": "Dominant supplier of AI training and inference accelerators.",
"firstDate": "2025-10-23",
"lastDate": "2026-11-25"
}
]
}Constituent history
Daily open, high, low, close and volume for one constituent.
{symbol} is a constituent ticker such as NVDA, in any letter case. The constituents endpoint lists the valid ones.
- adjusted
- Prices are adjusted for splits and dividends.
- data[].open … close
- Daily prices in USD.
- data[].volume
- Shares traded.
{
"symbol": "NVDA",
"name": "NVIDIA",
"range": "1m",
"adjusted": true,
"currency": "USD",
"from": "2026-10-26",
"to": "2026-11-25",
"count": 22,
"data": [
{
"date": "2026-10-26",
"open": 213.105,
"high": 217.75,
"low": 212.61,
"close": 216,
"volume": 90829289
}
]
}date,open,high,low,close,volume
2026-10-26,213.105,217.75,212.61,216,90829289All constituents, one call
Daily closes for every constituent on one shared date axis. As CSV: one row per day, one column per symbol.
- symbols
- Constituents, in column order.
- dates
- Trading days, oldest first.
- closes[symbol]
- One close per entry in dates. null (an empty CSV cell) when the symbol has no bar that day.
{
"index": "HAI Composite",
"range": "1m",
"field": "close",
"adjusted": true,
"from": "2026-10-26",
"to": "2026-11-25",
"count": 22,
"symbols": [
"NVDA",
"AMD",
"AVGO"
],
"dates": [
"2026-10-26",
"2026-10-27"
],
"closes": {
"NVDA": [
216,
217.94
],
"AMD": [
531.28,
540.1
],
"AVGO": [
329.17,
null
]
}
}date,NVDA,AMD,AVGO
2026-10-26,216,531.28,329.17
2026-10-27,217.94,540.1,Parameters
History endpoints take two optional query parameters.
| Parameter | Values | Meaning |
|---|---|---|
range | 1m | Last 30 days |
3m | Last 91 days | |
6m | Last 182 days | |
ytd | Since 1 January | |
1y | Last 365 days (default) | |
max | Everything on record | |
format | json | JSON object with metadata and a data array (default) |
csv | Header row, then one row per trading day |
Ranges count back in calendar days from the most recent trading day on record. Need a custom window? Request a wider range and filter on date; rows are always sorted oldest first.
Errors
Errors use ordinary HTTP status codes and a JSON body with a stable code to branch on and a message for people.
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_range | range is not one of the supported values. |
| 400 | invalid_format | format is not json or csv, or csv was asked of a JSON-only endpoint. |
| 403 | invalid_api_key | The key is not recognised or has been revoked. |
| 403 | expired_api_key | The key has passed its expiry date. |
| 404 | unknown_symbol | The symbol is not an index constituent. |
| 404 | not_found | No such endpoint or API version. |
| 405 | method_not_allowed | The API is read-only. Use GET. |
| 429 | rate_limited | Too many requests without an API key. Wait five minutes, or use a key. |
{
"error": {
"code": "invalid_range",
"message": "range must be one of 1m, 3m, 6m, ytd, 1y, max.",
"docs": "https://happyai.today/developers/"
}
}Data notes
- How the index is built
- Each day's index return is the simple mean of the constituents' daily returns: an equal-weighted basket, rebalanced daily. The level started at 1000 on the base date. ETFs shown on the site are not in the index.
- Constituents change
- Stocks are added and dropped as the AI landscape moves. A new name joins from its second trading day on record, so it never causes a jump in the level. Past levels are not restated for changes in membership.
- Freshness
- Data is rebuilt every 15 minutes during US market hours and hourly otherwise. During the session the latest row is the day in progress, built from delayed quotes; it settles after the close.
- Adjusted prices
- Constituent prices are adjusted for splits and dividends, so earlier rows can be revised after a corporate action. Index levels inside roughly the last year can shift slightly for the same reason; older levels are fixed.
- Caching
- Responses can be cached for 60 seconds. Daily history does not need polling faster than that; once a minute at most is plenty.
- Terms
- The data is provided as is, for information only, with no guarantee of accuracy or availability. Nothing here is investment advice.
Code examples
curl -o nvda.csv \
"https://happyai.today/api/v1/constituents/NVDA/history?range=max&format=csv"import io, os
import pandas as pd
import requests
BASE = "https://happyai.today/api/v1"
# Works without a key (10 requests per 5 minutes). A key lifts the limit.
KEY = os.environ.get("HAI_API_KEY")
HEADERS = {"X-API-Key": KEY} if KEY else {}
def frame(path, **params):
r = requests.get(f"{BASE}{path}", headers=HEADERS,
params={**params, "format": "csv"}, timeout=30)
r.raise_for_status()
return pd.read_csv(io.StringIO(r.text), parse_dates=["date"], index_col="date")
index = frame("/index/history", range="max") # date -> level
closes = frame("/constituents/history", range="1y") # date x symbol
returns = closes.pct_change().mean(axis=1) # the index's daily returnconst BASE = "https://happyai.today/api/v1";
async function hai(path, params = {}) {
const url = new URL(BASE + path);
for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
// No key is needed for light use; set HAI_API_KEY to lift the rate limit.
const key = process.env.HAI_API_KEY;
const res = await fetch(url, { headers: key ? { "X-API-Key": key } : {} });
const body = await res.json();
if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message}`);
return body;
}
const { data } = await hai("/constituents/NVDA/history", { range: "3m" });
console.log(data.at(-1)); // { date, open, high, low, close, volume }In Google Sheets, =IMPORTDATA("https://happyai.today/api/v1/index/history?range=1y&format=csv") pulls the index straight into a sheet. A machine-readable description of the API is at /openapi.json.