How to use NFTScan NFT API to develop Web3 applications on the Base network

Base is the latest Ethereum layer 2 (L2) network developed by Coinbase using OP Stack to solve the scalability and cost challenges faced by major blockchains such as Ethereum. Coinbase describes it as a "secure, low-cost, developer-friendly Ethereum L2 designed to bring the next billion users to Web3." BASE is designed as a standards-based, modular, rollup-agnostic superchain to provide developers with a user-friendly platform for creating Web3 applications with enhanced scalability and reduced gas costs. With the support of Coinbase, BASE has 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 22, a total of 85,852,985 NFT assets, 47,108 NFT Collections, 91,856,607 interaction records, 2,592,608 wallet addresses with interaction, and a total transaction volume of 71,324.82 ETH have been issued on the Base network.

Base NFTScan: 

How to access NFTScan NFT API

Create an NFTScan developer account

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

After logging in, find your own unique API KAY on the Dashboard and copy it. Access the API documentation and enter your API KEY into the corresponding location in the API documentation. According to the guidance of the document, you can start using the API service. In the API documentation, developers can find a variety of interface modes to choose from and choose the most appropriate interface according to their needs.

In the Dashboard, developers can also view statistics on their own API usage to help record historical usage data. Not only that, NFTScan also provides each registered developer with an API call service of 1M CU, which can be used to request all NFT API interfaces, and the CU will never expire until it is used up!

View Base NFT API documentation

After successfully registering a developer account to obtain the API Key, you need to view the NFTScan API documentation. The API documentation contains all API endpoints and parameters that can be used, as well as details on how to construct requests and handle responses. Please read the API documentation carefully and make sure you understand how to use the API to get the data you need. The NFTScan API service is dedicated to helping developers improve the experience of obtaining NFT data analysis.

NFTScan currently has the largest and most comprehensive NFT Collection library on the entire network, supporting Ethereum, Solana, BNBChain, Bitcoin, TON, Polygon, zkSync, Aptos, Linea, Base, Avalanche, Arbitrum, OP Mainnet, Starknet, Scroll, Viction, Fantom, Full NFT data of 21 blockchains including Moonbeam, PlatON, Cronos, and Gnosis. The NFT data covered is comprehensive and diverse. It provides a complete set of interfaces to obtain ERC721 and ERC1155 assets as well as transaction, project, market statistics and other information. It is now supported More than 60 public interfaces for EVM-compatible chains, as well as a batch of interfaces of the same model for Solana, Aptos, Bitcoin, and TON, largely meet the needs of developers for indexing multiple types of NFT data.

Base NFT API model

It mainly includes the following three model interfaces, including an overall introduction and description of some API core fields, so that developers can know how to obtain data and use this information to serve the Dapp service they are building.

Assets API : "Assets" is the most critical data field in NFT, used to uniquely identify and describe digital assets. Developers can   obtain a comprehensive understanding and build related applications by extracting the "Assets" data of NFTs on the Base blockchain. The "Assets" object provides the unique identification of digital assets and data throughout its life cycle, providing a basis for developers to understand and apply NFT.

Transactions API: The transaction model represents the full transaction data of an NFT asset on the blockchain, providing developers with the complete life cycle transaction information of the NFT. Including NFT mint, transfer, sale, and other transaction activities, it provides developers with the opportunity to deeply understand the flow and evolution of NFT assets in the  Base  ecosystem. NFTScan continuously aggregates NFT trading markets and related trading contract information from various blockchain networks. Currently, NFTScan has been included to track and understand the dynamics of the NFT market. It also helps developers build NFT-based applications and tools.

Collections API: NFTScan obtains off-chain data such as descriptions, social media and other basic information related to NFT Collections. NFTScan obtains this information through the API provided by the most mainstream NFT markets in various blockchain networks. In addition, the current floor price information is centralized data based on the order information of the NFT market, which is also available through the API.

Base NFT API retrieval

1/Retrieve Assets Series

  • Get NFTs by account (retrieve NFTs by wallet address)

  • Get all NFTs by account (retrieve all NFTs from the wallet address and group the NFTs according to the contract address. If the total number of NFTs owned by the account address exceeds 2000, the returned NFTs will be limited to less than 2000. In this case, Developers and users can obtain all NFTs owned by the account address by account through paging query requests)

  • Get minted NFTs by account (retrieve minted NFTs of the wallet address)

  • Get NFTs by contract (retrieve NFTs by contract address and sort by token_id in ascending order)

  • Get single NFT (retrieve a single NFT)

  • Get multiple NFTs (retrieve NFTs of multiple contract addresses at the same time)

  • Search NFTs (This interface returns a list of NFT assets by applying a search filter 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 the NFT contract address with attributes, and the 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 the account address, and the NFTs are grouped according to the contract address)

Here we choose  the Get NFTs by attributes  interface  "/v2/assets/attributes"  to query the NFT contract address based on special attributes and sort it in ascending order by token_id. The request address is 0xfd794258aec191cce5e18e44dfa129431323ce99, the name is Base Summer Punks, the attribute name is "Headwear", and the attribute value is "Tiara".

After selecting the parameters, click Try it to view the returned array: a total of 112 sets of data are returned, indicating that there are 112 eligible NFTs under this attribute description, and each set of data contains:

2/ Retrieve Transactions Series

  • Get transactions by account (This interface returns the NFT transaction list of the wallet address)

  • Get transactions by contract (This interface returns the NFT transaction list of the NFT contract address)

  • Get transactions by NFT (This interface returns the NFT transaction list of a single NFT)

  • Search transactions (This interface returns a list of NFT transactions by applying a search filter 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 queried based on the transaction hash list)

