DEV Community

Cover image for Guide: How to Develop Web3 Dapp on Polygon Chain Using NFTScan NFT API?
NFT Research
NFT Research

Posted on

Guide: How to Develop Web3 Dapp on Polygon Chain Using NFTScan NFT API?

Polygon, formerly known as Matic Network, is an extended solution that provides various tools to accelerate and reduce the cost and complexity of transactions on blockchain networks. However, the significant activity on its blockchain nearly paralyzed Ethereum due to escalating transaction costs and congested traffic. The primary purpose of Polygon's inception is to help Ethereum address congestion issues within the chain. It achieves this through a multi-layered platform with numerous side chains, effectively offloading the main platform to scale Ethereum in a efficient and cost-effective manner, providing a simpler framework for building interconnected networks.

On the other hand, another significant use of Polygon is to enhance user experience. Ethereum's transaction fees are prohibitively expensive for ordinary users and the speed is slow. Polygon's high performance, low fees, and speed can address common user issues. The NFT ecosystem on Polygon is thriving, gradually becoming the preferred destination for NFTs from Web2 companies.

According to NFTScan data, as of November 10th, the Polygon network has cumulatively issued 699,833,880 NFT assets, comprising 1,527,885 NFT Collections. There have been 2,515,848,185 NFT tranfer, involving 82,664,934 wallet addresses. The total transaction volume is 976,263,373 MATIC.

Polygon NFTScan: https://polygon.nftscan.com/

Image descriptionhttps://polygon.nftscan.com/chart

Accessing the NFTScan NFT API

Step 1: Create a NFTScan Developer Account
Before utilizing the NFTScan API, visit the NFTScan developer platform and create an account. Go to the official NFTScan website and click on the “Sign Up” button under NFTScan API.
NFTScan Developer: https://developer.nftscan.com/user/signup

Image description

Once logged in, find your unique API KEY on the Dashboard. Visit the API documentation and input your API KEY in the designated location. Follow the documentation’s instructions to start using the API services.

Image description

In the API documentation, developers can find multiple interface modes to choose from based on their requirements. Additionally, developers can monitor their API usage statistics in the Dashboard, which helps in keeping track of historical data. Furthermore, NFTScan offers each registered developer 1M CU of API calls, which can be used for requesting all NFT API interfaces, and these CU never expire.

Step 2: View Ethereum API Documentation
After successfully registering a developer account and obtaining an API Key, you need to review the NFTScan API documentation. The API documentation contains all available API endpoints and parameters, as well as detailed information on how to build requests and handle responses. Please read the API documentation carefully and make sure you understand how to use the API to obtain the data you need. NFTScan API services are dedicated to helping developers improve their experience in obtaining NFT data analysis.

Currently, NFTScan has the largest and most comprehensive NFT Collection database on the web, supporting full NFT data for 19 blockchains including Ethereum, Solana, BNBChain, Bitcoin, TON, Polygon, zkSync, Aptos, Linea, Base, Avalanche, Arbitrum, Optimism, Scroll, Fantom, Moonbeam, PlatON, Cronos, and Gnosis. The covered NFT data is extensive and diverse, providing a complete set of interfaces to obtain ERC721 and ERC1155 assets as well as transaction, project, and market statistics information. NFTScan now supports more than 60 public interfaces for EVM-compatible chains and a group of equivalent interfaces for Solana, Aptos, Bitcoin, and TON, largely meeting developers’ needs for indexing various types of NFT data.

Image description

Polygon NFT API Model

This comprises three primary model interfaces, each with an overview and explanation of core API fields to assist developers in accessing and utilizing data for their Dapp services under development.

1/ Assets API: "Assets" represent the most critical data fields within NFT, uniquely identifying and describing digital assets. Developers can extract "Assets" data from NFTs on the Polygon to gain comprehensive insights and construct relevant applications. The "Assets" object provides unique identification for digital assets and data about their entire lifecycle, serving as a foundation for developers to understand and utilize NFTs.

2/ Transactions API: The transaction model represents the complete transaction data for an NFT asset on the blockchain, offering developers a full view of an NFT's transaction history. This includes NFT minting, transfers, sales, and other transaction activities, providing developers with an opportunity to deeply understand the flow and evolution of NFT assets within the Polygon ecosystem. NFTScan continuously aggregates NFT transaction market and related contract information from various blockchain networks. Currently, NFTScan has compiled data for tracking and understanding NFT market dynamics, aiding developers in building NFT-based applications and tools.

