📌 Guide: How to Develop Web3 Dapps on Bitcoin Using Runes API

NFTScan
NFTScan
Published in
6 min readJul 5, 2024

Runes, similar to Ordinals, has introduced new possibilities for the Bitcoin network by offering a more efficient tokenization solution compared to BRC-20. Runes is elegantly simple in design, utilizing OP_RETURN in transactions to assign tokens to specific UTXOs with output index, token quantity, and token ID.

As of July 5th, data from Bitcoin-runes NFTScan shows that the total transaction volume of Runes minted on the Bitcoin network is 6,498.45 BTC, with a current market value of 33,201,612,224.75 BTC. There have been a total of 86,850 minted Runes, with 1,036,982 unique wallet addresses interacting with them.

➡️ Data Source: Runes NFTScan | https://btc.nftscan.com/runes​

🛠️ Create 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 Runes 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 blockchains. 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.

🏷️ Runes API Model

The main models include the following three model interfaces, which provide an overall introduction and explanation of key fields in the API, allowing developers to access data and use it to serve the Dapp services they are building.

Assets API: The “Assets” field is crucial in NFTs as it uniquely identifies and describes digital assets. By extracting the “Assets” data of NFTs on the blockchain, developers can gain a comprehensive understanding and build related applications. The “Assets” object provides a unique identifier for digital assets and data on their entire lifecycle, serving as a foundation for developers to understand and utilize NFTs.

Transactions API: The transaction model represents the complete transaction data of an NFT asset on the blockchain, offering developers a thorough overview of the NFT transaction details. This includes NFT mint, transfers, sales, and other transaction activities, enabling developers to deeply understand the flow of assets in the NFT ecosystem. NFTScan continuously aggregates NFT transaction markets and related transaction contract information from various blockchain networks, providing developers with information to track and comprehend the dynamics of the NFT market and build applications and tools based on NFTs.

Collections API: NFTScan collects off-chain data related to NFT Collections, such as descriptions, social media links, and other basic information, through APIs provided by mainstream NFT markets in various blockchain networks. Additionally, the current floor price information is based on centralized data from NFT market order information, which can also be accessed through APIs.

1/ Retrieve Rune Series

  • Get a rune (Retrieve Rune information by Rune name or ID)
  • Search runes (Retrieve a list of runes by applying search filters in the request body. Runes are listed in ascending order by Rune ID.)

For example, we retrieve detailed information about a specific Rune using the Get a rune endpoint, with the path “/btc/rune/{rune}”. The path parameters include RuneName or RuneId as options. In this case, we retrieve information for the Rune DOG•GO•TO•THE•MOON.

2/ Retrieve Rune Balances Series

  • Get owners by rune (Returns a group of owner information related to a specified Rune)
  • Get runes by account address (This interface queries all Rune information owned by the account address)
  • Get single rune by account (This interface returns specified rune information owned by a specified address)

For example, we use the Get owners by rune interface, the interface path is: “/btc/rune/balance/{rune}”, to retrieve owner information of the rune DOG•GO•TO•THE•MOON. Query parameters available for selection include cursor/limit/sort_direction:

3/ Retrieve Rune Transactions Series

  • Get rune transactions by account (This API returns a list of rune transactions for a specific account address, sorted in descending order by timestamp.)
  • Get transactions by rune (This API returns a list of rune transactions for a specific rune, sorted in descending order by timestamp.)
  • Get transactions by transaction ID (Returns a list of rune transactions by applying search filters in the request body. Transactions are sorted in descending order by timestamp.)

For example, we can retrieve details of the Transfer type transactions of DOG•GO•TO•THE•MOON using the API path “/btc/rune/transactions/{rune}”. The query parameter allows you to choose multiple event types (Etch/Mint/Transfer/Sale/Burn) separated by ‘;’.

📝 Build API requests

Once the required Runes API interface and parameters are found in the NFTScan API documentation, developers can write API request code using their chosen programming language, configure API endpoints and request parameters, and use an HTTP request library to send the requests and handle 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, configure request parameters as needed, and finally handle and print the response data.

For example, we are using the Get a rune API endpoint “/btc/rune/{rune}” to retrieve details of the rune DOG•GO•TO•THE•MOON. By making an HTTP GET request to NFTScan’s API, you can build the request like this using Python’s requests library:

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

--

--