export type GetApiApiMacroPolicyRatesHistoryArgs = {api_key: string, country: string, start_date?: string | undefined, end_date?: string | undefined, format?: ('json' | 'xml' | 'csv' | 'tsv') | undefined, callback?: string | undefined}; export type GetApiApiMacroPolicyRatesHistoryOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Policy rate history for ONE central bank (free tier — counts against the normal daily request quota). Returns every rate change between `start_date` and `end_date` plus `rate_at_start` — the rate already in force on `start_date` — so a range with no decisions in it is still answered. Histories go back decades (US from 1954, UK from 1946). `country` accepts an ISO country code or a currency code (EUR -> ECB). CSV/TSV output contains the change rows only. 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/policy-rates/history */ export const getApiApiMacroPolicyRatesHistory = async (args: GetApiApiMacroPolicyRatesHistoryArgs, options: GetApiApiMacroPolicyRatesHistoryOptions) => { 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/policy-rates/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 };