DEV Community

Cover image for Guide: How to Develop Web3 DApps on Fantom Network Using NFTScan NFT API
NFT Research
NFT Research

Posted on

Guide: How to Develop Web3 DApps on Fantom Network Using NFTScan NFT API

Fantom is a high-throughput blockchain with low transaction costs and instant finality. Due to its EVM compatibility, it is used by many Ethereum developers to extend their Web3 applications. Ethereum developers can easily deploy their existing contracts using standard Ethereum developer tools while leveraging a faster blockchain to increase the diversity of dApp types they can develop.

According to NFTScan data, as of January 12th, there have been a total of 8,237,504 NFT assets issued on the Fantom network, with 13,010 NFT collections, 20,162,698 interaction records, 1,054,024 wallet addresses with interactions, and a total transaction volume of 32,144,526.02 FTM.

Fantom NFTScan: https://fantom.nftscan.com/

Image description

Create an NFTScan Developer Account

Before using the NFTScan API, you need to visit the developer's website and create an account. Go to the NFTScan official website and click the “Sign Up” button for the NFTScan API to register.

https://developer.nftscan.com/user/signup

After logging in, find your unique API KEY on the Dashboard. Visit the API documentation and enter your API KEY in the appropriate location. Follow the instructions in the documentation to start using the API service. In the API documentation, developers can find various interface modes to choose from and select the most suitable one based on their needs.

In the Dashboard, developers can also view statistical data on their API usage, which helps track historical usage data. Additionally, NFTScan provides 1M CU of API call service to all registered developers for requesting all NFT API interfaces, and the CU never expires until it is used up!

Review the Fantom NFT 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 the available API endpoints and parameters, as well as detailed information on how to construct requests and handle responses. Read the API documentation carefully and ensure that you understand how to use the API to retrieve the data you need. The NFTScan API service is designed to help developers improve their experience of obtaining NFT data analysis.

NFTScan currently has the largest and most comprehensive NFT Collection library in the entire network. It supports full data of NFTs from Ethereum, Solana, BNBChain, Bitcoin, TON, Polygon, zkSync, Aptos, Linea, Base, Avalanche, Arbitrum, OP Mainnet, Starknet, Scroll, Viction, Fantom, Moonbeam, PlatON, Cronos, and Gnosis. It covers a wide range of NFT data and provides a set of interfaces to obtain ERC721 and ERC1155 assets, transactions, projects, market statistics, and more. It now supports over 60 public interfaces for EVM-compatible chains, as well as a set of interfaces for Solana, Aptos, Bitcoin, and TON with the same model, which largely meets the needs of developers to index various types of NFT data.

Image description

Fantom NFT API Models

These include the following three model interfaces, which provide an overall introduction and explanation of the core fields of these API models. This helps developers understand how to retrieve data and use this information to serve their own Dapp services.

Assets API: “Assets” are the most critical data fields in NFTs, used to uniquely identify and describe digital assets. Developers can extract the “Assets” data of NFTs on the Fantom blockchain to gain a comprehensive understanding and build related applications. The “Assets” object provides the unique identifier of the digital asset and data on its entire lifecycle, providing a foundation for developers to understand and apply NFTs.

Transactions API: The transaction model represents the full transaction data of an NFT asset on the blockchain, providing developers with complete transaction information for the lifecycle of an NFT. This includes minting, transfers, sales, and other transaction activities of NFTs, providing developers with opportunities to understand the flow and evolution of NFT assets in the Fantom ecosystem. NFTScan continuously aggregates the NFT trading market and related transaction contract information from various blockchain networks. Currently, NFTScan has collected dynamic NFT market tracking and understanding information, which also helps developers build NFT-based applications and tools.

Collections API: NFTScan retrieves off-chain data related to NFT collections, such as descriptions, social media, and other basic information, by leveraging popular NFT market APIs from various blockchain networks. Additionally, the current floor price information is based on centralized data from the NFT market and is accessible via API.

Image description

Fantom 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 can use the “Get single NFT” endpoint of the API, “/v2/assets/{contract_address}/{token_id}”, to retrieve detailed information about a single NFT item under a contract address. The path parameters include contract_address and token_id for selection. Here, we query an NFT with the contract address veEQUAL and token id 1.

We retrieve the detailed information of a single NFT item under a contract address through the “Get single NFT” API, which is “/v2/assets/{contract_address}/{token_id}”. The path parameters include contract_address and token_id for selection. In this case, we are querying the NFT with veEQUAL as the contract address and token id 1.

Image description

Upon clicking “Try it,” the returned data includes the basic information query of the NFT asset contract address, metadata information, and rarity description.

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

We use the “Get transactions by contract” API to retrieve the transaction records of a specific address. The query parameters allow us to select the NFT event types (Mint/Transfer/Sale/Burn) of the transactions, separated by ‘;’. In this case, we are selecting the Mint event type. After entering your API key, the response data will contain all the key details of the NFT transaction, including transaction hash, block information, From and To addresses, contract address, transaction timestamp, as well as specific features of the NFT transaction such as Token ID, transaction amount, and cryptocurrency.

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” API “/v2/collections/{contract_address}” to retrieve the details of the collection with the address “0x8313f3551c4d3984ffbadfb42f780d0c8763ce94” and the name “veEQUAL”.

Image description

4/ Collection Statistics: Statistical Analysis for Collection

  • 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” API “/v2/statistics/amount/distribution/{contract_address}” to primarily retrieve the holding amount distribution information for an NFT collection. You can refer to the Fantom NFTScan Holding Amount Distribution on the Fantom chain for reference.

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

These series of APIs are typically used to retrieve information related to data analysis and statistics on NFTScan Fantom. APIs like “Trade Ranking,” “Mint Amount,” and “Gas Ranking” allow developers or users to query, analyze, and retrieve statistical data related to specific datasets or metrics. These APIs can be used for various purposes, including market analysis, trend tracking, investment decisions, and understanding the nature of specific data.

Reference: https://fantom.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 the 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
Developers can find the required Fantom API interface and parameters in the NFTScan API documentation. They can then use their chosen programming language, such as Python, Java, JavaScript, etc., to write the API request code.

Here is an example that demonstrates how to request transaction records for an NFT contract address using Python. In this example, we use the NFT interface “/v2/transactions/{contract_address}” to retrieve the transaction records for the contract address 0x8313f3551c4d3984ffbadfb42f780d0c8763ce94:

import requests

Define the Fantom NFTScan API endpoint and contract address

api_endpoint = "https://api.nftscan.com/v2/transactions"
contract_address = "0x8313f3551c4d3984ffbadfb42f780d0c8763ce94"

Construct the API request URL

url = f"{api_endpoint}/{contract_address}"

Make an HTTP GET request

response = requests.get(url)

Check if the request was successful

if response.status_code == 200:
# Get the returned JSON data
data = response.json()
# Process the returned contract address transaction records
print("Contract address transaction records:")
print(data) # This will print the retrieved contract address transaction records; you can further process or extract information as needed
else:
print("Request failed:", response.status_code)

This code sends an HTTP GET request to the Fantom NFTScan API to retrieve the transaction records for the given contract address. After running the code, developers will receive the transaction records for that contract address and can further process or extract the information as needed.

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

Join the NFTScan Connect Program

Top comments (0)