Tutorials

Multi-chain NFT API: How to get NFT Data

Multi-chain NFT API: How to get NFT Data

Gaming - Unity3D Developer at NFTPort

NFT data is one of the most valuable and essential things you’ll need in any kind of product integrating NFTs – be it NFT assets like images or metadata properties. Though there can be a lot of complexities in integrating and reading this data from the blockchain. Coupled with different blockchains, this makes it even harder.

If you’re looking for a simple multi-chain solution, then you’ve come to the right place. In this article, we’ll go through how NFTPort provides access to everything in an NFT with fast, reliable, and up-to-date data.

Complexities of getting blockchain data

Getting fast and reliable data is one of the most important aspects of any product for a good user experience, whether you want to build an NFT marketplace, an NFT analytics platform, or on-chain NFT games.

However, getting the data from a blockchain is not an easy task. To do it from scratch one needs to run their own blockchain nodes for different chains and parse the data from it. The complexities which come with different blockchain structures make it even more technically difficult and costly.

  • Blockchain stack is complex 🤔
    Grasping Solidity, Web3.js, GraphQL, nodes, IPFS, data-intensive applications, etc. is hard, time-consuming and usually needs a team to cover all of the skills.
  • Setting up and maintaining blockchain infra is like selecting the nightmare difficulty in Doom 👹
    Teams waste 25-50% of engineering resources managing nodes, developing NFT indexers, doing DevOps, etc. Going multi-chain only compounds that because it usually takes 3+ months to develop a robust NFT infrastructure per chain.
  • Running your own nodes is expensive 💸
    Already only for Ethereum, you will run into a minimum of $84k/year in costs i.e. $2k-5k/month for cloud and $5K/month for engineering time. Using hosted node providers is even more expensive as you need to retrieve all the historical NFT data.
  • Speed matters in this market 🚀
    Being leapfrogged by the competition in a fast-moving NFT market is one of the top worries for many. Slow-to-deploy and -use APIs will hinder your go-to-market, thus you risk losing users, and revenue and being displaced by the competition.

It becomes clear very quickly that it is extremely time-consuming and difficult with all sorts of unaccustomed problems surfacing.

We know this because we’ve experienced it ourselves.

How to bring high-quality NFT data to your product?

NFTPort Data APIs fix the problem outlined above. At NFTPort we run multiple services across a range of blockchain networks, constantly live indexing the blockchains to deliver fast, reliable and high-quality ****NFT data.

As a result, you’ll get highest quality data from Polygon, Ethereum and Solana, including tokens,  assets, metadata, contracts, ownership info, transactions, floor prices, and sales stats. It saves developers months of work.

Cross-chain design with a unified developer experience makes it very easy to create cross-chain products without diving into the intricacies of different blockchains yourself.

NFTPort also offers cached assets, a fast alternative copy of the original NFT assets. The original assets are usually hosted anywhere like IPFS, custom domains and more which can be slow and unavailable at times.

NFTPort’s cached assets promise to deliver fast and reliable assets of the NFTs be it images, audio, video, 3D objects, documents, or whatever type of data the NFT holds.

Data quality from NFTPort’s Data API

Fast and reliable data is one of the core aspects NFTPort focuses on. We are constantly live-indexing the blockchains to deliver fast, reliable, and high-quality NFT data, with top collections being manually verified. We have at least 99% coverage and API uptime on supported chains. This means you can always rely on getting the most recent, up-to-date data from NFTPort’s data API.

We dive deeper into the comparisons between different data providers in the article NFT data quality APIs comparison. Meanwhile, here’s a quick look at our current data coverage for the top 10k collections on Ethereum (as of September 2022):

Getting started with NFTPort

Step 1: Get your free API key

First, sign up for NFTPort for free and copy your API key from the "API key" section.

Step 2: Query NFT data based on requirements

The magic here lies in the parameters within the URL request which can be modified to use-case-specific needs.

Get NFT Metadata and cached assets from Polygon, Solana and Ethereum

NFT Details API lets you query everything about a single NFT. For example, if in your product the user enters a particular NFT they want to look up, this is the query you’ll need. It will provide you with all the assets, metadata, type of NFT and also the ownership information. This is useful in creating NFT viewers, games or experiences around particular NFTs, and more.

