Bitcoin API and its usage

January 24, 2020

To understand the overall meaning of Blockchain API and how it can be applied, one must do a quick recap on the essence of API itself, even though if you are interested in this field, chances are pretty high that you have encountered this concept before.

What is API?

API stands for Application Programming Interface and it aims to present an abstract layer to the interaction with the software program which simplifies the underlying implementation. In simple words, in order to gain access to another developer’s application, API would come in handy without having the need to have the entire code. The keyword I would concentrate here is access.

Moreover, API comes in different types as far as access restrictions go. The access is dependable on the type of process the software follows. Let’s dive in deeper in the bitcoin blockchain one. The main steps that the network consists of would briefly be:

Bitcoin client creates a transaction which is executed in the blockchain and then halts in the memory pool. Miners come across the transaction and join it in the block. Within 10-20 minutes, the transaction is solved and confirmed to be part of the network.

This not only seems complicated, it actually is! Hence, above all, the use of Bitcoin APIs is offered as a network backend to build different applications such as block explorers or wallets. It simply provides the developer or user the leverage needed to customize its requests in order to save time and focus on the overall application logic.



Okay, now you may now wonder: “These are plenty of nice words, but I want to see some action!”

If so, then you are ready to be introduced to the capabilities of Bitcoin API.

How can I use Bitcoin API?

In order to use the endpoints you will need an API key for authentication and providing any data. Be sure to generate an API Key from your Crypto APIs dashboard. Firstly, Click on “Create New API Key”. This can be used in all three: development, QA and production.

Content-Type: application/json

X-API-Key: my-api-key

General Information Endpoint

Secondly, let’s assume you may need general information on the node or the latest block. That is available by GET-ing the base resource. The returned object will contain a litany of information about the blockchain, including its height, the time/hash of the latest block and more.

Block Endpoint

Thirdly, if there is the need to query one particular block, you can also request the block using hash string or integer form (height) as parameters. The returned object will represent information on the block in JSON format, including its height, the number of transactions in it, transaction hashes listed in the canonical order in which they appear in the block etc.

Addresses Endpoint

In addition, API is also implemented for specific retrieval of information in: addresses, wallets, transactions, payment forwarding, webhook notifications and omni layer. GET the information about the address, including its balance in bitcoins and the number of transactions associated with it simply by using the default Address Endpoint. If that address is involved in multisignature addresses, CryptoAPIs provides the Multisig Address Endpoint.

Create Wallets Endpoints

Further on, the Address API can leverage both HD Wallets and normal Wallets, just by using their $NAME instead of $ADDRESS. This will generally have the effect of batching the set of addresses contained in the wallet.

Therefore, Create a new wallet, by POSTing a partially filled out Wallet or HDWallet object, depending on the endpoint. For normal wallets, you must include WALLET_NAME attribute and at least one public address in the ADDRESSES array.

{ “walletName” : ${WALLET_NAME}, “addresses” : ${ADDRESSES} }

For HD wallets, you must include WALLET_NAME, the ADDRESS_COUNT and the PASSWORD attributes

{ “walletName” : ${WALLET_NAME}, “addressCount” : ${ADDRESS_COUNT}, “password” : ${PASSWORD} }

If successful, it will return a Wallet or HDWallet object with the data you requested

Finally, these are a few examples of how endpoints help in integrating the API into your website. We suggest now that you have dipped you toe in the water, you dive in!

Additionally, you can read more on our docs on Bitcoin API.