Guide: How to Develop Web3 Dapp on BNB Chain Using NFTScan NFT APIs
Tags: web3, nft, nftscan, api
Published: 2023-11-06 09:11:11

BNB Chain is a blockchain compatible with the Ethereum Virtual Machine (EVM), serving as a testing ground and cutting-edge exploration for leading projects in the cryptocurrency industry. By introducing the Proof of Stake Authority (PoSA) consensus mechanism, BNB Chain has created an ecosystem that benefits nodes, token holders, developers, and users, offering higher performance and ample innovation space. BNB Chain remains a community-driven, open-source, and decentralized ecosystem.

According to NFTScan data, as of November 2nd, there have been a total of 195,093,986 NFT assets issued on the BNB Chain, with 608,766 NFT collections, 435,980,676 transaction records, 26,946,054 wallet addresses engaged in interactions, and a total transaction volume of 1,412,382.57 BNB.

You can explore BNB NFTScan here: https://bnb.nftscan.com/

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfj2b3mdbwabcuxlaknh.png)

With the API provided by NFTScan, developers can efficiently and automatically retrieve and process a vast amount of NFT data without the need for manual operations or complex decision-making, significantly reducing development costs. The API enables easy high-frequency monitoring, reducing labor costs. Furthermore, NFTScan API returns data in a standardized format, making the development and optimization of monitoring tools simpler and more efficient. Customizable parameter settings also allow developers to tailor their own solutions. In addition to supporting 15 EVM-compatible chains, NFTScan also supports four non-EVM blockchains: Bitcoin, Aptos, Solana, and TON.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1w8twfqz3jh8m5jfhrax.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l8yscehvvmge45rdsm2k.png)[Sign Up on NFTScan Developer](https://developer.nftscan.com/)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97zv81wzx1t1tr15wd7m.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/74tc1xvbw2uhpayjut51.png)

## BNB 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 BNB Chain blockchain 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 BNB 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o6oj4ks6i25nl63fdufd.png)

## BNB NFT API Retrieval
**1/Retrieve Assets Series**

- Get NFTs by account (Retrieve NFTs by 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 this case, developers and users can request page-by-page queries to obtain all NFTs owned by the account.)
- Get minted NFTs by account (Retrieve minted NFTs for a specific wallet address)
- Get NFTs by contract (Retrieve NFTs by contract address and sort them in ascending order by token_id)
- Get single NFT (Retrieve a single NFT)
- Get multiple NFTs (Retrieve NFTs from multiple contract addresses simultaneously)
- Search NFTs (This interface returns a list of NFT assets by applying search filters in the request body. Assets are sorted in ascending order by nftscan_id. Note: when filtering data using only the block_number condition, the range between block_number_start and block_number_end should not exceed 10,000.)
- Get NFTs by attributes (This interface returns a set of NFTs belonging to contract addresses with specific attributes, sorted in ascending order by token_id.)
- Get all multi-chain NFTs by account (This interface returns all multi-chain NFTs owned by an account, grouped by contract address.)

Here, we use the "Get single NFT" interface: "/v2/assets/{contract_address}/{token_id}" to retrieve detailed information about a single NFT item under a specific contract address. The path parameters include contract_address/token_id as selections, and in this case, we are querying the NFT with contract address Pancake Squad and token id 1.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sfflkset0cww3nk0x8wu.png)

Click "Try it," and the data returned includes basic information about the NFT asset's contract address, metadata details, and rarity description.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z559gfverlq3jksguvus.png)

**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 NFT transaction lists 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 NFT" interface: "/v2/transactions/{contract_address}/{token_id}" to retrieve transaction records for a specific single NFT item. Query parameters allow you to select NFT event types (Mint/Transfer/Sale/Burn) for the transaction and use ';' to separate multiple events.

Similarly, in this case, we are retrieving the NFT with contract address Pancake Squad and token id 1. By selecting the Mint event type, the response data will include all key information about this NFT transaction, such as transaction hash, From and To addresses, block information, gas consumption, transaction timestamp, and other basic data, providing characteristic information for the NFT transaction.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n143d80zzbcq8f2f3f4k.png)

**3/ Retrieve Collections Series**

- Get an NFT collection (Retrieve details based on the contract address of a Collection, including an overview and categorization of Items by description, owner distribution, average price, floor price, and other basic information)
- Search NFT collections (This interface returns information about Collections by applying search filters in the request body. Collections are sorted in ascending order by deployment block number. Note: when filtering data using only the block_number condition, the range between block_number_start and block_number_end should not exceed 10,000.)
- Get NFT collections by account (This interface returns a list of projects associated with a given account address, sorted by floor price from high to low)
- Get NFT collections by ranking (This interface returns a list of projects with a given ranking field, sorted by the specified sorting field and sorting direction)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n0cnf277zvsc79p4xm1p.png)

**4/ Collection Statistics Series**

- 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 Holding Amount Distribution" interface: "/v2/statistics/amount/distribution/{contract_address}" to mainly return the distribution of holdings within an NFT Collection, which can be referred to at NFTScan Amount Distribution: https://www.nftscan.com/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d?module=Holders

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vur5b4fqthtfuokw11r.png)

**5/ Account Statistics Series**

- Account Overview Statistics (This interface provides an overview of statistical information for a given account address, see NFTScan Overview)
- Account Holding Distribution (This interface provides statistical information on the distribution of NFT holdings for a given account address, see NFTScan Portfolio)
- Account Holding NFT Trending (This interface provides statistical information on the quantity or amount of NFT holdings for a given account address, see NFTScan Portfolio)

**6/ Analytic Statistics Series**

This series of interfaces is typically used to obtain data analysis and statistical information related to NFTScan on the Ethereum network. Interfaces such as Trade Ranking and Mint Amount allow developers or users to query, analyze, and retrieve statistical data related to specific datasets or metrics. These statistics can be used for various purposes, including market analysis, trend tracking, investment decisions, and understanding the nature of specific data.

Reference: https://bnb.nftscan.com/analytics

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1uxokaz6eoindm2xkta2.png)

**7/ Refresh Metadata**

- Refresh NFT metadata
- Refresh NFT metadata by contract
Interfaces like Refresh Metadata can assist developers or users in submitting background tasks to refresh metadata. These tasks, after review, will refresh the specified Item or the entire contract's metadata.

**8/ Other**

- Get the latest block number (Returns the latest block number reached by NFTScan)
- Get NFT amount by account (Returns the number of ERC721 and ERC1155 NFTs owned by an account address based on the search list provided in the request body)
- Get NFT owners by contract (Returns a list of owners for an ERC721 NFT contract address, with NFTs sorted in ascending order by token_id)
- Get owners by an NFT (Returns a list of owners for ERC1155 NFTs, with NFTs sorted in ascending order by account_address)

## Building Relevant NFT API Requests
Once developers have found the required BNB API interfaces and parameters in the NFTScan API documentation, they can write API request code using their chosen programming language, such as Python, Java, JavaScript, etc. Here's a simple example demonstrating how to make API requests using Python:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yzl2huu7pg44j8ky0sgl.png)

In the above example, we constructed an API endpoint and provided a contract address. Then, we used the requests.get method to send a GET request to retrieve detailed information about an NFT collection. If the request is successful, developers can extract and process information about the NFT collection from the JSON data in the API response.

Please make sure to replace the contract_address with the actual contract address. This example uses the requests library in Python to make the request. If you are using a different programming language, you will need to adjust the request method and libraries accordingly.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4kfu8r19slt7l3t25797.png)

## 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