Contents

qn_fetchNFTsByCollection RPC method

Currently supports ERC-721 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:

    collection — (String) The contract address of the NFT Collection.

    omitFields — (String - optional) Optionally omit specific properties of objects from the "tokens" array of the response. Any property of the tokens 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 higher than "totalPages", an empty assets array will be returned. If the page number requested is less than 1, an invalid params response will be returned.

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

Returns:

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

    collection — The contract address we checked for NFTs.

    tokens — 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 — The chain this aggregation happened on.

    network — The 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.

    txHash — The token transfer transaction hash.

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_fetchNFTsByCollection", {
    collection: "0x60E4d786628Fea6478F785A6d7e704777c86a7c6",
    omitFields: ["provenance", "traits"],
    page: 1,
    perPage: 10,
  });
  console.log(heads);
})();
Ready to try QuickNode? Start your 7-day free trial