Connecting to Anyblock API via Postman
In this short tutorial, we will explain how to connect to the Anyblock ElasticSearch API via Postman. The Postman application simplifies testing, querying, and exploring API data. We will show you how to get started analyzing blockchain data with the Anyblock Index using our ElasticSearch API in Postman.
The Anyblock Index makes it easier to read, search and process real-time data from 20+ Ethereum- and Bitcoin-based blockchains. The enriched and human-readable data can be queried via our ElasticSearch API. Get started for free now!
What is Postman?
It often makes sense to test the results of an API request before laboriously incorporating them into a codebase. It makes little sense to integrate test queries directly in a programming language with an ElasticSearch client.
The Postman application is particularly suitable for this purpose. Postman simplifies API development and supports developers at every step of the API lifecycle.
However, Postman is also extremely useful as an API client, allowing consumers of APIs to make requests, inspect the responses, and debug the requests. This makes exploratory testing of APIs much easier.
Postman allows querying different APIs, among others postman supports REST, SOAP, GET, POST, and GraphQL queries. Since we use POST queries for ElasticSearch queries, Postman also supports them.
Postman as an API client supports a variety of features. However, this short guide describes only the essentials to get started with Postman. For more information visit the features page, as well as the documentation.
1. First, you have to go to the Postman website where you can decide whether you want to install the application or use the web interface. Then select the desktop app for your OS. In this tutorial, we will use the MacOS version of Postman.
2. On the following site select “Download the App”
3. After installing the application, launch it and create an account or log in to your account.
4. Now select the workspace and then click on the name of the workspace. If there is no workspace, create one first.
5. Here it is recommended to create a new collection for future queries. These queries can then be saved and named. This way, a collection of interesting and relevant queries can be created.
6. After creating a new collection we have to configure the authorization method. The easiest way to authenticate is to use a Bearer Token.
7. The Bearer Token can be found on your account overview. You first need to log in to your Anyblock account (Login) and go to the “API Keys tab“. Here you can simply copy the API key and paste it into Postman as a token.
8. After inserting the API key and authentication, a new query can now be added. To do this, click on “add a new request” or on the “+” sign.
9. The next steps are used to create the query. First of all, it makes sense to 1. rename the query so that it can be saved with a reasonable name; 2. change the query type from GET to POST; 3. Insert the API URL. 4. if necessary, add the API key to the Authorization (but this should be filled in automatically); 5. change the headers, and 6. insert the query.
10. We always have to provide the appropriate URL. If we want to query Block data, the URL should look like this:
If we want to query tx/event/trace data, the “block” part should be changed to “tx” / “event” …. Like this:
Changing the blockchain, technology, and network allows us to query different blockchains such as xDai:
11. It is also necessary to provide some headers. Copy the headers from the following image:
12. Now switch to the Body tab. In the Dropdown select “JSON” and select “raw”. Input the following query to get all daily last blocks (last block of the day) after Block 100920064.
13. Press the Send button, and in the bottom window, the response should be displayed. You can select different formats to display the response (JSON/XML..) and also pretty format it.
A really cool feature of Postman is the display of the code snippet for the query and sourcing of the data in different languages. To do this, click on the code icon (framed in red in the image above). Then you can select different programming languages and frameworks and Postman will create the query in the respective language.
I hope this short guide helped you to get a solid start in using the Anyblock Analytics API with the help of Postman. Many of Postman’s features have not been covered here, as that would go beyond the scope. Working with Postman for exploratory analysis of data or for testing queries is very simple and intuitive.
Interested or questions?
+49 6131 3272372
Originally published at https://www.anyblockanalytics.com on September 24, 2021.