Guide | How to Quickly Create an NFT Application Using the NFTScan BTC API?

NFT Research - Jul 28 '23 - - Dev Community

Bitcoin NFT, also known as the Bitcoin Ordinals protocol, is a method of creating digital assets on the BTC blockchain. In January 2023, software engineer Casey Rodarmor officially released the Ordinals NFT protocol on the Bitcoin blockchain, allowing users to create unique NFTs on the smallest unit of Bitcoin, the Satoshi (SAT). The main purpose is to assign a unique identity to each satoshi, enabling users to track them using an ordinal numbers system.

Using the Ord software, this protocol adds data to these sats and allows users to track them based on the ordinal numbers system. In other words, the Ordinals protocol represents Bitcoin's smallest unit, sats, in the form of NFTs, giving them significant trading and collectible value. In a way, it has created a new dimension of value for the smallest unit of Bitcoin, serving as a form of scaling for the cryptocurrency. Since the creation of the Ordinals protocol, users have been able to engrave information on the Bitcoin blockchain, including text, images, audio, and video, thereby creating NFTs on the BTC chain.

Since the release of Ordinals, an increasing number of people have started minting Bitcoin NFTs. The ecosystem is still in its early stages, but the popularity and quantity are growing rapidly. According to data from Bitcoin NFTScan as of July 27th, a total of 19.79 million NFT assets have been engraved on the Bitcoin network, with 605,000 Bitcoin wallet addresses holding NFT assets. NFTScan has currently indexed and recorded 1,534 NFT Collections on the Bitcoin network.

Developers can quickly create related applications, such as NFT marketplaces, based on NFTScan's Bitcoin NFT API.

Bitcoin NFTScan: https://btc.nftscan.com/

Image description

How to access the NFTScan NFT API:

