export type ChainIdentifier = 'base' | 'ethereum' | 'zora' | 'arbitrum' | 'sei' | 'avalanche' | 'polygon' | 'optimism' | 'ape_chain' | 'flow' | 'soneium' | 'ronin' | 'bera_chain' | 'solana' | 'shape' | 'unichain' | 'gunzilla' | 'abstract' | 'animechain' | 'hyperevm' | 'somnia' | 'monad' | 'hyperliquid' | 'megaeth' | 'ink' | 'robinhood' | 'stablechain'; export type GetApiApiV2TokensTrendingArgs = {limit?: number | undefined, chains?: Array | undefined, sort_by?: ('market_cap' | 'fdv' | 'one_hour_volume' | 'one_day_volume' | 'one_hour_price_change' | 'one_day_price_change' | 'seven_day_price_change' | 'fourteen_day_price_change' | 'thirty_day_price_change' | 'two_hundred_day_price_change' | 'one_year_price_change' | 'price' | 'genesis_date' | 'score') | undefined, sort_direction?: ('asc' | 'desc') | undefined, cursor?: string | undefined}; export type GetApiApiV2TokensTrendingOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get trending tokens * * GET /api/v2/tokens/trending */ export const getApiApiV2TokensTrending = async (args: GetApiApiV2TokensTrendingArgs, options?: GetApiApiV2TokensTrendingOptions) => { 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)) for (const item of args.chains ?? []) query.append("chains", String(item)) if (args.sort_by != null) query.append("sort_by", String(args.sort_by)) if (args.sort_direction != null) query.append("sort_direction", String(args.sort_direction)) if (args.cursor != null) query.append("cursor", String(args.cursor)) if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/tokens/trending${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() };