SuredBits
Sports & FitnessExploring the Public API Docs of Suredbits
Suredbits is a data provider for blockchain data, and they offer a public API for accessing their data. The API allows developers to create applications that can access blockchain data in real-time. In this blog, we will explore the various APIs available on Suredbits and provide code examples for JavaScript.
API Keys
To use the Suredbits API, you need an API key that you can obtain by registering on their website. Once you have the key, you can use it to make requests to the API.
Block Header API
The Block Header API allows you to retrieve the header of a given block in the Bitcoin blockchain. You can use the following code to retrieve the header of the block with the given block height:
const apiUrl = "https://api.suredbits.com/btc/main";
const blockHeight = 681114;
const response = await fetch(`${apiUrl}/header/${blockHeight}`, {
headers: {
"Content-Type": "application/json",
Authorization: `Token ${API_KEY}`,
},
});
const data = await response.json();
console.log(data);
Block API
The Block API allows you to retrieve the complete information about a given block in the Bitcoin blockchain. You can use the following code to retrieve the block with the given block height:
const apiUrl = "https://api.suredbits.com/btc/main";
const blockHeight = 681114;
const response = await fetch(`${apiUrl}/block/${blockHeight}`, {
headers: {
"Content-Type": "application/json",
Authorization: `Token ${API_KEY}`,
},
});
const data = await response.json();
console.log(data);
Transaction API
The Transaction API allows you to retrieve the complete information about a given transaction in the Bitcoin blockchain. You can use the following code to retrieve the transaction with the given transaction ID:
const apiUrl = "https://api.suredbits.com/btc/main";
const txid = "e073b6f86a7a0dcdc18c6eaf2f9f4d019a8d591d3dbafbe29729f4f9dd1af728";
const response = await fetch(`${apiUrl}/transaction/${txid}`, {
headers: {
"Content-Type": "application/json",
Authorization: `Token ${API_KEY}`,
},
});
const data = await response.json();
console.log(data);
Conclusion
This blog provides you with an overview of the Suredbits public API and code examples for using three of its APIs in JavaScript. With the help of these code snippets, you can retrieve the header of a given block, complete information about a block, and complete information about a transaction. You can explore more APIs on the Suredbits API documentation and integrate them into your applications for real-time blockchain data analysis.