export type GetApiContractsPlatformIdContractAddressHistoricalArgs = {platform_id: string, contract_address: string, start: string, end?: string | undefined, limit?: number | undefined, quote?: string | undefined, interval?: string | undefined}; export type GetApiContractsPlatformIdContractAddressHistoricalOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Redirect to historical ticks by contract address * * GET /contracts/{platform_id}/{contract_address}/historical */ export const getApiContractsPlatformIdContractAddressHistorical = async (args: GetApiContractsPlatformIdContractAddressHistoricalArgs, options?: GetApiContractsPlatformIdContractAddressHistoricalOptions) => { const {baseUrl = "https://api.coinpaprika.com/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.start != null) query.append("start", String(args.start)) if (args.end != null) query.append("end", String(args.end)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.quote != null) query.append("quote", String(args.quote)) if (args.interval != null) query.append("interval", String(args.interval)) const url = `${baseUrl.replace(/\/+$/, '')}/contracts/${encodeURIComponent(String(args.platform_id))}/${encodeURIComponent(String(args.contract_address))}/historical${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 undefined };