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

zkSync was created by Matter Labs and is a user-centric zk rollup platform. It is a layer 2 scaling solution for Ethereum. It uses zk-rollups as the scaling technology. Like optimistic rollups, zk-rollups will aggregate Transactions on the Ethereum mainnet and submitting the transaction proof to Ethereum. zkSync Era is a blockchain ecosystem based on zkSync technology, aiming to achieve high-performance, low-cost smart contracts and blockchain applications. The zkSync Era is fully open source and the code can be viewed, modified and forked freely, zkSync 2.0 is now zkSync Era, and zkSync 1.0 is now zkSync Lite.

According to NFTScan data, as of November 7, a total of 16,207,719 NFT assets, 78,973 NFT Collections, 22,020,416 transaction records, 2,565,626 interactive wallet addresses, and a total transaction volume of 566,890.33 ETH have been issued on the zkSync Era network.

zkSync NFTScan:

https://zksync.nftscan.com/

picture

How to access NFTScan NFT API

Create 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.

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

picture

After logging in, find your own unique API KAY on the Dashboard and copy it. Visit the API documentation and enter your API KEY into the corresponding location in the API documentation. According to the guidance of the documentation, 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.

picture

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 zkSync Era API 文档

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, Optimism, Scroll, Fantom, Moonbeam, PlatON, Cronos , Gnosis 19 blockchain full NFT data, covering a wide range of NFT data, providing a complete set of interfaces to obtain ERC721 and ERC1155 assets as well as transaction, project, market statistics and other information, currently supports more than 60 EVM-specific The public interface of the compatible chain, 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.

picture

zkSync NFT API model

It mainly includes the following three model interfaces, including an overall introduction and description of some core API 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 NFT on the zkSync Era 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, providing developers with in-depth understanding of the flow and flow of NFT assets in the zkSync Era ecosystem opportunities for evolution. 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 APIs 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.

picture

zkSync NFT API connection

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

  • 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 use Get all multi-chain NFTs by account The interface is

 "/v2/assets/chain/{account_address}" to retrieve the assets held by a single or multiple chains under a certain wallet address NFT details, path parameters include account_address, query parameters include erc_type (erc721/erc1155)/chain (15 evm compatible chains supported by NFTScan)

Here we are querying 

Details of eth and zkSync NFT held under 0xeb71d303a6cee4ba28e9c5adc1af308892fb681b.

picture

Click Try it, the data is returned as follows, mainly including basic information query of eth and zkSync NFT assets held under the address:

picture

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 pass Get transactions by account

This interface "/v2/transactions/account/{account_address}" retrieves NFT transaction records on the zkSync network of a certain wallet address. The query parameter can select the NFT event type of the transaction (Mint/Transfer/Sale/Burn), use ';' to separate multiple events.

Similarly here we search 

NFT transaction records under the address 0xeb71d303a6cee4ba28e9c5adc1af308892fb681b. According to the event type of Mint, the result response data contains all key data of Mint for all Items of the address, such as transaction hash value, From and To addresses, block information, gas consumption, transaction timestamp and other basic data and other characteristics of NFT transactions. information.

picture

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 for a Collection list sorted by deployment block number in ascending order by applying a search filter in the request body)

  • 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 use the interface Get NFT collections by account “/v2/collections/own/{account_address}” to retrieve the address 

Details of the NFT Collection held by 0xeb71d303a6cee4ba28e9c5adc1af308892fb681b, the returned data contains 20 pieces of data:

picture

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 use the interface Collection Trending Statistics 

"/v2/statistics/collection/trending/{contract_address}" mainly returns the Trading statistics sorting of an NFT Collection, please refer to NFTScan Trending:

https://zksync.nftscan.com/0xad8a95b347b96274940229754dfd8569f2b72bf4

picture

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 zkSync Era network, such as Trade Ranking, Mint Amount, etc. These 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.

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

picture

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 that NFTScan has reached)

  • Get NFT amount by account (return the amount of ERC721 and ERC1155 NFT owned by the account address based on 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 an ERC1155 NFT, sorted by account_address in ascending order)

Construct related NFT API requests

It is very simple and convenient to build NFTScan-related NFT data requests. Developers only need to find the required interface in the API document and view the interface address, request method, request parameters and other instructions. Then choose a programming language according to your own needs, such as JavaScript, Python, Java, etc., use the HTTP request library of that language to send a constructed request to the interface address, and filter the necessary header information and parameters. The entire calling process is fast and convenient, and developers can implement it completely according to the documentation.

For example, we request 

0xeb71d303a6cee4ba28e9c5adc1af308892fb681b 

Detailed information about the NFT Collection held, using the interface:

"/v2/collections/own/{account_address}", HTTP GET request accesses NFTScan's API endpoint, using Python's requests library , the request can be constructed like this:

import requests

# Define the API URL with address parameter
api_url = "https://api.nftscan.com/v2/collections/own/0xeb71d303a6cee4ba28e9c5adc1af308892fb681b"  

# Send GET request
response = requests.get(api_url)

# Check status code  
if response.status_code == 200:

  # Request succeeded, print response data
  data = response.json()
  print(data)
  
else:
  # Request failed
  print("Request failed with status code:", response.status_code)

The main steps include: constructing the API interface URL, filling in the account_address parameter, and using the requests library to send a GET request; checking the return status code, 200 means the call is successful; if the request is successful, the returned JSON data can be processed; error handling is also done, printing 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 and currently supports Bitcoin, Ethereum, BNBChain, Polygon, Solana, TON, Arbitrum, Optimism, zkSync, Base, Scroll 19 mainstream blockchain networks including , Aptos, etc. 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 working for MetaMask, CMC, Binance NFT, Bybit, KuCoin, HashKey Group, Mask, imToken, Enjin, Coin98, etc. 5000+ developers provide multi-chain NFT API data services!

Guess you like

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