Are you searching for an accessible method to get NFT collections utilizing Python? If that’s the case, you must familiarize your self with Moralis’ NFT API and Python SDK. With these instruments, you possibly can simply question all NFT collections of a selected Web3 pockets in two simple steps:
- Set up Moralis:
pip set up moralis
- Make a Moralis API name to get NFT collections:
from moralis import evm_api api_key = "" params = { "tackle": "", "chain": "eth", "restrict": 0, "cursor": "", } outcome = evm_api.nft.get_wallet_nft_collections( api_key=api_key, params=params, ) print(outcome)
Whenever you run the code, it’ll autonomously return the NFT collections held by the required pockets. As you possibly can see, you solely want a number of quick strains of code to get all NFT collections utilizing Python, due to Moralis. Additionally, take a look at Moralis’ official get collections by pockets NFT API endpoint documentation for added data on how the API works!

Overview
Buying on-chain knowledge is central to Web3 improvement as decentralized functions (dapps) depend upon this data. Due to this fact, blockchain builders want simple strategies for querying and accessing the information saved on the varied decentralized networks. For those who, for instance, are all in favour of non-fungible token (NFT) improvement, one such piece of knowledge may be NFT collections. Luckily, that is the place we are going to direct our consideration on this article. As such, the tutorial will present you methods to get all NFT collections of a Web3 pockets utilizing Python and Moralis!
Because of the Python SDK and NFT API, you possibly can simply get all of the NFT collections of a specified pockets. What’s extra, you are able to do so with just a few strains of code. So, if you wish to study extra about this, comply with alongside as we present you the way to take action! Together with exhibiting you methods to get this knowledge, the article additionally demonstrates methods to arrange an easy Python and React utility the place customers can enter a pockets tackle to question its NFT collections.
What’s extra, the NFT API is just one of Moralis’ varied Web3 APIs you must discover. Different distinguished examples are the EVM API, Solana API, Token API, Streams API, and so forth. These are all instruments contributing to a extra seamless developer expertise and why Moralis presents the quickest method to construct a Web3 app!
So, it doesn’t matter what blockchain improvement endeavors you need to embark on, enroll with Moralis instantly. With an account, you obtain entry to all of the aforementioned instruments and may absolutely leverage the facility of blockchain. What’s extra, you possibly can create your account without spending a dime, so you don’t have anything to lose!
Easy methods to Get All NFT Collections from a Pockets Utilizing Python
The next sections will present you methods to get the NFT collections of a selected Web3 pockets utilizing Python. To make this as accessible as doable, we are going to use Moralis’ collections NFT API endpoint and the Python SDK. By means of these instruments, you will get the collections of a selected pockets with just a few quick strains of code!
Together with exhibiting you methods to get NFT collections utilizing Python, the tutorial additionally briefly illustrates methods to arrange a whole undertaking implementing this performance. For comfort, we are going to use an already-developed undertaking and present you methods to add the required configurations for making it operational.
The undertaking incorporates a frontend React utility and a Django Python backend server dealing with the applying logic. With the React utility, customers can enter a pockets tackle and choose a sequence to question the pockets’s NFT collections.
We divided the tutorial into the next two sections to make it as simple as doable:
- Easy methods to Get All NFT Collections Utilizing Moralis’ Collections NFT API Endpoint
- Easy methods to Set Up the Full Utility
Nevertheless, earlier than leaping into the tutorial, the next part options an utility demo exhibiting you the way the ultimate undertaking works. By masking this, you’re going to get a greater understanding of what you might be working in the direction of and how one can implement this performance into your personal tasks sooner or later!
Utility Demo – Get NFT Collections Utilizing Python
Earlier than leaping into the tutorial, this part offers an utility demo as an instance what you might be working in the direction of and offer you an summary of the top product. Nonetheless, down beneath, you will see a screenshot of the applying’s touchdown web page:
The appliance options three enter fields: ”Pockets”, ”Chains”, and ”Restrict”. These components are comparatively self-explanatory; nonetheless, allow us to cowl them for the sake of it. Within the ”Pockets” subject, you possibly can enter any pockets tackle from which you need to get NFT collections utilizing Python. The ”Chain” enter subject contains a drop-down menu with a number of EVM-compatible chains to select from. Lastly, the quantity specified within the ”Restrict” subject restricts the variety of collections returned to the frontend.
As soon as we’ve entered the data in all of the enter fields, all that is still is hitting the ”Get NFTs” button, and it’ll present a response much like the one proven beneath:
Because the picture above illustrates, the applying returns as much as ten NFT collections held by the required Web3 pockets. Nonetheless, that covers the whole lot of the applying! Now, let’s leap into the tutorial and present you methods to create this utility from which you will get NFT collections utilizing Python!
Easy methods to Get All NFT Collections Utilizing Moralis’ Collections NFT API Endpoint
The central a part of this tutorial is to indicate you methods to get NFT collections utilizing Python, and this part will present you the way to take action utilizing Moralis’ collections NFT API endpoint. After you have familiarized your self with the endpoint, the continuing part briefly covers methods to arrange the applying proven above. For now, we are going to deal with methods to get NFT collections utilizing Python!
That mentioned, there are two conditions you must take care of: putting in Django and the Relaxation framework, which you are able to do by opening a brand new terminal and operating the next two instructions:
pip set up django
pip set up djangorestframwork django-cors-header
From there, progress by establishing a brand new undertaking utilizing Django. With a undertaking at your disposal, create a brand new file known as ”companies.py”. From there, copy and paste the next code from the Moralis collections NFT API endpoint documentation into the file you simply created:
from moralis import evm_api api_key = "" params = { "tackle": "", "chain": "eth", "restrict": 0, "cursor": "", } outcome = evm_api.nft.get_wallet_nft_collections( api_key=api_key, params=params, ) print(outcome)
As you possibly can see by inspecting the code above additional, you must add a number of parameters. To begin with, you will need to add your Moralis API key. So, in case you nonetheless have to, enroll with Moralis now. From there, log in, navigate to the ”Web3 APIs” tab, copy the important thing, and paste it into your code:
Along with including your Moralis API key, you must specify the pockets tackle from which you need to get the NFT collections, the chain, and a restrict. For this tutorial, we are going to add a random pockets tackle, set the chain to ”eth”, and the restrict to ”10”. We will go away the ”cursor” empty for now. Accordingly, your ”companies.py” ought to now look one thing like this:
from moralis import evm_api api_key = "JnJn0MW…" params = { "tackle": "0xd06Ffc91…", "chain": "eth", "restrict": 10, "cursor": "", } outcome = evm_api.nft.get_wallet_nft_collections( api_key=api_key, params=params, ) print(outcome)
That covers the code! Within the following sub-section, we present you methods to strive it out and what the response seems like!
Working the Code
As a way to run the code, open a brand new terminal and set up Moralis with the next terminal enter:
pip set up moralis
From there, make sure that you ”cd” into the proper location of the folder containing the file. Then, run the command beneath within the terminal:
python companies.py
As quickly as you run this command, it ought to return a terminal response with a most of ten NFT collections held by the required pockets, and it ought to look one thing like this:
That’s it! That is how easy it’s to get NFT collections utilizing Python and Moralis. Nevertheless, as you possibly can see from the response, it’s a bit messy and tough to interpret. Due to this fact, we are going to look intently on the full app we showcased earlier within the ”Utility Demo – Get NFT Collections Utilizing Python” part down beneath!
Easy methods to Set Up the Full Utility
Now that you understand how to get NFT collections utilizing Python and due to the accessibility of Moralis’ collections NFT API endpoint, allow us to take a more in-depth take a look at how one can apply the identical elementary ideas to create a whole utility. To make issues as simple as doable, we are going to use a developed undertaking that includes a Python backend server app and React frontend app. It is possible for you to to search out your complete undertaking’s code within the GitHub repository beneath:
Full Get NFT Collections Utilizing Python Documentation – https://github.com/MoralisWeb3/youtube-tutorials/tree/fundamental/nft-collections-django-react
To kick issues off, open the GitHub repository above and clone your complete undertaking to your native listing. With your complete code at your disposal, you now want to put in Django, the Relaxation framework, Moralis, “python-dotenv“, and “axios“. To take action, open a brand new terminal and run the next instructions of their consecutive order:
pip set up django
pip set up djangorestframework django-cors-headers
pip set up moralis
pip set up python-detenv
npm set up axios
Subsequent up, you must set up the required dependencies. As such, ”cd” into the undertaking’s frontend folder and run the command beneath:
npm set up
From there, create a brand new “.env” file within the ”backend/nft/” folder and add your Moralis API key.
Now that’s it! When you’ve got adopted alongside this far, you now have your complete undertaking in your native listing and have made all of the required configurations. Consequently, all that is still is operating the Django Python server and the React frontend utility!
Working the App
To run this utility, you first have to spin up the Python server on the backend utilizing the next terminal command:
python handle.py runserver
From there, you possibly can ”cd” into the undertaking’s frontend folder and run the React utility by inputting the next and hitting enter:
npm begin
Working this command ought to launch the applying, permitting you to check its performance. Consequently, you must now have the ability to enter an tackle, choose a sequence, set a restrict, and get the NFT collections of that specific pockets.
That’s it for this tutorial on methods to get NFT collections utilizing Python and React! When you’ve got questions concerning the endpoint, take a look at the official NFT API collections endpoint documentation web page from Moralis.
What’s extra, in case you are searching for a whole breakdown of your complete undertaking, take a look at the next clip from Moralis’ YouTube channel. Within the video beneath, one among Moralis’ proficient engineers walks you thru your complete code. Furthermore, the engineer exhibits you methods to arrange the backend and frontend in additional element:
Do you’ve additional curiosity in Python and Web3? If that’s the case, take a look at our Python for Ethereum improvement information, and learn to construct a Web3 Ethereum Python app. Moreover, learn Moralis’ full Web3 Python SDK documentation!
Abstract – Get NFT Collections Utilizing Python
On this article, you realized methods to get NFT collections utilizing Python. Because of Moralis, you possibly can implement this performance with just a few strains of code. Together with instructing methods to get NFT collections, the article additionally confirmed methods to arrange an easy Python and React utility. Within the app, customers can enter a pockets tackle and obtain its NFT collections in return. When you’ve got adopted alongside this far, now you can use the identical elementary ideas in any of your future Web3 improvement endeavors to implement comparable performance!
That mentioned, in case you discovered this text useful, think about trying out further content material right here on the Web3 weblog. When you’ve got a selected curiosity in Python improvement, we extremely suggest our information on methods to arrange automated Web3 notification emails. Or, if you wish to have Python Web3 improvement made simple, take a look at the linked article. Additionally, there are different fascinating articles you may discover thrilling. For instance, study extra about blockchain infrastructure firms or discover ethers.js vs Web3 streams!
Furthermore, if you wish to turn out to be a more adept Web3 developer, think about enrolling in Moralis Academy. The academy presents a number of the finest blockchain improvement programs for each novice and skilled builders. Irrespective of your present talent degree, you’ll most definitely discover programs interesting to you. For instance, in case you are new to blockchain improvement, take a look at the course on Ethereum fundamentals.
Nonetheless, it doesn’t matter if you wish to get all NFT collections utilizing Python or develop different dapps; enroll with Moralis proper now! You may create an account without spending a dime, which solely takes a number of seconds. With an account, you obtain quick entry to the varied instruments of Moralis. This lets you leverage the facility of blockchain know-how absolutely!