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 GetApiApiV2MetadataChainContractAddressTokenIdArgs = {chain: ChainIdentifier, contractAddress: string, tokenId: string}; export type GetApiApiV2MetadataChainContractAddressTokenIdOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get NFT metadata * * GET /api/v2/metadata/{chain}/{contractAddress}/{tokenId} */ export const getApiApiV2MetadataChainContractAddressTokenId = async (args: GetApiApiV2MetadataChainContractAddressTokenIdArgs, options?: GetApiApiV2MetadataChainContractAddressTokenIdOptions) => { const {baseUrl = "https://api.opensea.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/metadata/${encodeURIComponent(String(args.chain))}/${encodeURIComponent(String(args.contractAddress))}/${encodeURIComponent(String(args.tokenId))}${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() };