Parameters: For EVM chains you need to pass the contract address and token ID in the request URL after the nfts/. Also, determine the ?chain= parameter when querying from EVM, while for Solana* you just need to pass in the mint address of the NFT after nft/

*Solana url commented out for example purposes.

# Get Details of a particular NFT
curl --request GET \

#for EVM
--url 'https://api.nftport.xyz/v0/nfts/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d/2222?chain=ethereum' \
#for Solana 
#--url 'https://api.nftport.xyz/v0/solana/nft/7voJkCEYAnKDnYQMW8FDRon7zrrZbMh5y68smFbnAwuc' \

--header 'Authorization: YOUR-API-KEY-HERE' \
--header 'Content-Type: application/json'

View code snippets for different languages here: Docs.

With a bit of CSS, you can display the results of this query like this in your product:

Get all metadata and details of any NFT with a single API call.

Get all NFTs from a collection / contract

You can also query all the NFTs of a particular contract or collection alongside metadata and assets for all of them. This is useful for building products like marketplaces, analytics tools, experiences tied to particular collections and more.

Parameters: For EVM networks you need to pass the contract address in the request URL while defining the EVM chain after ?chain=. For Solana, you just need to pass the collection ID of the NFT which can be obtained by NFT details or any other Solana ownership endpoints. Parameter ?include=metadata or ?include=all can be passed to retrieve detailed information like type, contract, metadata, etc. about the NFTs.

# Get NFTs in a collection/contract with all its details
curl --request GET \

#for EVM
--url 'https://api.nftport.xyz/v0/nfts/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d?chain=ethereum&include=all' \
#for Solana
#--url 'https://api.nftport.xyz/v0/solana/nfts/oak-paradise-920f13f9?include=metadata'

--header 'Authorization: YOUR-API-KEY-HERE' \
--header 'Content-Type: application/json'

View code snippets for different languages here: Docs

With a bit of CSS, you can display the results of this query like this in your product:

Get all NFTs, including their metadata, from a collection with a single API call.

Get NFT ownership data

Given an account address, you can query the NFTs this account holds, has created, and more. For example, when a user connects their wallet, this can be queried to display their NFT data. Also useful in creating token gated experiences, account explorers, etc.

Parameters: Here you need to pass the account wallet address in the request URL. Parameter ?include=metadata or ?include=all can be passed to retrieve detailed information about the NFTs like type, contract, metadata or more. For EVM chains you can also further define the networks like polygon, rinkeby and ethereum after ?chain=.

You can also query a particular contract address here to verify if the account owns any NFTs from that particular collection by just adding an extra parameter &contract_address= followed by the contract address of the collection you would like to filter from.

Retrieve NFTs owned by an account

# Retrieve NFTs owned by an account
curl --request GET \

#for EVM
--url 'https://api.nftport.xyz/v0/accounts/0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045?chain=ethereum&include=metadata' \
#for Solana
#--url 'https://api.nftport.xyz/v0/solana/accounts/BeUpd7oDsv5hBU9MXJzZhv18cnkL9g1FBFTSCH5JMULE?include=metadata' \

--header 'Authorization: YOUR-API-KEY-HERE' \
--header 'Content-Type: application/json'

View code snippets for different languages here: Docs

With a bit of CSS, you can display the results of this query like this in your product:

Get all NFTs owned and/or created by an account (wallet) with a single API call.

Retrieve NFTs created by an account

# Retrieve NFTs created by an account
curl --request GET \

#for EVM
--url 'https://api.nftport.xyz/v0/accounts/creators/0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045?chain=ethereum&include=metadata' \
# for Solana
#--url 'https://api.nftport.xyz/v0/solana/accounts/creators/BeUpd7oDsv5hBU9MXJzZhv18cnkL9g1FBFTSCH5JMULE?include=metadata' \

--header 'Authorization: YOUR-API-KEY-HERE' \
--header 'Content-Type: application/json'

View code snippets for different languages here: Docs

Get NFT transactional data

