Docs
API
NFTs
Get users NFTs

Get Users NFTs

This API allows you to find all NFTs that a user own. You can also query NFTs by contract address. Lens uses Moralis API to get the NFT data

Parameters

NameTypeExample
ownerAddressString0x....
limitInteger20
chainIdsArray[1]

API operation

Lens.GetUsersNFTs(params)
  .then((res) => {
    console.log(res);
  })
  .catch((err) => {
    console.log(err);
  });

API response

{
  "nfts": {
    "items": [
      {
        "contractName": "Origin Stories 1",
        "contractAddress": "0x54439D4908A3E19356F876aa6022D67d0b3B12d6",
        "symbol": "ORIGIN1",
        "tokenId": "5742",
        "owners": [
          {
            "amount": 1,
            "address": "0x54BE3a794282C030b15E43aE2bB182E14c409C5e"
          }
        ],
        "name": "Origin Stories 1: Mad Clown, Sad Town",
        "description": "Before she was a tough-as-nails lead member of the PUNKS crew, Courtney had humble beginnings. Okay, she was always tough as nails, but to follow her dreams she had to carve her own path. Coming from a small town, Courtney had to go it alone, overcome major fears and doubts, and finally take a major leap of faith to make it in… ORIGIN CITY.",
        "contentURI": "https://ipfs.moralis.io:2053/ipfs/QmRpVH1xubDpNJ5RUqjnhE9DLU99R44NtZqs1s59pH7qBB",
        "originalContent": {
          "uri": "ipfs://QmP7vzEULM45qZkYnTdejrDhprEM9xmCNHztaNgffEZvcm",
          "metaType": "unknown"
        },
        "chainId": 1,
        "collectionName": "Origin Stories 1",
        "ercType": "ERC721"
      },
      {
        "contractName": "Origin Stories 1",
        "contractAddress": "0x54439D4908A3E19356F876aa6022D67d0b3B12d6",
        "symbol": "ORIGIN1",
        "tokenId": "5741",
        "owners": [
          {
            "amount": 1,
            "address": "0x54BE3a794282C030b15E43aE2bB182E14c409C5e"
          }
        ],
        "name": "Origin Stories 1: Mad Clown, Sad Town",
        "description": "Before she was a tough-as-nails lead member of the PUNKS crew, Courtney had humble beginnings. Okay, she was always tough as nails, but to follow her dreams she had to carve her own path. Coming from a small town, Courtney had to go it alone, overcome major fears and doubts, and finally take a major leap of faith to make it in… ORIGIN CITY.",
        "contentURI": "https://ipfs.moralis.io:2053/ipfs/QmRpVH1xubDpNJ5RUqjnhE9DLU99R44NtZqs1s59pH7qBB",
        "originalContent": {
          "uri": "ipfs://QmP7vzEULM45qZkYnTdejrDhprEM9xmCNHztaNgffEZvcm",
          "metaType": "unknown"
        },
        "chainId": 1,
        "collectionName": "Origin Stories 1",
        "ercType": "ERC721"
      }
    ],
    "pageInfo": {
      "prev": "{\"offset\":0}",
      "next": "{\"offset\":10}",
      "totalCount": 4023
    }
  }
}

Full Code Example

import { Lens } from 'lens-protocol';
import { useEffect } from 'react';

export default function Example({ ownerAddress, contractAddress, chainIds, limit }) {
  useEffect(() => {
    Lens.GetUsersNFTs({
      ownerAddress,
      contractAddress,
      chainIds,
      limit,
    })
      .then((res) => {
        console.log(res);
      })
      .catch((err) => {
        console.log(err);
      });
  }, []);
}
Last updated on July 31, 2022