Guide: How to Develop Web3 Dapp on Base Using NFTScan API?

NFTScan
10 min readJan 5, 2024

--

Base is the latest Layer 2 (L2) network developed by Coinbase using the OP Stack for Ethereum. It aims to address scalability and cost challenges faced by major blockchains like Ethereum. Coinbase describes it as a “secure, low-cost, developer-friendly Ethereum L2 designed to onboard the next billion users into Web3.”

BASE is designed as a standardized, modular, and rollup-agnostic superchain that provides developers with a user-friendly platform to create Web3 applications with enhanced scalability and reduced gas fees. With Coinbase’s support, BASE gains access to the exchange’s product suite, user base, and tools, bridging the gap between CeFi and DeFi.

According to NFTScan data as of December 22nd, the Base network has accumulated a total of 85,852,985 issued NFT assets, 47,108 NFT collections, generated 91,856,607 interaction records, involved 2,592,608 wallet addresses with interactions, and had a total transaction volume of 71,324.82 ETH.

Base NFTScan: https://base.nftscan.com/

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

Sign up for NFTScan Developer

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. In the API documentation, developers can find multiple interface modes to choose from based on their requirements.

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 Base 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 is currently the platform with the largest and most comprehensive NFT Collection library across various blockchains. It supports complete NFT data from 21 blockchains, including Ethereum, Solana, BNBChain, Bitcoin, TON, Polygon, zkSync, Aptos, Linea, Base, Avalanche, Arbitrum, OP Mainnet, Starknet, Scroll, Viction, Fantom, Moonbeam, PlatON, Cronos, and Gnosis. The platform offers a wide range of NFT data, covering various types of assets, and provides a comprehensive set of APIs to access information on ERC721 and ERC1155 assets, transactions, projects, market statistics, and more. Currently, it supports over 60 public interfaces for EVM-compatible chains and also provides a series of interfaces for Solana, Aptos, Bitcoin, and TON. This extensive support caters to the diverse needs of developers seeking to index different types of NFT data.

Base 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 Base to gain comprehensive insights and construct relevant applications. The “Assets” object provides a 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 Base ecosystem. NFTScan continuously aggregates the 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.

Base 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 select the “Get NFTs by attributes” API “/v2/assets/attributes,” primarily to query and retrieve NFTs based on specific attributes of the NFT contract address, sorted in ascending order by token_id. The requested address is 0xfd794258aec191cce5e18e44dfa129431323ce99 with the name “Base Summer Punks.” The attribute name chosen is “Headwear,” and the attribute value selected is “Tiara.”

After selecting the parameters, click on “Try it” to view the retrieved array, which consists of a total of 112 sets of data. This indicates that 112 NFTs meet the specified attribute description. Each set of data includes:

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)

Here we select the “Get transactions by to address” API endpoint, “/v2/transactions/to/{to_address},” to retrieve transaction records with the following to address: 0x00000000000000adc04c56bf30ac9d3c0aaf14dc. The query parameter chosen is the Mint event type.

By clicking “Try it,” the resulting response data will contain all the key data of NFT Mint transactions under this to address. Besides the basic data such as transaction hash, block information, from and to addresses, contract address, and transaction timestamp, it will also include characteristic information of NFT transactions such as token ID and transaction amount.

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 select the “Get NFT collections by account” API, “/v2/collections/own/{account_address}.” We are retrieving all the NFT collections held by the wallet address 0x85447407829fa2deb31e10beec8f6f40981d7f44, specifically those that follow the ERC721 protocol. It can be observed that a total of 14 items are returned.

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 select the Collection Top Holder API, “/v2/statistics/collection/holder/{contract_address}”, to retrieve detailed data and distribution of the top holder for the collection named Base Squad with the contract address 0x3adeb28ed99068cc2d03c506047e6166f27e1c84.

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 is typically used to access various information related to data analysis and statistics on NFTScan Starknet. Interfaces such as Trade Ranking, Mint Amount, and Gas Ranking allow developers or users to query, analyze, and retrieve statistical data related to specific data sets or metrics. They can be used for various purposes, including market analysis, trend tracking, investment decision-making, and understanding the nature of specific data.

Reference: https://base.nftscan.com/

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

Building and calling the NFTScan NFT API is a simple and convenient process. Developers only need to browse the API documentation, find the desired endpoint, and understand information such as the endpoint address, request method, and request parameters. Then, depending on their preference, they can choose a programming language like JavaScript, Python, Java, etc., and use the HTTP request library of that language to send the constructed request to the API endpoint. They can also filter the required headers and parameters. The entire calling process is fast and convenient, and developers can easily follow the instructions in the NFT API documentation to make the call.

Here, we use Chain Overview “/v2/statistics/chain/overview”, to retrieve the overall data on the Base chain. To make the request, we use an HTTP GET request to access the NFTScan API. With Python and the requests library, you can construct the request like this:


import requests

# NFTScan API endpoint
api_endpoint = "https://api.nftscan.com/v2/statistics/chain/overview"

# Make an HTTP GET request
response = requests.get(api_endpoint)

# Check if the request was successful
if response.status_code == 200:
# Get the returned JSON data
data = response.json()
# Process the returned overall chain data
print("Overall data on the Base chain:")
print(data) # This will print the retrieved overall data of the Base chain; you can further process or extract information as needed
else:
print("Request failed:", response.status_code)

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

--

--

No responses yet