export type GetApiApiV2AccountAddressPortfolioHistoryArgs = {address: string, timeframe?: ('HOUR' | 'DAY' | 'WEEK' | 'MONTH') | undefined}; export type GetApiApiV2AccountAddressPortfolioHistoryOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get portfolio net worth history for an account * * GET /api/v2/account/{address}/portfolio/history */ export const getApiApiV2AccountAddressPortfolioHistory = async (args: GetApiApiV2AccountAddressPortfolioHistoryArgs, options?: GetApiApiV2AccountAddressPortfolioHistoryOptions) => { const {baseUrl = "https://api.opensea.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.timeframe != null) query.append("timeframe", String(args.timeframe)) if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/account/${encodeURIComponent(String(args.address))}/portfolio/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 res.blob() };