🔑 Guide: How to Develop Web3 Dapps on Bitcoin Using Ordinals API

NFTScan
NFTScan
Published in
7 min readJun 28, 2024

With the rise of Ordinals in the NFT ecosystem, the Bitcoin network has experienced an unexpected transformation, significantly increasing the frequency and activity of transactions on the chain. As more and more users and developers enter this ecosystem, the transaction volume and miner revenue on the Bitcoin network have significantly increased, driving technological progress and market development in the entire blockchain industry. The rise of Ordinals highlights the NFT market's potential and reveals new possibilities for Bitcoin in the decentralized digital asset space.

According to data from NFTScan, as of June 28, 72,389,094 Ordinals inscriptions (NFT assets) have been minted on the Bitcoin network, generating a total of 524,774,887 on-chain interaction records. 2,630,322 wallet addresses have interacted, with a total transaction volume of 73,192.92 BTC and a current market value of 8,868.51 BTC.

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

Creating an NFTScan Developer Account

Before using the NFTScan API, you need to visit the developer platform and create an account. Visit the NFTScan official website and click on the “Sign Up” button for NFTScan API registration.

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

Sign up

Once logged in, find your unique API KEY on the Dashboard. Visit the API documentation, enter your API KEY in the appropriate place as instructed in the documentation, and you can start using the API service. In the API documentation, developers can find various interface modes based on their needs.

In the Dashboard, developers can also view statistics on their API usage, helping to track historical usage data. Additionally, NFTScan provides each registered developer with 1M CU of API call services for requesting all NFT API interfaces, and the CU never expires until used up!

View Ordinals 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 detailed information on all available API endpoints and parameters, as well as how to construct requests and handle responses. Please read the API documentation carefully and make sure you understand how to use the API to retrieve the data you need. NFTScan API services are dedicated to helping developers improve their NFT data analysis experience.

NFTScan currently boasts the largest and most comprehensive NFT Collection library on the web, supporting full NFT data for Ethereum, Solana, BNBChain, Bitcoin, Mint, and other blockchain networks. The NFT data covers a wide range of assets and types, providing a complete set of interfaces to access ERC721, ERC1155, ERC404, and ERC6551 assets, as well as transaction, project, and market statistics. The platform currently supports over 60 public interfaces for EVM-compatible chains and a set of similar interfaces for Solana, Aptos, Bitcoin, and TON, greatly meeting the needs of developers to index various types of NFT data.

Ordinals API Model

The main components of the Ordinals API model include three key interfaces, each providing information on core fields that developers can utilize to access data and serve their DApp services. This overview aims to help developers understand how to retrieve data and make use of it in their projects.

Assets API: “Assets” are the most crucial data fields in NFT, used to uniquely identify and describe digital assets. By extracting the “Assets” data from NFTs on the blockchain, developers can gain comprehensive insights and build related applications. The “Assets” object provides a unique identifier for digital assets and data on their entire lifecycle, serving as the foundation for developers to understand and apply NFTs.

Transactions API: The transaction model represents the complete transaction data of an NFT asset on the blockchain, providing developers with information on the full lifecycle transactions of NFTs. This includes NFT minting, transfers, sales, and other transaction activities, enabling developers to gain a deeper understanding of the flow and evolution of Ordinals in the Bitcoin ecosystem. NFTScan continuously aggregates NFT transaction market data and related transaction contract information from various blockchain networks, providing valuable insights for tracking and understanding the dynamics of the NFT market. It also helps developers in building NFT-based applications and tools.

Collections API: NFTScan gathers off-chain data related to NFT collections, including descriptions, social media, and other basic information. This data is obtained through APIs provided by the most mainstream NFT markets on various blockchain networks. Additionally, floor price information is based on centralized data from NFT market order information, which can also be accessed through APIs.

1/ Retrieve Assets Series

  • Get NFTs by account (Retrieve NFTs by wallet address)
  • Get minted NFTs by account (Retrieve minted NFTs by wallet address)
  • Get NFTs by collection (Retrieve NFTs by collection name and sort by inscription_id in ascending order)
  • Get single NFT (Retrieve a single NFT)
  • Get NFTs by output (Retrieve NFTs by output)

Get cursed inscriptions (This endpoint retrieves a set of cursed inscription NFTs, sorted by inscription_number in ascending order)

Here we can use the “Get cursed inscriptions” endpoint “/btc/assets/cursed/inscription” to retrieve details of a set of cursed inscription NFTs. Query parameters include cursor, limit, and show_attribute for selection. Some inscriptions that have been successfully engraved do not have an allocated index and therefore cannot be retrieved, hence they are referred to as “cursed inscriptions”. NFTScan also integrates and indexes this data for the convenience of developers.

2/ Retrieve Transactions Series

  • Get transactions by account (This API returns a list of NFT transactions for a wallet address)
  • Get transactions by inscription ID (This API mainly retrieves BTC NFT transactions by Inscription ID)
  • Get transactions by collection (This API returns a list of transactions for a specific collection, sorted in descending order by timestamp)
  • Search transactions (This API returns a list of Ordinals transactions applying search filters in the request body)

Here, we will use the Get transactions by inscription ID interface with the path: “/btc/transactions/{inscription_id}”, to retrieve transaction records for inscription ID 6fb976ab49dcec017f1e201e84395983204ae1a7c2abf7ced0a85d692e442799i0. The query parameter fields available for selection include event_type (transaction event type): Mint/Transfer, separated by ‘;’ for multiple events.

3/ Retrieve Collections Series

  • Get an NFT collection (Retrieve details based on Collection name)
  • Search NFT collections (This endpoint returns information about collection lists by applying search filters in the request body. Collections are sorted in ascending order by create_block_number)

We retrieve the details of an NFT collection named “Bitcoin Frogs” through the API Get an NFT collection “//btc/collections/{collection}”:

Building NFT API Requests

Once you have found the required Ordinals API interface and parameters in the NFTScan API documentation, developers can write API request code using their chosen programming language, set the API endpoint and request parameters, and use an HTTP request library to send the request and handle the API response data. For example, in Python, you can use the requests library to send a GET request, set the API endpoint and request headers, and configure the request parameters as needed, and finally handle and print the response data.

Here, we will use the “Get an NFT collection “//btc/collections/{collection}” to retrieve details of a collection named Bitcoin Frogs. We will make an HTTP GET request to access NFTScan’s API interface. Using Python’s requests library, you can construct the request like this:

import requests

# Set the API endpoint and Collection name
collection_name = "Bitcoin Frogs"
api_url = f"https://api.nftscan.com/v1/btc/collections/{collection_name}"

# Set the request headers
headers = {
"Authorization": "Bearer YOUR_API_KEY", # Replace YOUR_API_KEY with your actual API key
"Content-Type": "application/json"
}

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

# Handle the response data
if response.status_code == 200:
data = response.json()
print("API Response Data:", data)
else:
print("Request failed with status code:", 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

--

--