Prerequisites

Ensure you have a wallet created. You can follow the Quickstart for server wallets to prepare one. You will need:

  • API Key: Ensure you have an API key with the scopes: wallets.read and wallets:nfts.read.
  • Wallet Address: The address of the wallet you want to check the NFTs from.

Retrieving Wallet NFTs

We will use the Get NFTs from Wallet API.

It requires the following parameters:

  • walletAddress: The address of the wallet.
  • chain: The blockchain network where the wallet is.
  • page: (Optional) Page number for pagination.
  • perPage: (Optional) Number of NFTs per page.
const walletAddress = 'your_wallet_address';
const chain = 'polygon-amoy';
const apiKey = 'your_api_key';

async function fetchNFTs() {
    const response = await fetch(
        `https://staging.crossmint.com/api/2022-06-09/wallets/${chain}:${walletAddress}/nfts?page=1&perPage=10`,
        {
            method: 'GET',
            headers: {
                'X-API-KEY': apiKey,
            },
        }
    );

    const data = await response.json();
    console.log(data);
}

fetchNFTs().catch(console.error);