With the Moralis NFT API, you can GET all NFTs in a wallet using just one API call. Use the following code in your index file to do so:
GET
index
1const Moralis = require("moralis").default;2const { EvmChain } = require("@moralisweb3/common-evm-utils");3const { config } = require("dotenv");4 5// Inject environment variables6config();7 8const runApp = async () => {9 await Moralis.start({10 apiKey: process.env.MORALIS_API_KEY,11 // ...and any other configuration12 });13 14 const address = "0xCf8B5C33584F00EC12Ca257Ae5B74D080f9A432b";15 16 const chain = EvmChain.PALM;17 18 const response = await Moralis.EvmApi.nft.getWalletNFTs({19 address,20 chain,21 });22 23 console.log(response.toJSON());24};25 26runApp();
1import Moralis from "moralis";2import {3 EvmChain,4 GetWalletNFTsResponseAdapter,5} from "@moralisweb3/common-evm-utils";6import { config } from "dotenv";7 8// Inject environment variables9config();10 11const runApp = async () => {12 await Moralis.start({13 apiKey: process.env.MORALIS_API_KEY,14 // ...and any other configuration15 });16 17 const address: string = "0xCf8B5C33584F00EC12Ca257Ae5B74D080f9A432b";18 19 const chain: EvmChain = EvmChain.PALM;20 21 const response: GetWalletNFTsResponseAdapter =22 await Moralis.EvmApi.nft.getWalletNFTs({23 address,24 chain,25 });26 27 console.log(response.toJSON());28};29 30runApp();
1{2 total: 1,3 page: 1,4 page_size: 100,5 cursor: null,6 result: [7 {8 token_address: '0xcaffa4b5f72a44c75f796e94f22debd6369f04fc',9 token_id: '337459032062404130888958965050657186814',10 owner_of: '0xcf8b5c33584f00ec12ca257ae5b74d080f9a432b',11 block_number: '7336008',12 block_number_minted: '2757718',13 token_hash: '391b72d5191fbe8a67938c9d8d76436a',14 amount: '1',15 contract_type: 'ERC721',16 name: 'CandyDigitalNFT',17 symbol: 'CNDY',18 token_uri: 'https://tokens.candy.com/337459032062404130888958965050657186814',19 metadata: '{"name":"Earth Anew","description":"Bank of America commissioned brand agency Superunion and 3D artist João Seabra to create its first-ever, limited-edition NFT. Built on PALM, a sustainable and energy-efficient ecosystem, this unique digital rendering of a rainforest reflects our commitment to helping preserve the planet we share.","external_url":"https://www.candy.com/mlb/collectibles/fde03ed8-1fc3-414a-afe5-bd51f08fa3fe","image":"https://assets.candy.com/VIDEO/34599b72-58e7-4700-ac25-d34bacdd3f9d/BofA_NFT_2021_NoLogo.mp4","animation_url":"https://assets.candy.com/VIDEO/34599b72-58e7-4700-ac25-d34bacdd3f9d/BofA_NFT_2021_NoLogo.mp4","attributes":[{"display_type":"number","trait_type":"Serial Number","value":7}]}',20 last_token_uri_sync: '2022-11-12T21:31:07.385Z',21 last_metadata_sync: '2022-11-12T21:31:12.653Z',22 minter_address: '0xf00dc91588ac40b5c886aec93b24ec92d7f737dd'23 }24 ],25 status: 'SYNCED'26}