export type GetApiApiMacroInflationArgs = {api_key: string, country?: string | undefined, format?: ('json' | 'xml' | 'csv' | 'tsv') | undefined, callback?: string | undefined}; export type GetApiApiMacroInflationOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Latest consumer price inflation (CPI, year-on-year % change) by country (free tier — counts against the normal daily request quota). Covers ~65 economies from the BIS consumer prices dataset, monthly. Without `country` returns every live series; with `country` accepts ISO country codes (US, DE, JP) or currency codes (USD, JPY), comma-separated. EUR returns euro-area inflation; a euro-area member with its own series (e.g. DE) returns its national CPI. `period` is the month the figure refers to (national statistics are published with a 1-3 month lag; a few quarterly series such as AU and NZ are repeated monthly by the BIS). 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 */ export const getApiApiMacroInflation = async (args: GetApiApiMacroInflationArgs, options: GetApiApiMacroInflationOptions) => { 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/inflation${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 };