Create an NFTScan Developer Account Before using the NFTScan API, you first need to visit the developer website and create an account. Go to the official NFTScan website (https://developer.nftscan.com/user/signup) and click the "Sign Up" button for NFTScan API registration.

Image description

After logging in, navigate to your Dashboard where you can find your unique API KEY, which you should copy. Access the API documentation and input your API KEY in the designated location as instructed in the documentation. With the guidance provided in the documentation, you can begin using the API service. Within the API documentation, developers can explore various interface modes to choose the most suitable one according to their specific needs.

Image description

In the Dashboard, developers can also view statistical data about their API usage, helping them keep track of their historical usage. Moreover, NFTScan provides each registered developer with 1M CU (Compute Units) of API call service, which can be used for requesting all NFT API interfaces, and the CU never expires, allowing developers to use it until it's fully consumed!

Viewing the Bitcoin API Documentation After successfully registering for a developer account and obtaining an API Key, you need to access the NFTScan API documentation. The API documentation contains all available API endpoints and parameters, along with detailed instructions 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 obtain the data you need. The NFTScan API service is dedicated to helping developers enhance their experience in obtaining and analyzing NFT data.

Currently, NFTScan has the largest and most comprehensive NFT Collection library across 15 blockchains, including Ethereum, Solana, BNBChain, Bitcoin, Polygon, Aptos, Linea, Avalanche, Arbitrum, Optimism, Fantom, Moonbeam, PlatON, Cronos, and Gnosis. It covers a wide range of NFT data with abundant variety, offering a complete set of interfaces to retrieve ERC721 and ERC1155 assets, transaction details, project information, market statistics, and more. NFTScan now supports over 50 public interfaces for EVM-compatible chains, as well as a batch of similar interfaces for Solana, Aptos, and Bitcoin, significantly fulfilling the diverse needs of developers in indexing various types of NFT data.

Image description

The Bitcoin API primarily consists of the following three models: Asset Model, Transaction Model, and Collection Model, which include an overall introduction and explanation of some core fields. This enables developers to understand how to utilize this information to serve their DApp services under construction.

Assets API: Assets are the most crucial data fields of NFTs, used to identify and describe digital assets. Developers can extract key data of NFTs on the BTC blockchain to gain a comprehensive understanding and build relevant applications. The Assets object provides a unique identification of digital assets and their full lifecycle data, forming the foundation for developers to comprehend and utilize NFTs.

The core data model in NFTScan's BTC API is Assets, representing each unique digital project. It mainly includes fields such as inscription ID, inscription number, collection name, transaction hash, block number, mint price, owner, and other comprehensive data.

Transactions API: The transaction model represents the full transaction data of an NFT asset on the blockchain, providing developers with NFT's full lifecycle transaction data. NFTScan continuously collects NFT transaction market and contract information on various blockchain networks, analyzing and interpreting contract source codes and transaction logs, and incorporating them into its data parsing logic. According to NFTScan data, as of the end of July, there are a total of 2,126,014,489 records on the main 15 chains, and comprehensive information on 150 transaction markets on 14 major chains has been included, with their transaction data continuously being collected.

Users can use the Transactions API to retrieve complete transaction records, action logs, and current ownership information of any NFT asset, enabling comprehensive tracking of NFTs and providing reliable data sources for developers to analyze NFT transaction characteristics, price trends, and circulation paths.

Collections API: NFTScan obtains off-chain data related to NFT Collections, including descriptions, social media, and other basic information. NFTScan obtains this information through APIs provided by the most popular NFT markets in various blockchain networks. Additionally, the current floor price information is centralized data based on order information from NFT markets, which is also accessible via API.

NFTScan continuously tracks newly emerging NFT projects and rapidly acquires their off-chain data information publicly available on various trading platforms. This information is then opened to developers through the Collections API, enabling developers to obtain essential information about projects' off-chain descriptions, holders, and transaction activities without having to aggregate data from different platforms manually. This integration can be easily done by accessing the Collections API for the application.

Query related API:

Get NFTs by collection: Through the NFTScan BTC API, developers can use the "Retrieve Assets" endpoint "/btc/assets/collection/{collection}" to retrieve a set of NFTs belonging to the NFT Collection specified by its name. The API will return NFTs that are associated with the given NFT contract address and sort them in ascending order based on the inscription_id.

Image description

By entering the name of the NFT Collection and clicking "Try it," the API will return detailed information about all NFT assets under that collection. The data is paginated by default and can be controlled using the limit and cursor parameters to specify the number of items per page and navigate between pages. Once you have obtained all the NFT data, it can be used for display, analysis, or other application scenarios. This API allows for the convenient batch retrieval of all NFT data within a specific NFT project, providing powerful support for building NFT applications. The displayed data is as follows:

Image description

Get cursed inscriptions: This API returns a set of cursed inscriptions NFTs, sorted in ascending order by the inscription_number. The Bitcoin NFT protocol Ordinals has been upgraded to version v0.6.0, with the most notable update being the support for "cursed inscriptions." Some successfully engraved inscriptions were not assigned an index number by the indexer, making them inaccessible, hence referred to as "cursed inscriptions." NFTScan has integrated and recorded their data, providing convenient access for developers to use.

Image description

Get transactions by inscription ID: This API primarily retrieves BTC NFT transactions based on the inscription ID of the NFT. The API endpoint is "/btc/transactions/{inscription_id}". Developers can easily obtain the full lifecycle transaction data of a specific NFT from minting to all transfers. This enables developers to achieve historical tracing and analysis of NFT transactions.
The query parameter field available for selection includes event_type: Mint/Transfer, using ';' to separate multiple events.

Image description

Building relevant API requests:

Once developers have found the required BTC API endpoints and parameters in the NFTScan API documentation, they can write API request code using their chosen programming language. Accessing NFTScan's API documentation will provide the following information:

  • API Endpoint: The URL address for API requests, typically starting with HTTP or HTTPS.
  • Supported Request Methods: Common request methods include GET, POST, PUT, DELETE, etc., used to specify the type of operation on the API.
  • Request Parameters: API requests may require passing some parameters, which can be URL parameters, data in the request body, etc., to specify the specific content of the request.
  • Response Data: After a successful API request, the server will return corresponding data, usually in JSON or XML format.

In the chosen programming language, developers can use HTTP libraries or API client libraries to send HTTP requests and include the required parameters and header information in the request. For example, Python can use the requests library, while JavaScript can use axios or fetch libraries.

The general process of writing API request code is as follows:

  1. Import the necessary HTTP library or API client library.
  2. Build the API request URL, including the endpoint and parameters (if any).
  3. Set the request method, request headers (if authentication is required), and request body (if it is a POST or PUT request).
  4. Send the API request and receive the server's response.
  5. Parse the response data and handle it accordingly.

When writing API request code, be sure to refer to the NFTScan API documentation to ensure correct usage of API endpoints, parameters, and authentication methods to successfully interact with NFTScan and obtain the required data.

For example, to build an API request to retrieve Bitcoin Frogs NFT data, after consulting the NFTScan BTC API documentation, use the endpoint "Get NFTs by collection: "/btc/assets/collection/{collection}".
Use an HTTP GET request to access NFTScan's API endpoint and pass the required parameters. For instance, using Python's requests library, you can construct the request as follows:

Image description

In the above code, we first constructed the complete API request URL and then used the requests.get() method to send a GET request and retrieve the returned NFT data from the response (assuming the NFT data is returned in JSON format). Developers can further process and analyze the obtained NFT data according to their needs.

Conclusion

Not limited to the Bitcoin NFT API, developers can flexibly access the rich NFT data resources provided by NFTScan based on their application requirements. NFTScan's NFT API offers comprehensive, real-time, and reliable core NFT data, allowing developers to quickly obtain the desired NFT data, greatly simplifying and accelerating the development process. Developers can freely combine these APIs according to their business scenarios, building NFT applications or solutions that meet their specific needs.

NFTScan continues to optimize the API and introduce more advanced features to further enhance developers' work efficiency and reduce development costs. It provides professional and reliable NFT fundamental data support, allowing developers to focus more on the innovation of their applications.

Image description

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

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .