Stocks endpoints

Every route in stocks/index.ts. Base path /functions/v1/stocks/. All routes need an Origin on the allow-list first.

Public reads (publishable key via verifyPublicAuth)

EndpointMethodParamsResponseHandler
detailsGET / POSTticker (query or JSON body)StockDetailsResponse: company, price, metrics, earnings, watcher_count, quarters[]. 404 unknown ticker.stockDetails.ts
leaderboardGET / POSTpage, pageSize, sortBy, sortDir (browse only), search{stocks: LeaderboardStock[], pagination}; each stock has price_history (1d bars) and sparkline (closes).stockLeaderboard.ts
price-historyGETticker + either timeframe (1d 5d 1m 3m 6m 1y 2y ytd) or from[/to]{ticker, timeframe, interval_type, bars[], count}. Timestamps in Eastern Time with offset. 400 when both modes are given.priceHistory.ts
logosGET / POSTpage (≥1), pageSize (1-100){logos: [{ticker, icon, logo}], pagination}; urls into the company-logos bucket.stockLogos.ts
newsGETticker, limit (1-50, default 10)StockNewsResponse from Stock_News_* with per-ticker sentiment.stockNews.ts

User JWT (getUserId)

EndpointMethodParamsResponseHandler
watchlistGETwatchlist_id{watchlist_id, stocks: WatchlistStock[]}, each with a 1d sparkline. Empty list for a list the caller does not own.watchlist.ts
benchmarkGETperiod 1D 1W 1M 6M 1Y, symbol (default SPY)Close series in the same point shape as get_my_portfolio_summary.benchmark.ts

Service only (secret key via verifyServiceRoleAuth, called by cron)

EndpointBodyWritesCron
refresh{tiers?: string[]}Stock_Current_Quotesmega 5s, large+mid 30s, small 60s (trading hours)
ingest-minute-barsnoneStock_Price_Minuteevery 30s in session
refresh-historical{interval_type, tiers, check_existing}Stock_Price_History (intraday/hourly)via SQL wrappers, 5-10 min
backfill-daily{from_date, to_date} ≤31 daysStock_Price_Daily01:00 UTC Tue-Sat
refresh-market-capnoneshares_outstanding on quotes07:00 UTC
refresh-company-profilesnoneCompanies, logos bucketevery 6h / weekly
refresh-earningsnoneEarnings_Metrics00,06,12,18 UTC
refresh-newsnoneStock_News_*every 6h
retry-blocked · hydrate · prune-stalenoneCompanies.blocked, quotes, historydaily / every 5 min / daily
repair-splits{days_back?, max_tickers?}daily bars after a split15:00 & 21:00 UTC; weekly backlog
poll-edgar-filings · refresh-cik-map · refresh-filings · backfill-filingssee lesson 9Stock_SEC_Filings, SEC_CIK_Tickers1 min / daily / nightly
backfill-insider-transactions · refresh-insider-transactions · backfill-financials · refresh-financials · refresh-wsb-sentimentsee lesson 9insider, financials, sentiment tablesvarious

Unknown endpoint: 404 {error: "Unknown endpoint: x"}. Any thrown error: 500. Both carry the CORS headers computed before routing. stocks/index.ts:190-215