export type GetApiApiMacroPolicyRatesArgs = {api_key: string, country?: string | undefined, format?: ('json' | 'xml' | 'csv' | 'tsv') | undefined, callback?: string | undefined}; export type GetApiApiMacroPolicyRatesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Latest central bank policy interest rates (free tier — counts against the normal daily request quota). Covers the ~40 live central banks in the BIS central bank policy rates dataset (Fed, ECB, BoE, BoJ, PBoC, RBA, BoC, SNB, RBI, BCB and more). Without `country` returns every live series; with `country` accepts ISO country codes (US, GB, JP) or currency codes (USD, GBP, JPY), comma-separated. EUR (or EU/EZ/ECB) returns the ECB rate; a euro-area member (e.g. DE) with no live national series also resolves to the ECB. `rate` is in percent; `effective_date` is the first day the BIS series shows the current rate; `as_of` is the latest BIS observation date; `definition` is the BIS description of which rate is used (e.g. the US figure is the mid-point of the Fed Funds target range). 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 */ export const getApiApiMacroPolicyRates = async (args: GetApiApiMacroPolicyRatesArgs, options: GetApiApiMacroPolicyRatesOptions) => { 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.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${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 };