We're now supporting Polygon zkEVM!
Learn more here.

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.

Please note that this RPC method requires the NFT Fetch Tool add-on enabled on your QuickNode endpoint. Also, it currently supports ERC-721 compliant contracts (on Ethereum mainnet).

Parameters:

  1. object - The custom object with the following fields:

    collection - string - The contract address of the NFT Collection

    tokens - string - An array of strings that 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

    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 - The 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:

    collectionName - The name of this NFT's collection

    collectionAddress - The contract address that this NFT lives in

    chain - The chain this aggregation happened on

    network - The network this aggregation happened on

    collectionTokenId - The token id of this NFT in its collection

    name - The name of this specific NFT

    description - The description of this specific NFT

    traits - The traits refer to the different attributes of NFTs

    value - The specific value associated with each trait of the NFT which can be present in the form of text, numbers, or even images, depending on the type of NFT

    trait_type - The type of trait associated with each NFT. It includes attributes like the color, rarity, or any other defining characteristic that sets the NFT apart from others in its collection

    totalPages - The total number of results pages available

    pageNumber - The page number of results that were returned with this response

    totalItems - The total number of results

Code Examples:

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-qn-api-version", "1");

var raw = JSON.stringify({
  "id": 67,
  "jsonrpc": "2.0",
  "method": "qn_fetchNFTsByCollection",
  "params": {
    "collection": "0x60E4d786628Fea6478F785A6d7e704777c86a7c6",
    "omitFields": [
      "imageUrl",
      "traits"
    ],
    "page": 1,
    "perPage": 10
  }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("http://sample-endpoint-name.network.quiknode.pro/token-goes-here/", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
Ready to get started? Create a free account