export type GetApiApiMacroInflationHistoryArgs = {api_key: string, country: string, start_date?: string | undefined, end_date?: string | undefined, format?: ('json' | 'xml' | 'csv' | 'tsv') | undefined, callback?: string | undefined}; export type GetApiApiMacroInflationHistoryOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Monthly CPI inflation history (year-on-year % change) for ONE country (free tier — counts against the normal daily request quota). Many series go back to the 1950s or earlier (US from 1914). `country` accepts an ISO country code or a currency code. Dates accept YYYY-MM or YYYY-MM-DD (the month is used). Source: Bank for International Settlements (BIS), https://data.bis.org — UniRate is not affiliated with or endorsed by the BIS. Provided for information only; not investment advice. * * GET /api/macro/inflation/history */ export const getApiApiMacroInflationHistory = async (args: GetApiApiMacroInflationHistoryArgs, options: GetApiApiMacroInflationHistoryOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.api_key != null) query.append("api_key", String(args.api_key)) if (args.country != null) query.append("country", String(args.country)) 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.format != null) query.append("format", String(args.format)) if (args.callback != null) query.append("callback", String(args.callback)) const url = `${baseUrl.replace(/\/+$/, '')}/api/macro/inflation/history${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 (await res.json()) as unknown };