DEV Community

Cover image for Guide: How to Use NFTScan’s TON API for NFT Application Development
NFT Research
NFT Research

Posted on

Guide: How to Use NFTScan’s TON API for NFT Application Development

Last week, the NFTScan Developer Platform introduced TON (The Open Network) NFT API services. TON, developed by the Telegram team, is a Layer 1 high-performance public blockchain that uses its TVM virtual machine, making it incompatible with EVM. It achieves lightning-fast processing with a million TPS (transactions per second) through advanced technological architecture. TON offers smart contract and DApp development support, enhances scalability through sharding, and ensures network security through data sharding. It aims to create a fast, secure, and scalable decentralized network, laying a solid foundation for building the Web 3.0 ecosystem.

Currently, TON has seen the issuance of 1,204,487 NFT assets, 10,123 NFT collection projects, 2,888,936 transaction records, 762,453 interacting wallet addresses, and a total transaction volume of 15,083,265 TON. In addition to the 15 EVM-compatible chains, NFTScan also supports four non-EVM blockchains: Bitcoin, Aptos, Solana, and Scroll.

TON NFTScan: https://ton.nftscan.com/chart

Image descriptionTON NFTScan

How to Access NFTScan NFT API

1.Create an NFTScan developer account.
Before using NFTScan’s API, you’ll need to visit the NFTScan developer platform and create an account. Go to the NFTScan official website and click on the NFTScan API “Sign Up” button to register. https://developer.nftscan.com/user/signup

Image description
Sign Up

After logging in, find your unique API KEY on the Dashboard. Copy your API KEY. Visit the API documentation and enter your API KEY in the appropriate place. You can start using the API services according to the documentation’s guidance.

Image descriptionAPI Doc

In the Dashboard, developers can also view statistics on their API usage, helping to keep track of historical usage data. Furthermore, NFTScan provides 1M CU of API calls for each registered developer, usable for all NFT API interfaces, and CU never expires; it’s available until fully consumed.

  1. View TON API documentation.

After successfully registering as a developer and obtaining your API Key, you need to review NFTScan’s API documentation. The API documentation contains all available API endpoints and parameters, as well as detailed information on how to construct requests and handle responses. Carefully read the API documentation and ensure you understand how to use the API to obtain the data you need. NFTScan’s API services are designed to help developers improve their NFT data analysis experience.

NFTScan currently has the most extensive NFT Collection library on the entire network and supports full data from 19 blockchains: Ethereum, Solana, BNBChain, Bitcoin, TON, Polygon, zkSync, Aptos, Linea, Base, Avalanche, Arbitrum, Optimism, Scroll, Fantom, Moonbeam, PlatON, Cronos, Gnosis, and Scroll. It covers a wide range of NFT data types and provides a complete set of interfaces for obtaining ERC721 and ERC1155 assets, transactions, projects, market statistics, and more. Now it supports more than 60 public interfaces for EVM-compatible chains and a batch of similar models for Solana, Aptos, Bitcoin, and TON, significantly meeting developers’ demands for indexing various types of NFT data.

Image description

TON API mainly consists of five types of interfaces:

Type 1: Retrieve Asset

Get NFTs by account: /ton/account/own/{account_address}
Get all NFTs by account: /ton/account/own/all/{account_address}
Get minted NFTs by account: /sol/account/mint/{account_address}
Get NFTs by contract: /ton/assets/collection/{contract}
Get single NFT: /ton/assets/{token_address}
Get multiple NFTs: /ton/assets/batch

These APIs offer developers a simple and efficient way to obtain various NFT data, including retrieving relevant NFT lists based on user accounts or contract addresses, getting detailed information about a single or multiple NFTs, and accessing basic data such as metadata without extracting and processing raw on-chain data. These interfaces reduce the complexity of on-chain data, significantly lowering the difficulty of obtaining detailed NFT data and serving as a vital foundation for developing DApps and data analysis applications based on TON NFTs.

Type 2: Retrieve Transaction Series

Get transactions by account: /ton/transactions/account/{account_address}
Get transactions by contract: /ton/transactions/collection/{contract}
Get transactions by NFT: /ton/transactions/{token_address}

