The best way to Get All NFTs from a Assortment in 3 Steps

Due to Moralis’ final NFT API, any dev can get all NFTs from a set. Set up the Moralis SDK and use the “getContractNFTs“ NFT API endpoint; it’s so simple as that! Basically, with the next code snippet, you possibly can cowl the core of fetching non-fungible tokens from a set:

const response = await Moralis.EvmApi.nft.getContractNFTs({
deal with,

In case you’re already conversant in Moralis and the way it allows you to bridge the event hole between Web2 and Web3, you most likely have a number of concepts for using the above strains of code. Nevertheless, if you’re new to Web3 growth, be certain to finish immediately’s tutorial. By doing so, you’ll learn to get all of the NFTs from a set simply. Simply create your free Moralis account and comply with our lead. 


The bear market is one of the best time to construct dapps (decentralized purposes). Contemplating that NFTs proceed to be probably the most standard blockchain use instances, now’s the appropriate time to learn to work with the final word NFT API.  

A hologram displaying a text that says how to get all NFTs from collection.

As identified earlier, the “getContractNFTs” API endpoint would be the point of interest of immediately’s article. The upcoming tutorial will revolve round correctly incorporating the above-presented snippet of code. Finally, we’ll educate you how you can use JavaScript (JS) or TypeScript (TS) to get all NFTs from a set with out breaking a sweat. Luckily, it is a three-step course of that shouldn’t take you greater than a few minutes. Particularly because you’ll be capable to merely copy and paste our strains of cod, and when you get NFTs from a set, you’ll get to make use of your terminal to discover the outcomes. 

As well as, we determined that can assist you take issues to the subsequent degree. As such, you’ll additionally be capable to comply with our lead and create a easy NFT explorer dapp. That method, you’ll see how you can neatly make the most of the outcomes offered by the “getContractNFTs” endpoint. 

Nevertheless, earlier than we invite you to roll up your sleeves and comply with our directions, we have to guarantee the fundamentals. Therefore, we’ll first clarify what NFTs and NFT collections are. We’ll additionally take a better take a look at the final word growth software for NFT collections – the Moralis NFT API.

NFT Collections

NFTs and Collections – What are They?

NFTs (non-fungible tokens) are particular sorts of crypto property. Consistent with the which means of “non-fungible”, most of these tokens will not be interchangeable. Because of this every NFT has its distinctive token ID (an on-chain signature). Therefore, NFTs are designed to symbolize distinctive digital or bodily objects. As such, it is sensible that digital artwork and digital collectibles are usually the most typical utility examples of non-fungible tokens. Nevertheless, NFTs are already revolutionizing many different industries that require any sort of possession proofing or certification issuing. Nonetheless, these crypto property are additionally poised to alter the gaming trade. In spite of everything, we’re already seeing varied Web3 gaming tasks that empower gamers to actually personal their in-game property.  

Moreover, NFTs are sometimes assigned to collections. This isn’t important, as an NFT will be utterly unbiased. Nevertheless, most of the time, the creators of non-fungible tokens are inclined to assign a bigger quantity of tokens to a single assortment. After all, the sizes of collections additionally range vastly from undertaking to undertaking. In digital artwork, collections have a tendency to incorporate fewer NFTs. However, in the case of digital collectibles, a single assortment can typically embrace a number of thousand NFTs. For example, the CryptoPunks assortment contains practically 10,000 NFTs. 

CryptoPunks Collection

Furthermore, it’s value declaring that devs create (mint) NFTs utilizing good contracts. These on-chain items of software program embrace all the small print concerning the NFT they give attention to. Plus, contracts embrace predefined actions that will likely be executed when particular predefined circumstances are met. Therefore, additionally they govern transactions associated to their NFTs. Additionally, observe that there’s the identical good contract behind all of the NFTs in a single assortment. Thus, we get NFTs from a set by specializing in the appropriate good contract.   

Final Growth Software for NFT Collections

Now that what NFTs and NFT collections are, it’s time we take a better take a look at the software that permits you to get all NFTs from a set. By this level, that if you wish to be taught what number of NFTs in a set there are, you should use the Moralis “getContractNFTs” endpoint. After all, there are much more particulars that this wonderful software can give you for a selected assortment.

You possibly can even develop your toolset by using different NFT API endpoints in Moralis’ arsenal. Moreover, when constructing dapps, you’ll probably wish to use different Moralis’ Web3 APIs, beginning with its Web3 Auth API. Furthermore, when working with NFT collections, the “getWalletNFTCollections” and “getNFTContractMetadata” endpoints will be significantly helpful. 

Nevertheless, on this article, we wish to present you how you can get all of the NFTs from a set utilizing “getContractNFTs“. Thus, we have to take a better take a look at this endpoint, which basically allows you to get all NFTs from a contract. Additionally, “getContractNFTs” gives you with metadata for all NFTs belonging to a selected good contract. That mentioned, you need to remember that the endpoint is proscribed to presenting 100 outcomes per web page. As such, you have to work with the cursor parameter for collections with greater than 100 NFTs. 

Get NFTs by Contract Docs

Following is a screenshot of the “Get NFTs by Contract” documentation web page:

The getContractNFT endpoint documentation page.

The latter gives all the small print concerning the endpoint. This web page additionally allows you to check this endpoint and replica the code that matches your programming language. Moreover, listed here are the parameters that this endpoint takes in:

“deal with“ – You utilize this parameter to supply an NFT good contract deal with. Furthermore, this parameter is crucial (all different parameters are elective). “chain“ – This parameter permits you to decide which programmable chain to give attention to (Moralis helps all main Web3 networks).  “format“ – You utilize this parameter to find out what kind of token ID format you wish to work with – decimal or HEX.“restrict“ – This parameter permits you to set the specified web page measurement of the consequence.“totalRange“ – You utilize this parameter to find out the variety of subranges to separate the outcomes into.“vary“ – This parameter permits you to set the specified subrange to question.“cursor“ – You utilize this parameter to get to the subsequent web page when you may have greater than 100 NFTs or wish to show even fewer NFTs per web page.“normalizeMetadata” – This parameter permits you to determine whether or not normalized metadata needs to be returned (true) or not (false). If you happen to select “true”, the endpoint returns metadata in a standardized construction in a brand new object referred to as “normalized_metadata”.     

Now that the speculation and the capabilities of the “getContractNFTs” endpoint, you’re able to get your fingers soiled. As such, be certain to comply with our tutorial that covers the steps you have to full to get NFTs from a set.

The best way to Get All NFTs from a Assortment

Figuring out how you can get all NFTs from a set will be extraordinarily helpful. As identified earlier, NFTs play vital roles in lots of dapps, and you should use most of these tokens to symbolize possession of a novel merchandise on the blockchain. Accordingly, you possibly can construct NFT portfolio trackers, NFT-gated web sites, DAOs, social graphs, and plenty of different sorts of NFT dapps.

Earlier than shifting on, ensure you have these three conditions accomplished:

Set up Node v.14 or increased.Put together your favourite code editor or IDE. We have a tendency to make use of Visible Studio Code (VSC).Set up your favourite package deal supervisor (”npm”, ”yarn”, or ”pnpm”).

Wizard pointing at text that says learn how to get all nfts from a collection.

Step 1: Set Up Moralis  

To finish this tutorial and get all NFTs from a set, you could entry your Moralis admin space. As such, ensure you create your free Moralis account. You are able to do so through the use of the hyperlink within the intro or by visiting the Moralis homepage:

In both case, you’ll land on the register web page. Merely enter your full identify and e-mail deal with, create your password, and settle for the phrases and circumstances. With these particulars in place, you’ll be capable to click on on the “Signal Up” button:

Lastly, affirm your account by clicking on the affirmation hyperlink in your e-mail inbox.

Whether or not you wish to use “getContractNFTs” to get NFTs from a set or another Moralis Web3 API endpoint, you want your Web3 API key. Luckily, now that you’ve your Moralis account prepared and may entry your admin space, you get to acquire it in two easy clicks:

You’ll see the place to stick your API key within the subsequent part. Nevertheless, earlier than shifting on, set up the Moralis SDK in your undertaking. Relying on the package deal supervisor that you’re utilizing, you have to run one of many following instructions:

npm set up moralisyarn add moralispnpm add moralis

Step 2: Use an Instance Script to Get All NFTs from a Assortment

With the preliminary setup below your belt, you’re able to give attention to an instance script that allows you to get all of the NFTs from a set effortlessly. Right here is an “index.js” script that does the trick:

const Moralis = require(“moralis”).default;
const { EvmChain } = require(“@moralisweb3/evm-utils”);

const runApp = async () => {
await Moralis.begin({
apiKey: “YOUR_API_KEY”,
// …and another configuration

const deal with = “0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB”;

const chain = EvmChain.ETHEREUM;

const response = await Moralis.EvmApi.nft.getContractNFTs({
deal with,



Word: In case you favor working with TypeScript, be certain to make use of the “documentation web page” hyperlink above. There, you’ll get to decide on between “index.js” and “index.ts”.

Furthermore, when you take a look at the strains of code above, you possibly can see “EvmChain.ETHEREUM“. The latter defines the chain the script focuses on. So, when you’d prefer to get all of the NFTs from a set on different main EVM-compatible chains, you’d want to exchange “ETHEREUM” accordingly. 

Nonetheless, whether or not you determine to make use of JS or TS, you have to substitute the “YOUR_API_KEY” placeholder with the above-obtained Web3 API key.

Step 3: Execute the Program to Get All NFTs from a Assortment

Now that you’ve the “index” file prepared, you get to execute this system and see the small print for a given deal with, together with what number of NFTs in a set there are. Therefore, enter one of many following instructions in your terminal:

For JavaScript:

node index.js

For TypeScript: 

node index.ts

After operating the suitable command, verify your terminal for the outcomes. If you happen to didn’t change the deal with within the code above, you need to see the next outcomes:

“whole”: 9991,
“web page”: 0,
“page_size”: 100,
“cursor”: “eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3aGVyZSI6eyJ0b2tlbl9hZGRyZXNzIjoiMHhiNDdlM2NkODM3ZGRmOGU0YzU3ZjA1ZDcwYWI4NjVkZTZlMTkzYmJiIn0sInRva2VuX2FkZHJlc3MiOiIweGI0N2UzY2Q4MzdkZGY4ZTRjNTdmMDVkNzBhYjg2NWRlNmUxOTNiYmIiLCJsaW1pdCI6MTAwLCJvZmZzZXQiOjAsIm9yZGVyIjpbXSwicGFnZSI6MSwia2V5IjoiZmQ5MmE0ODg3MmE4NjIwZTFlNmU0NTk3ODZkMTExYWYiLCJ0b3RhbCI6OTk5MSwiaWF0IjoxNjY3ODA4NzcxfQ.9qXwHyyUKJkzrub-ze-q2gm8dC0dy-jvgF0CJrm5piY”,
“consequence”: [
“token_address”: “0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb”,
“token_id”: “9082”,
“amount”: “1”,
“token_hash”: “fffdaced3ddfb220d9124289a518bb97”,
“block_number_minted”: “12021693”,
“updated_at”: null,
“contract_type”: null,
“name”: “CRYPTOPUNKS”,
“symbol”: “Ͼ”,
“token_uri”: “”,
“metadata”: “{“image”:””,”name”:”CryptoPunk 9082″,”attributes”:[“Bandana”,”Big Shades”,”Shadow Beard”],”description”:”Male”}”,
“last_token_uri_sync”: null,
“last_metadata_sync”: “2022-10-05T17:55:52.262Z”,
“minter_address”: “0xc352b534e8b987e036a93539fd6897f53488e56a”
“token_address”: “0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb”,
“token_id”: “4799”,
“quantity”: “1”,
“token_hash”: “fff8ff007820e85a75c545389d5a88d4”,
“block_number_minted”: “11637283”,
“updated_at”: null,
“contract_type”: null,
“identify”: “CRYPTOPUNKS”,
“image”: “Ͼ”,
“token_uri”: “”,
“metadata”: “{“picture”:””,”identify”:”CryptoPunk 4799″,”attributes”:[“Blue Eye Shadow”,”Black Lipstick”,”Straight Hair Blonde”,”Earring”],”description”:”Feminine”}”,
“last_token_uri_sync”: null,
“last_metadata_sync”: “2022-07-17T17:25:24.644Z”,
“minter_address”: “0xc352b534e8b987e036a93539fd6897f53488e56a”
“token_address”: “0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb”,
“token_id”: “47”,
“quantity”: “1”,
“token_hash”: “fff3657368693f145d0ad29453f6cd4d”,
“block_number_minted”: “3918216”,
“updated_at”: null,
“contract_type”: null,
“identify”: “CRYPTOPUNKS”,
“image”: “Ͼ”,
“token_uri”: “”,
“metadata”: “{“picture”:””,”identify”:”CryptoPunk 047″,”attributes”:[“Knitted Cap”],”description”:”Male”}”,
“last_token_uri_sync”: null,
“last_metadata_sync”: “2022-07-24T12:12:11.930Z”,
“minter_address”: “0xc352b534e8b987e036a93539fd6897f53488e56a”
“standing”: “SYNCED”

So, what number of NFTs in a set are there when specializing in the “0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB” deal with on the Ethereum chain? If you happen to’re pondering 9,991, you’re proper. Now, attempt utilizing the “index” script to get NFTs from a set on different EMV-compatible chains.

Finalized NFT explorer dapp letting a user get all NFTs from a collection in 1 click.

Bonus: Get All NFTs from a Assortment Utilizing an Explorer Dapp 

The above tutorial taught you how you can get all of the NFTs from a set. As such, you are actually able to construct a correct dapp using the “getContractNFTs” endpoint. If that sounds attention-grabbing, be certain to make use of the video under and comply with our in-house knowledgeable’s lead. As a substitute of specializing in what number of NFTs in a set there are, you’ll construct a neat NFT explorer dapp. The latter will allow you to enter a contract deal with and choose the chain you wish to give attention to. With these two parameters in place, you’ll be capable to hit the “Get NFTs” button, which is able to get NFTs from a set and neatly current the primary twenty NFTs: 

Lastly, that is the video tutorial that can present you how you can create a NodeJS backend app and ReactJS frontend app and tie all of it collectively to create a cool NFT explorer dapp with Moralis: 

The best way to Get All NFTs from a Assortment in 3 Steps – Abstract

In immediately’s article, you had a chance to learn to get all NFTs from a set utilizing the final word NFT API. In case you had been new to Moralis, you additionally realized that this enterprise-grade Web3 API supplier allows you to create killer dapps the simple method. We additionally defined what NFTs and NTF collections are. Nevertheless, the core of the article was our three-step tutorial that targeted on utilizing the “getContracNFTs” endpoint. Moreover, by finishing this tutorial, you realized how you can simply learn how many NFTs in a set there are, amongst a number of different particulars. Final however not least, you additionally had an opportunity to comply with a brief video tutorial and construct an instance NFT explorer dapp. Therefore, you now know how you can get all NFTs from a set utilizing our instance dapp. 

If you happen to loved immediately’s tutorial and wish to proceed exploring NFT growth, be certain to take a look at our different NFT API how-to guides that await you in Moralis’ docs. However, you could be all for exploring different blockchain growth matters. In that case, you need to go to the Moralis YouTube channel and our blockchain weblog. A few of the newest articles there embrace crypto pockets integration, Web3 supplier, Web3 for enterprise, and plenty of different attention-grabbing matters.

Final however not least, you is perhaps all for going full-time crypto sooner relatively than later. In that case, you must enroll in Moralis Academy. There, you’ll be capable to select amongst many various programs and change into blockchain-certified. Nevertheless, we advocate beginning with blockchain and Bitcoin fundamentals. 

Source link

Stay in the Loop

Get the daily email from CryptoNews that makes reading the news actually enjoyable. Join our mailing list to stay in the loop to stay informed, for free.

Latest stories

- Advertisement - spot_img

You might also like...