Skip to main content

Introduction

In this tutorial, you’ll learn how to retrieve a summary of all NFT collections owned by a wallet address using the Moralis API. Instead of listing every individual NFT, this endpoint groups NFTs by collection and provides counts, making it perfect for portfolio overviews and collection summaries. We’ll use the following Moralis API endpoint:

Prerequisites

Step 1: Set Up Your Project

Create a new directory for your project and initialize it:
mkdir get-nft-collections && cd get-nft-collections
npm init -y

Step 2: Create the Script

Create a file called index.js and add the following code:
// index.js
const API_KEY = 'YOUR_API_KEY';
const WALLET_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; // Vitalik's wallet

async function getNFTCollections() {
  const response = await fetch(
    `https://deep-index.moralis.io/api/v2.2/${WALLET_ADDRESS}/nft/collections?chain=eth`,
    {
      headers: {
        'X-API-Key': API_KEY,
      },
    }
  );

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

getNFTCollections();
Replace YOUR_API_KEY with your actual Moralis API key.

Step 3: Run the Script

Execute the script to fetch the collections:
node index.js

Example Response

{
  "status": "SYNCED",
  "page": 1,
  "page_size": 100,
  "cursor": null,
  "result": [
    {
      "token_address": "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
      "contract_type": "ERC721",
      "name": "Bored Ape Yacht Club",
      "symbol": "BAYC",
      "count": 3,
      "collection_logo": "https://...",
      "collection_banner_image": "https://...",
      "possible_spam": false,
      "verified_collection": true,
      "floor_price": 25.5,
      "floor_price_usd": 89250.75
    },
    {
      "token_address": "0x60e4d786628fea6478f785a6d7e704777c86a7c6",
      "contract_type": "ERC721",
      "name": "Mutant Ape Yacht Club",
      "symbol": "MAYC",
      "count": 2,
      "collection_logo": "https://...",
      "possible_spam": false,
      "verified_collection": true,
      "floor_price": 4.2,
      "floor_price_usd": 14700.00
    }
  ]
}

Understanding the Response

FieldDescription
token_addressCollection contract address
contract_typeToken standard (ERC721 or ERC1155)
nameCollection name
symbolCollection symbol
countNumber of NFTs owned from this collection
collection_logoURL to collection logo
possible_spamWhether flagged as spam
verified_collectionWhether collection is verified
floor_priceCurrent floor price in ETH
floor_price_usdFloor price in USD

Next Steps