export type GetApiApiV2CollectionsSlugOfferAggregatesArgs = {slug: string, limit?: number | undefined, cursor?: string | undefined, sort_direction?: string | undefined}; export type GetApiApiV2CollectionsSlugOfferAggregatesOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get collection offer aggregates * * GET /api/v2/collections/{slug}/offer_aggregates */ export const getApiApiV2CollectionsSlugOfferAggregates = async (args: GetApiApiV2CollectionsSlugOfferAggregatesArgs, options?: GetApiApiV2CollectionsSlugOfferAggregatesOptions) => { const {baseUrl = "https://api.opensea.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.limit != null) query.append("limit", String(args.limit)) if (args.cursor != null) query.append("cursor", String(args.cursor)) if (args.sort_direction != null) query.append("sort_direction", String(args.sort_direction)) if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/collections/${encodeURIComponent(String(args.slug))}/offer_aggregates${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() };