export type GetApiApiCommoditiesHistoricalTimeseriesArgs = {api_key: string, start_date: string, end_date: string, amount?: number | undefined, symbols?: string | undefined, format?: ('json' | 'xml' | 'csv' | 'tsv') | undefined, callback?: string | undefined}; export type GetApiApiCommoditiesHistoricalTimeseriesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get commodity time series data for a date range with optional amount conversion (max 5 years, Pro subscription required). Precious metals history back to 1968 (gold/silver) and 1990 (platinum/palladium); energy, base-metal and agricultural history accrues daily from 2026-08. 19 commodities: gold, silver, platinum, palladium (troy oz); WTI and Brent crude (barrel), US Henry Hub natural gas (MMBtu); copper, aluminium, zinc, nickel, lead, tin (tonne); wheat, corn (tonne), coffee, sugar, cocoa, cotton (kg). Precious metals are blended live from LBMA and market feeds; energy, base metals and agriculturals are World Bank reference prices (CC BY 4.0, attribution: The World Bank). * * GET /api/commodities/historical/timeseries */ export const getApiApiCommoditiesHistoricalTimeseries = async (args: GetApiApiCommoditiesHistoricalTimeseriesArgs, options: GetApiApiCommoditiesHistoricalTimeseriesOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "prices_only") if (args.api_key != null) query.append("api_key", String(args.api_key)) if (args.start_date != null) query.append("start_date", String(args.start_date)) if (args.end_date != null) query.append("end_date", String(args.end_date)) if (args.amount != null) query.append("amount", String(args.amount)) if (args.symbols != null) query.append("symbols", String(args.symbols)) 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/commodities/historical/timeseries${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() };