3/ Collections API: NFTScan retrieves off-chain data related to NFT Collections, including descriptions, social media, and other fundamental information. This data is obtained from the most popular NFT markets provided through various blockchain networks. Additionally, floor price information is centralized data derived from order information on NFT markets, and it can be accessed via API.

Image description

Polygon NFT API Retrieval

1/ Retrieve Assets Series

  • Get NFTs by account (Retrieve NFTs using a wallet address)
  • Get all NFTs by account (Retrieve all NFTs associated with a wallet address and group them by contract address. If the total number of NFTs owned by the account exceeds 2000, the returned NFTs will be limited to 2000 or less. In such cases, developers and users can use pagination queries to retrieve all NFTs owned by the account.)
  • Get minted NFTs by account (Retrieve NFTs minted by a specific wallet address)
  • Get NFTs by contract (Retrieve NFTs using a contract address, sorted by token_id in ascending order)
  • Get single NFT (Retrieve details of a single NFT)
  • Get multiple NFTs (Retrieve details of multiple NFTs from different contract addresses simultaneously)
  • Search NFTs (This interface returns a list of NFT assets by applying search filters in the request body. Assets are sorted by nftscan_id in ascending order.)
  • Get NFTs by attributes (This interface returns a set of NFTs belonging to contract addresses with specific attributes. NFTs are sorted by token_id in ascending order.)
  • Get all multi-chain NFTs by account (This interface returns all multi-chain NFTs owned by a specific wallet address, grouped by contract address.) Here, we use the Get NFTs by contract interface:"/v2/assets/{contract_address}"to retrieve details of NFTs under a specific contract address. The path parameter includes the contract_address as a selection, and in this case, we are querying NFTs from Owlpha.

Image description

Clicking "Try it" returns the following data. The data response displays the basic and metadata information for all items in the selected NFT Collection. In this case, we have chosen Owlpha, and the data shows a total of 3333 items under the project, sorted by token_id. For example, item with id 0:

  • Basic data for a single item:Contract address: 0x12aa01f646fe5c993c66c9c86eddad4e514f6cbc;Name: Owlpha;NFT Token id: 0;Percentage in the project: 1;Protocol standard: erc721;Wallet address during Mint/Owner's wallet address;Timestamp at Mint/Hash address of Mint/Token URI address;Latest trade price/Latest trade symbol;Latest trade timestamp, etc.
  • Metadata: The metadata for this project indicates that the metadata is hosted on IPFS, with the format being image/png. It includes the storage path and detailed feature descriptions for the image.
  • Rarity description: The item has a rarity score of 0.9080396907866151, and it ranks 2494th in the overall rarity ranking.

Image description

2/ Retrieve Transactions Series

  • Get transactions by account (This interface returns a list of NFT transactions for a wallet address)
  • Get transactions by contract (This interface returns a list of NFT transactions for an NFT contract address)
  • Get transactions by NFT (This interface returns a list of NFT transactions for a single NFT)
  • Search transactions (This interface returns a list of NFT transactions by applying search filters in the request body)
  • Get transactions by to address (This interface returns a list of NFT transactions filtered by transaction parameters)
  • Get transactions by hash (This interface returns transaction

records based on a list of transaction hashes)
Here, we use the Get transactions by contract interface:"/v2/transactions/{contract_address}"to retrieve NFT transaction records for a specific NFT contract address. Query parameters allow the selection of NFT event types (Mint/Transfer/Sale/Burn), separated by ';'.

Similarly, here, we retrieve the transaction records for Owlpha's NFTs. Based on the Mint event type, the response data includes all key data for items minted in this NFT Collection, such as transaction hash, From and To addresses, block information, gas consumption, transaction timestamp, and other fundamental data characteristics of NFT transactions.

Image description

3/ Retrieve Collections Series

  • Get an NFT collection (Retrieve details based on the contract address of the collection, including an overview and classification of items based on descriptions, distribution of holders, average prices, floor prices, and other basic summary information)
  • Search NFT collections (This interface returns information about collections by applying search filters in the request body, and the collections are sorted in ascending order based on the deployment block number)
  • Get NFT collections by account (This interface returns a list of projects with the given account address, and the collections are sorted from high to low based on the floor price)
  • Get NFT collections by ranking (This interface returns a list of projects with the given sorting field, and the collections are sorted based on the specified sorting field and direction)

