@@ -39,6 +39,7 @@ import {
3939 getNFTPath ,
4040 getRefreshMetadataPath ,
4141 getCollectionOffersPath ,
42+ getListNFTsByAccountPath ,
4243} from "../orders/utils" ;
4344import {
4445 Chain ,
@@ -416,6 +417,40 @@ export class OpenSeaAPI {
416417 return response ;
417418 }
418419
420+ /**
421+ * Fetch NFTs owned by an account.
422+ * @param address The address of the account
423+ * @param limit The number of NFTs to retrieve. Must be greater than 0 and less than 51.
424+ * @param next Cursor to retrieve the next page of NFTs
425+ * @param retries Number of times to retry if the service is unavailable for any reason.
426+ * @param chain The chain to query. Defaults to the chain set in the constructor.
427+ * @returns The {@link ListNFTsResponse} returned by the API.
428+ */
429+ public async getNFTsByAccount (
430+ address : string ,
431+ limit : number | undefined = undefined ,
432+ next : string | undefined = undefined ,
433+ retries = 1 ,
434+ chain = this . chain ,
435+ ) : Promise < ListNFTsResponse > {
436+ let response ;
437+ try {
438+ response = await this . get < ListNFTsResponse > (
439+ getListNFTsByAccountPath ( chain , address ) ,
440+ {
441+ limit,
442+ next,
443+ } ,
444+ ) ;
445+ } catch ( error ) {
446+ _throwOrContinue ( error , retries ) ;
447+ await delay ( 1000 ) ;
448+ return this . getNFTsByAccount ( address , limit , next , retries - 1 , chain ) ;
449+ }
450+
451+ return response ;
452+ }
453+
419454 /**
420455 * Fetch metadata, traits, ownership information, and rarity for a single NFT.
421456 * @param chain The NFT's chain.
0 commit comments