export type GetApiApiCalendarExchangesArgs = {api_key: string, format?: ('json' | 'xml') | undefined, callback?: string | undefined}; export type GetApiApiCalendarExchangesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * List the stock/futures exchanges (ISO 10383 MIC codes) supported by the exchange trading calendar endpoints. `data_available_through` is the last date holiday data exists for that exchange (null = rule-based, no fixed end); a few exchanges with lunar-calendar holidays (e.g. XSHG, XBOM, XSES) end at a fixed date until the next yearly data release; dates past it are still answered by /api/calendar/exchange*, best-effort (weekdays as trading days, public holidays unknown) and flagged `holiday_data_available: false`. Pro subscription required. * * GET /api/calendar/exchanges */ export const getApiApiCalendarExchanges = async (args: GetApiApiCalendarExchangesArgs, options: GetApiApiCalendarExchangesOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "exchanges") if (args.api_key != null) query.append("api_key", String(args.api_key)) if (args.format != null) query.append("format", String(args.format)) if (args.callback != null) query.append("callback", String(args.callback)) const url = `${baseUrl.replace(/\/+$/, '')}/api/calendar/exchanges${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };