export type GetApiV1FlowStocksSymbolBarsArgs = {symbol: string, resolution?: string | undefined, minutes?: number | undefined}; export type GetApiV1FlowStocksSymbolBarsOptions = {baseUrl: string, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /v1/flow/stocks/{symbol}/bars */ export const getApiV1FlowStocksSymbolBars = async (args: GetApiV1FlowStocksSymbolBarsArgs, options: GetApiV1FlowStocksSymbolBarsOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.resolution != null) query.append("resolution", String(args.resolution)) if (args.minutes != null) query.append("minutes", String(args.minutes)) if (ApiKey !== undefined) headers.set("X-Api-Key", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/flow/stocks/${encodeURIComponent(String(args.symbol))}/bars${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 undefined };