Here, we use the Get an NFT collection interface:"/v2/collections/{contract_address}"to retrieve details for the collection with the address 0x12aa01f646fe5c993c66c9c86eddad4e514f6cbc named Owlpha.

Image description

4/ Collection Statistics

  • Collection Statistics (This interface provides an analytical overview of NFT Collection statistics)
  • Collection Trade Distribution (This interface primarily provides the distribution of project trades)
  • Collection Trending Statistics (Mainly returns trading statistics ranking for a project)
  • Collection Holding Amount Distribution (This interface can provide information on the distribution of NFT project holdings)
  • Collection Holding Period Distribution (Data returns information about the distribution of NFT project holding periods)
  • Collection Blue Chip Statistics (Overview statistics for blue-chip projects)
  • Collection Blue Chip List (List of blue-chip projects associated with the project, referring to NFTScan Blue Chip Collection)
  • Collection Top Holder (Distribution of the top holders of the Collection)

Here, we use the Collection Top Holder interface:"/v2/statistics/collection/holder/{contract_address}"to mainly return the distribution of holdings within an NFT Collection, which can be referred to at NFTScan Holders: https://www.nftscan.com/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d?module=Holders

Image description

5/ Account Statistics Series

  • Account Overview Statistics (This interface returns an overview of statistical information for an account address, refer to NFTScan Overview)
  • Account Holding Distribution (This interface returns statistical information on the distribution of NFT holdings for an account address, refer to NFTScan Portfolio)
  • Account Holding NFT Trending (This interface returns statistical information on the trending NFT holdings or quantities for an account address, refer to NFTScan Portfolio)

6/ Analytic Statistics Series

This series of interfaces are typically used to obtain various data analysis and statistical information on the NFTScan Polygon network. Interfaces like Trade Ranking, Mint Amount, and others allow developers or users to query, analyze, and retrieve statistical data related to specific datasets or metrics. They can be used for various purposes, including market analysis, trend tracking, investment decisions, and understanding the nature of specific data.
Reference: https://polygon.nftscan.com/analytics

Image description

7/ Refresh Metadata

  • Refresh NFT metadata
  • Refresh NFT metadata by contract

Interfaces like Refresh Metadata can assist developers or users in submitting backend tasks to refresh metadata. Once reviewed, these tasks will refresh the specified item or the entire contract metadata.

8/ Other

  • Get latest block number (Returns the latest block number reached by NFTScan)
  • Get NFT amount by account (Returns information on the quantity of ERC721 and ERC1155 NFTs owned by the account address specified in the request body)
  • Get NFT owners by contract (Returns a list of owners for the specified ERC721 NFT contract address, with NFTs sorted by token_id)
  • Get owners by an NFT (Returns a list of owners for the specified ERC1155 NFT, with NFTs sorted by account_address)

Building Relevant NFT API Requests

Once developers find the necessary Polygon API interfaces and parameters in the NFTScan API documentation, they can use their chosen programming language (such as Python, Java, JavaScript, etc.) to write API request code. Here is an example demonstrating how to use Python to request transaction records for an NFT contract address. In this example, the contract address used is 0x12aa01f646fe5c993c66c9c86eddad4e514f6cbc,and the NFT interface is "/v2/transactions/{contract_address}".

Image description

In the above example, we constructed the API endpoint and contract address, then used the requests.get method to initiate a GET request to retrieve transaction records for the NFT contract address. If the request is successful, developers can extract transaction information from the JSON data in the API response and handle it accordingly.

About NFTScan

NFTScan is the world’s largest NFT data infrastructure, including a professional NFT explorer and NFT developer platform, supporting the complete amount of NFT data for 19 blockchains including Ethereum, Solana, BNBChain, Arbitrum, Optimism, and other major networks, providing NFT API for developers on various blockchains.
Official Links:
NFTScan: https://nftscan.com
Developer: https://developer.nftscan.com
Twitter: https://twitter.com/nftscan_com
Discord: https://discord.gg/nftscan

Top comments (0)