export type NftIdentifierInput = {chain: string, contract_address: string, token_id: string}; export type BatchNftsRequest = {identifiers: Array}; export type CreateApiApiV2NftsBatchArgs = {body: BatchNftsRequest}; export type CreateApiApiV2NftsBatchOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get NFTs by identifiers * * POST /api/v2/nfts/batch */ export const createApiApiV2NftsBatch = async (args: CreateApiApiV2NftsBatchArgs, options?: CreateApiApiV2NftsBatchOptions) => { const {baseUrl = "https://api.opensea.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/nfts/batch${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };