How To Connect to Bitcoin Node

Hello everyone, today we’re going to demonstrate what is under the hood of GetBlock’s API nodes connection instruments.

Let’s try reaching the Bitcoin node via GetBlock API and check the header of the Bitcoin block. Block header represents the encrypted summary of the information about this or that block; the blockchain algorithm needs it to find the block.

We’re going to experiment with Bitcoin, a flagship cryptocurrency and the earliest of all blockchain in existence. It was proposed in 2008 by a pseudonymous developer Satoshi Nakamoto as a first implementation of the blockchain concept itself.

Let’s choose the Bitcoin endpoint on GetBlock. To achieve this goal, we need to open the ‘Shared Nodes’ section in Main Menu.

In the first row, we see ‘Bitcoin’, ‘Ethereum’ and ‘Binance Smart Chain’ blockchains. Let’s open the first one.

Bitcoin’ dashboard GetBlock

In the ‘Bitcoin’ dashboard, we need to find the URL of its endpoint and copy it.

In parallel, let’s launch Postman terminal, a user-friendly instrument for experiments with API requests. Then, let’s paste the address of the endpoint to the corresponding field.

Postman terminal

To continue our experiment, we need to specify the parameters of our API request. To set the ‘VALUE’ properly, we should copy the number of our API key. GetBlock utilizes this public number to identify the accounts of users and their requests.

To do so, we need to open the ‘Your API settings’ segment. We copy the API public address from the black box and paste it into the ‘VALUE’ field.

x-api-key

Once this is done, we should set the parameters of our request in the ‘Headers’ tab. We should set ‘x-api-key’ as the type of our key.

Once API data is filled, let’s set the rest of the parameters in the ‘Body’ tab. Please choose ‘RAW’ as a type of data requested — as we need the unprocessed ‘raw’ data from the Bitcoin blockchain — and JSON as data format.

Main menu

To fill the main body of our request, we need to open the GetBlock website main page once again by clicking ‘Back to the site’. In the ‘Main menu’, choose the ‘Documentation’ tab.

In the drop-down menu ‘Available Nodes Methods’ in the left section of the screen. Find the Bitcoin (first point) and choose ‘getblockheader’ command.

As we know already, block header is a crucial data set which is unique for different blocks. Choose the ‘getblockheader’ command and copy the code of request. We need the code part between ‘json rpc’ and ‘getblock.io’ strings.

Code the text of request to the Postman ‘body’ field. To authorize the request we need to choose ‘POST’ as the type of request (‘GET’ type is set by default).

To send a request you should click the ‘SEND’ button. The result of the request will be displayed in the lower field. All data about the latest mined block will be displayed here.

That’s it, enjoy our tutorial and have a great day!

There’s also a video version of it.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
GetBlock

GetBlock is a service that provides fast and easy API connection to blockchain nodes of 40+ cryptocurrencies.