{"openapi":"3.1.0","info":{"title":"HAI Terminal Data API","version":"1.0.0","description":"Daily history for the HAI Composite AI stock index and its constituents, as JSON or CSV. Public: no key is needed for up to 10 requests per 5 minutes per IP address. An API key lifts that limit."},"externalDocs":{"description":"API documentation","url":"https://happyai.today/developers/"},"servers":[{"url":"https://happyai.today/api/v1"}],"security":[{},{"apiKey":[]},{"bearer":[]}],"paths":{"/index":{"get":{"operationId":"index","summary":"Index summary","description":"The HAI Composite's latest level, base and constituent count.","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"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}}}},"403":{"description":"Key not accepted. Codes: invalid_api_key, expired_api_key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit for requests without a key. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/index/history":{"get":{"operationId":"indexHistory","summary":"Index history","description":"Daily HAI Composite levels.","parameters":[{"name":"range","in":"query","description":"How far back to go.","schema":{"type":"string","enum":["1m","3m","6m","ytd","1y","max"],"default":"1y"}},{"name":"format","in":"query","description":"Response format.","schema":{"type":"string","enum":["json","csv"],"default":"json"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"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}]}},"text/csv":{"example":"date,level\n2026-10-26,1251.08\n2026-10-27,1263.9"}}},"400":{"description":"Bad parameter. Codes: invalid_range, invalid_format.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key not accepted. Codes: invalid_api_key, expired_api_key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit for requests without a key. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/constituents":{"get":{"operationId":"constituents","summary":"Constituents","description":"Every stock in the index, with its segment, weight and the dates its history covers.","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"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"}]}}}},"403":{"description":"Key not accepted. Codes: invalid_api_key, expired_api_key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit for requests without a key. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/constituents/{symbol}/history":{"get":{"operationId":"constituentHistory","summary":"Constituent history","description":"Daily open, high, low, close and volume for one constituent.","parameters":[{"name":"symbol","in":"path","required":true,"description":"Constituent ticker, e.g. NVDA. Case-insensitive.","schema":{"type":"string"}},{"name":"range","in":"query","description":"How far back to go.","schema":{"type":"string","enum":["1m","3m","6m","ytd","1y","max"],"default":"1y"}},{"name":"format","in":"query","description":"Response format.","schema":{"type":"string","enum":["json","csv"],"default":"json"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"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}]}},"text/csv":{"example":"date,open,high,low,close,volume\n2026-10-26,213.105,217.75,212.61,216,90829289"}}},"400":{"description":"Bad parameter. Codes: invalid_range, invalid_format.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key not accepted. Codes: invalid_api_key, expired_api_key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found. Codes: unknown_symbol, not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit for requests without a key. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/constituents/history":{"get":{"operationId":"constituentsHistory","summary":"All constituents, one call","description":"Daily closes for every constituent on one shared date axis. As CSV: one row per day, one column per symbol.","parameters":[{"name":"range","in":"query","description":"How far back to go.","schema":{"type":"string","enum":["1m","3m","6m","ytd","1y","max"],"default":"1y"}},{"name":"format","in":"query","description":"Response format.","schema":{"type":"string","enum":["json","csv"],"default":"json"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"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]}}},"text/csv":{"example":"date,NVDA,AMD,AVGO\n2026-10-26,216,531.28,329.17\n2026-10-27,217.94,540.1,"}}},"400":{"description":"Bad parameter. Codes: invalid_range, invalid_format.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key not accepted. Codes: invalid_api_key, expired_api_key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit for requests without a key. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"X-API-Key"},"bearer":{"type":"http","scheme":"bearer"}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["invalid_range","invalid_format","invalid_api_key","expired_api_key","unknown_symbol","not_found","method_not_allowed","rate_limited"]},"message":{"type":"string"},"docs":{"type":"string","format":"uri"}}}}}}}}