export type GetApiMarketsTimelineArgs = {symbol: string, frequency: 'daily' | 'hourly' | 'minutely' | 'weekly', subFrequency?: ('hours_1' | 'hours_2' | 'hours_3' | 'hours_4' | 'hours_5' | 'hours_6' | 'minutes_1' | 'minutes_10' | 'minutes_15' | 'minutes_20' | 'minutes_25' | 'minutes_30' | 'minutes_35' | 'minutes_40' | 'minutes_45' | 'minutes_5' | 'minutes_50' | 'minutes_55') | undefined, before?: number | undefined, after?: number | undefined}; export type GetApiMarketsTimelineOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get market timeline by ticker and duration * * GET /markets/timeline */ export const getApiMarketsTimeline = async (args: GetApiMarketsTimelineArgs, options?: GetApiMarketsTimelineOptions) => { const {baseUrl = "https://api.limitless.exchange", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.symbol != null) query.append("symbol", String(args.symbol)) if (args.frequency != null) query.append("frequency", String(args.frequency)) if (args.subFrequency != null) query.append("subFrequency", String(args.subFrequency)) if (args.before != null) query.append("before", String(args.before)) if (args.after != null) query.append("after", String(args.after)) const url = `${baseUrl.replace(/\/+$/, '')}/markets/timeline${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 };