Transactional data gives you the whole journey an NFT, Account or Collection has gone through with information like mint, burn, transfer from, transfer to, buy, sell and more. Useful for creating analytics platforms, marketplaces and experiences tied to the current state of the NFT or account. For example, when was the NFT last sold or bought, was it just minted or eventually burnt.

Parameters: Here alongside the NFT, account or collection parameters similar to what we explored above, an additional type= parameter can be set to retrieve specific transactions such as mint, burn, transfer_from, transfer_to, buy, sell, or all which includes all transactions.

Retrieve transactions by NFT

# Retrieve transactions by NFT
curl --request GET \
#for EVM
--url 'https://api.nftport.xyz/v0/transactions/nfts/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d/222?chain=ethereum&type=all' \
#for Solana
#-- url 'https://api.nftport.xyz/v0/solana/transactions/nft/7voJkCEYAnKDnYQMW8FDRon7zrrZbMh5y68smFbnAwuc?type=all' \

--header 'Authorization: YOUR-API-KEY-HERE' \
--header 'Content-Type: application/json'

View code snippets for different languages here: Docs

With a bit of CSS, you can display the results of this query like this in your product:

Similarly, you can get all transactional data by account (wallet address) and by contract.

Retrieve transactions by an account

# Retrieve transactions by an account
curl --request GET \

#for EVM
--url 'https://api.nftport.xyz/v0/transactions/accounts/0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045?chain=ethereum&type=all' \
#for Solana
#--url 'https://api.nftport.xyz/v0/solana/transactions/accounts/BeUpd7oDsv5hBU9MXJzZhv18cnkL9g1FBFTSCH5JMULE?type=all' \

--header 'Authorization: YOUR-API-KEY-HERE' \
--header 'Content-Type: application/json'

View code snippets for different languages here: Docs

Retrieve transactions by contract

# Retrieve transactions by contract
curl --request GET \

#for EVM
--url 'https://api.nftport.xyz/v0/transactions/nfts/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d?chain=ethereum&type=all' \
#for Solana
#--url 'https://api.nftport.xyz/v0/solana/transactions/nfts/oak-paradise-920f13f9?type=all' \

--header 'Authorization: YOUR-API-KEY-HERE' \
--header 'Content-Type: application/json'

View code snippets for different languages here: Docs

Get NFT sales statistics & prices from marketplaces

Get all the sale statistics of an NFT collection like volume (one day, seven days, monthly and more), total supply, total mints, floor price plus its historic data, etc. Useful to build analytics tools, marketplaces and experiences tied to sales statistics.

Parameters: Here you just need to pass the contract address of the collection, followed by the chain parameter on EVM.

# Get NFT sales statistics & prices from marketplaces
curl --request GET \
--url 'https://api.nftport.xyz/v0/transactions/stats/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d?chain=ethereum' \
--header 'Authorization: YOUR-API-KEY-HERE' \
--header 'Content-Type: application/json'

View code snippets for different languages here: Docs

With a bit of CSS, you can display the results of this query like this in your product:

Bring quality NFT data to your product effortlessly

In conclusion, we have looked at how to get different types of NFT Data easily with NFTPort across multiple blockchains. With NFTPort protocol adding even more blockchains in the future, the unified multi-chain developer experience makes shipping and integrating NFT products to different blockchains super fast and seamless.

The cached file parameters in the metadata responses guarantee you get the NFT assets at all times including NFT images, animations, videos, audio and more.

This covers only fetching data, there is also a whole new paradigm with minting NFTs which is covered in another article - How to mint NFTs with a REST API in 10 minutes. The possibilities are endless from games, marketplaces, analytics tools, social apps, art experiences, NFT event tickets and more.

Join the NFT Dev Community for support and to build together

Join our Discord community if you need support from our team and a space to discuss NFT-related topics, voice feature requests, and engage with other like-minded NFT developers 💻

About NFTPort

The Stripe for NFTs — One-Stop, Simple and Developer-First NFT Infrastructure & APIs which Help Developers bring their NFT application to market in hours instead of months. We take care of the NFT infrastructure so you can focus on your application. By devs, for devs.

Website | Blog | Discord Community | Twitter | Docs | Contact Us

Similar Posts

Relevant Posts

Bring Your NFT Project to Life

Get Free API Key