export type GetApiApiV2ListingsCollectionSlugBestArgs = {slug: string, include_private_listings?: boolean | undefined, traits?: string | undefined, limit?: number | undefined, next?: string | undefined}; export type GetApiApiV2ListingsCollectionSlugBestOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get best listings by collection * * GET /api/v2/listings/collection/{slug}/best */ export const getApiApiV2ListingsCollectionSlugBest = async (args: GetApiApiV2ListingsCollectionSlugBestArgs, options?: GetApiApiV2ListingsCollectionSlugBestOptions) => { const {baseUrl = "https://api.opensea.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.include_private_listings != null) query.append("include_private_listings", String(args.include_private_listings)) if (args.traits != null) query.append("traits", String(args.traits)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.next != null) query.append("next", String(args.next)) if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/listings/collection/${encodeURIComponent(String(args.slug))}/best${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() };