These interfaces provide easy access to various transaction data related to TON NFTs that occurred on the blockchain, including transaction histories for NFTs, block heights, timestamps, token IDs, transaction prices, transaction types, and more. These APIs offer raw on-chain event data, and developers can access the necessary TON NFT transaction data without the need to extract it themselves. Once this data is obtained, developers can use it for data analysis, trading systems, and other applications.

Type 3: Retrieve Collection

Get an NFT collection: /ton/collections/{collection}
Search NFT collections: /ton/collections/filters

By specifying the collection address or filtering criteria, developers can search for NFT collections that match specific conditions. These interfaces allow developers to get an overview of any project and its list of NFT collections. Based on this information, they can develop applications, such as data analysis platforms that can provide information about popular NFT collections.

Type 4: Statistics Series

Trade Ranking: /ton/statistics/ranking/trade
Collection Statistics: /ton/statistics/collection/{collection}

The Trade Ranking interface helps developers quickly obtain ranking data for NFT projects in the TON ecosystem. This interface returns a list of data sorted in descending order based on filtering conditions such as transaction volume. Using this ranking list, developers can clearly see the most active NFT projects in terms of trading, assess the liquidity of different projects, and determine potential projects or those that need further research.

You can review the ranking data statistics, which can be filtered by parameters like time (15m/30m/1h/6h/12h/1d/7d/30d) and sorting fields (volume/sales/floor_price/average_price) to find the NFT trading ranking data that suits your needs.

Type 5: Refresh Metadata: /ton/refresh/metadata

This interface is used to submit a background task to refresh the metadata of specified NFT assets.

Image description

Making Relevant API Requests

1/ Get NFTs by contract:

Through the NFTScan TON API, developers can use this interface to retrieve a set of NFT information listed under a specific NFT contract address. The NFTs are sorted in ascending order by token address.

Here, we input the contract address:

EQCA14o1-VWhS2efqoh_9M1b_A9DtKTuoqfmkn83AbJzwnPi

Image description

Click “Try it,” and it will return detailed information about all the NFT assets under this contract address. Data is returned in default paginated format, and you can control the number of items per page and page number using the “limit” and “cursor” parameters. The returned data includes details for each NFT, such as token address, token ID, metadata, and owner address. You can dynamically fetch data with different granularity to build applications for displaying NFT details or extracting data for further analysis.

You can see that there are a total of 102,185 items under this contract address, and the data is displayed as follows:

Image description

2/ Get transactions by account:

By calling this interface and inputting an account address, you can easily obtain all the historical NFT transfer transaction data in which the wallet address is either the sender or the receiver. You can also specify an NFT contract address in the query parameters. The data includes block height, timestamp, token ID, transaction price, transaction type, and more.

Here, we are querying the address:

EQBwPvcqbRCICLo3cWOiFPO1QdmNZBcYAfpvwEaxjr9hKP-R

Image description

3/ Trade Ranking:

This interface helps developers quickly access ranking data for NFT projects in the TON ecosystem. The interface returns a set of data sorted in descending order based on filtering conditions such as transaction volume. Using this ranking list, developers can clearly see the most active NFT projects in terms of trading, assess the liquidity of different projects, and determine potential projects or those that require further research.

You can check the query parameters such as “time” (15m/30m/1h/6h/12h/1d/7d/30d) and sorting fields (volume/sales/floor_price/average_price) to filter NFT trading ranking data. Refer to TON NFTScan Trading for detailed statistics.

Image description

Building Relevant API Requests

Once developers have found the required TON API interfaces and parameters in the NFTScan API documentation, they can write API request code using their chosen programming language (e.g., Python, Java, JavaScript). Here are some general steps, along with an example in Python, to demonstrate how to write TON API request code:

1.First, import an HTTP request library for your chosen programming language. In Python, the requests library is commonly used.
2.Define the basic URL for the NFTScan API and the required parameters. Find the appropriate interfaces and parameters in the API documentation.
3.Add parameters to the basic URL and endpoint to construct the complete API request URL.
4.Use the HTTP library of your chosen programming language to make a request, typically a GET request.
5.Check the HTTP response’s status code; a status code of 200 usually indicates a successful request.

Image description

These general steps can be applied to interact with the NFTScan API or other similar APIs. You can build and send requests based on the information provided in the API documentation and handle the returned data accordingly.

Happy NFT applications development!

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

Top comments (0)