Marketplace has launched, further enabling blockchain developers! Learn more

Contents

qn_fetchNFTs RPC method

The API credit value for this method is 4 . To learn more about API credits and each method's value, visit the API Credits page.

Currently supports ERC-721 and ERC-1155 compliant contracts (on Ethereum mainnet).

Headers:

  1. x-qn-api-version — (Integer - optional) Provide an optional request header specifying the QuickNode API version you're targeting. Using this header is recommended as it will become mandatory (required) in the future. Current API version is 1.

Parameters:

  1. Object — Custom Object with the following fields:

    wallet — (String) The wallet address to check for NFTs.

    contracts — (Array of Strings - optional) List of NFT contract addresses you'd like to get ownership data from. Contract addresses may be optionally suffixed with :tokenId to specify a specific NFT id to filter on. For example, 0x2106c...7aeaa:1234 will filter Loopy Donuts on the NFT token with id 1234 only. You may include up to 20 contract addresses per request.

    omitFields — (Array of Strings - optional) Optionally omit specific properties of objects from the "assets" array of the response. Any property of the asset object can be omitted. If omitFields is not included in the request, response will return all available fields by default.

    page — (Integer - optional) The page number you would like returned. Page numbers start at 1 and end at "totalPages". If omitted, defaults to the first page (page 1). If the page number requested is less than 1 or higher than "totalPages", an empty assets array will be returned.

    perPage — (Integer - optional) The maximum amount of NFT assets to return on each page. You can request up to 40 items per page. If omitted, defaults to 20 items per page.

Returns:

  1. Object — Custom Response Object, or null if no NFTs are found:

    owner — The wallet address we checked for NFTs.

    assets — An array of objects representing NFTs with the following shape:

    name — The name of this specific NFT.

    collectionTokenId — The token id of this NFT in its collection.

    collectionName — The name of this NFT's collection.

    imageUrl — The URL where the image for this NFT can be seen.

    collectionAddress — The contract address that this NFT lives in.

    traits — An array of traits that this NFT has.

    chain — What chain this aggregation happened on.

    network — What network this aggregation happened on.

    provenance — An array with the transfer history for this NFT.

    blockNumber — The block number this transaction was included in.

    date — The date when this transaction was mined.

    from — The address for the sender of this transaction.

    to — The address for the receiver of this transaction.

    to — The token transfer transaction hash.

    totalItems — The total number of results.

    totalPages — The total number of results pages available.

    pageNumber — The page number of results that was returned with this response.

Code Examples:

const ethers = require("ethers");
(async () => {
  const provider = new ethers.providers.JsonRpcProvider("http://sample-endpoint-name.network.quiknode.pro/token-goes-here/");
  provider.connection.headers = { "x-qn-api-version": 1 };
  const heads = await provider.send("qn_fetchNFTs", {
    wallet: "0x91b51c173a4bdaa1a60e234fc3f705a16d228740",
    omitFields: ["provenance", "traits"],
    page: 1,
    perPage: 10,
    contracts: [
      "0x2106c00ac7da0a3430ae667879139e832307aeaa",
      "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
    ],
  });
  console.log(heads);
})();
Ready to get started? Create a free account