Register and show off your project at Ethereum QuickPitch and win $10,000. Apply now

Contents

qn_fetchNFTsByCollection 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 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.

    tokens — (Array of Strings - optional) Optionally limit the results to specific tokens within a collection. You may submit up to 20 token IDs in this parameter. If you do not want to limit results to specific tokens, please omit this parameter from your request.

    omitFields — (Array of Strings - 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.

    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_fetchNFTsByCollection", {
    collection: "0x60E4d786628Fea6478F785A6d7e704777c86a7c6",
    omitFields: ["imageUrl", "traits"],
    page: 1,
    perPage: 10,
  });
  console.log(heads);
})();
Ready to get started? Create a free account