export type GetApiApiCommoditiesSymbolsArgs = {api_key: string, format?: ('json' | 'xml' | 'csv' | 'tsv') | undefined, callback?: string | undefined}; export type GetApiApiCommoditiesSymbolsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * List all available commodity symbols with name and unit (Pro subscription required). 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/symbols */ export const getApiApiCommoditiesSymbols = async (args: GetApiApiCommoditiesSymbolsArgs, options: GetApiApiCommoditiesSymbolsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "commodities") 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/commodities/symbols${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() };