Here we choose the interface  Get transactions by to address 

“/v2/transactions/to/{to_address}”,对 to address:

0x00000000000000adc04c56bf30ac9d3c0aaf14dc Retrieve transaction records whose query parameter is Mint event type. The query parameter can select the NFT event type of the transaction (Mint/Transfer/Sale/Burn). Click try it. The result response data contains all the keys of the NFT Mint transaction under this to address. In addition to basic data such as transaction hash value, block information, From and To addresses, contract addresses, transaction timestamps, etc., there is also characteristic information of NFT transactions such as Token ID, transaction amount, etc.

3/ Retrieve Collections series

  • Get an NFT collection (query details based on the contract address of the Collection, including overview and classification of items according to description, basic summary information such as holder distribution, average price, floor price, etc.)

  • Search NFT collections (This interface returns information from a Collection list by applying a search filter in the request body. The Collection is sorted in ascending order by deployment block number)

  • Get NFT collections by account (This interface returns item list information with a given account address, Collection is sorted from high to low by floor price)

  • Get NFT collections by ranking (This interface returns item list information with a given sorting field, Collection is sorted by the given sorting field and the given sorting direction)

Here we choose the interface  Get NFT collections by account 

"/v2/collections/own/{account_address}" Here we retrieve the wallet address as 

From the NFT Collection of all erc721 protocols held by 0x85447407829fa2deb31e10beec8f6f40981d7f44, you can see that a total of 14 items were returned.

4/ Collection Statistics: Collection statistical analysis series

  • Collection Statistics (this interface provides analytical statistical overview data of NFT Collection)

  • Collection Trade Distribution (This interface mainly provides project transaction distribution)

  • Collection Trending Statistics (mainly returns the Trading statistics sorting of an item)

  • Collection Holding Amount Distribution (This interface can return the distribution information of NFT project holdings)

  • Collection Holding Period Distribution (data returns NFT project holding period distribution information)

  • Collection Blue Chip Statistics (blue chip project statistical overview data)

  • Collection Blue Chip List (for a list of blue chip projects involved in this project, please refer to NFTScan Blue Chip Collection)

  • Collection Top Holder (the top holder distribution of the Collection)

Here we choose the interface  Collection Top Holder 

"/v2/statistics/collection/holder/{contract_address}"  retrieves the contract address 0x3adeb28ed99068cc2d03c506047e6166f27e1c84 for the top holder details and distribution named Base Squad. Please refer to:

5/ Account Statistics Series

  • Account Overview Statistics (This interface returns the overview statistical information of the account address, refer to NFTScan Overview)

  • Account Holding Distribution (This interface returns the NFT holding distribution statistics of the account address, refer to NFTScan Portfolio)

  • Account Holding NFT Trending (This interface returns the NFT holdings (or quantity) statistics of the account address, refer to NFTScan Portfolio)

6/ Analytic Statistics Series

This series of interfaces are usually used to obtain information related to data analysis and statistics on the NFTScan  Base  network, such as Trade Ranking, Mint Amount, etc. Such interfaces allow developers or users to query, analyze, and retrieve information related to specific data sets or indicators. statistics. It can be used for a variety of purposes, including market analysis, trend tracking, investment decisions, and understanding the nature of specific data.

7/ Refresh Metadata

  • Refresh NFT metadata

  • Refresh NFT metadata by contract

Interfaces such as Refresh Metadata can help developers or users submit background refresh metadata tasks. After review, the task will refresh the submitted 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 (return the amount information of ERC721 and ERC1155 NFT owned by the account address according to the search list in the request body)

  • Get NFT owners by contract (returns the owner list of ERC721 NFT contract address, NFT is sorted by token_id in ascending order)

  • Get owners by an NFT (returns a list of owners of ERC1155 NFT, sorted by account_address in ascending order)

Construct related NFT API requests

The process of building and calling the NFTScan NFT API is very simple and convenient. Developers only need to browse the API documentation to find the required interface and understand the interface address, request method, request parameters and other information. Then choose a programming language according to personal needs, such as JavaScript, Python, Java, etc., use the HTTP request library of this language to send the constructed request to the interface address, and filter the required header information and parameters. The entire calling process is quick and convenient for developers. It can be called according to the NFT API documentation.

Here we use the interface  Chain Overview "/v2/statistics/chain/overview"  to retrieve the overall data on the Base chain. The HTTP GET request accesses the API interface of NFTScan. Using Python's requests library, the request can be constructed 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)


About NFTScan

NFTScan was founded in early 2021 and is headquartered in Hong Kong. It is the world's leading NFT data infrastructure service provider. It currently supports 21 mainstream projects including Bitcoin, Ethereum, BNBChain, Polygon, Solana, TON, Arbitrum, Optimism, zkSync, Aptos, etc. Blockchain network. The NFTScan team is committed to providing simple and efficient NFT retrieval services to hundreds of millions of Web3 users, providing safe and stable multi-chain NFT indexing services to the new generation of financial technology companies, and using data to promote the prosperity and development of the NFT ecosystem! Currently, NFTScan is providing multi-chain NFT data support to 5000+ developers including CMC, Binance NFT, Bybit, KuCoin, HashKey Group, Mask Network, imToken, Enjin, Coin98, etc.!

Guess you like

Origin blog.csdn.net/NFT_Research/article/details/135159733