In this short tutorial, we will explain how to connect to the Anyblock JSON-RPC Node API Access and use it in Python with the help of to interact with the Ethereum network. Furthermore, first simple use-cases will be shown.

The Anyblock Node API grants access to both Bitcoin- and Ethereum-based networks like Litecoin, BSC, and xDai using a JSON-RPC API. It relieves you of running a custom node for each chain, as this is handled by Anyblock instead. And archive data, as well as Ethereum block and transaction traces, are also included. Get started for free now!

What does RPC stand for?

RPC stands for Remote Procedure Call. This means that one client executes a procedure or function on another system. In other words, it is a client-server interaction where the client tells the server the procedure to be executed, the server then executes the procedure and sends a response to the client. There are different protocols for RPCs. The Anyblock Node API is a JSON-RPC interface. This means that both the requests and responses are serialized and returned in (the) JSON format.

What is used for? is a Python library that allows users to interact with the Ethereum blockchain. The library makes it possible to develop decentralized applications or to analyze the activities on the blockchain. Furthermore, enables us to interact with smart contracts and to send transactions. All this is possible because can connect to nodes (e.g. the ones operated by Anyblock Analytics as the basis for the JSON-RPC Node API).  These nodes are active on Ethereum and are responsible for storing the blockchain data. This allows us to query the network and for example get the transaction, block, or event data.

How to use with Anyblock JSON-RPC Node API

Step 1
The first step is to create an account with Anyblock Analytics or to log in to your existing one.

Anyblock account login interface

Image: Anyblock account login interface. Click to enlarge.

Step 2

After account creation or login, navigate to the RPC tab in your profile. There you will find all the RPC endpoints for the different networks expanded by your personal API key. In this example, we are working with the Ethereum Mainnet. Therefore, the following URL should be copied.

Anyblock Account RPC tab

Image: URL to copy under the Anyblock Account RPC tab. Click to enlarge.

If Python is not installed on your system yet, it is necessary to install it either directly via the command line or to download the installation file from the web. Subsequently, it is necessary to install the Python package manager pip. Best, open a command line and execute the following command:

python3 -m pip install --user --upgrade pip

Step 4

It is always recommended to create new projects in virtual environments. This way the packages can be managed separately, you can create an isolated Python installation and you do not influence the system Python interpreter. Using virtual environments requires the installation of the “virtualenv” package (for further documentation, visit this tutorial).

python3 -m pip install --user virtualenv
Step 5
Create virtual environment

Image: Create virtual environment command line. Click to enlarge.

Next, we have to create a virtual environment. Therefore we first have to create a new project directory in the user folder:

mkdir anyblock_rpc_example

After creating the directory, we need to change to this folder and create a virtual environment.

python3 -m venv env

Now the environment can be started: 

source env/bin/activate
To close the environment, simply execute the following command:
Step 6

In the following step, we install the package with pip. This allows it to be called and used in Python applications and scripts.

pip install web3
Step 7

Now we are ready to use the Anyblock JSON-RPC Node API with For this purpose, it is necessary to create a Python script in your text or code editor of choice. We use Vim.

Then insert the following source code replacing YOUR-API-KEY-HERE with the API key from your account page:
from web3 import web3

web3 = Web3(Web3.HTTPProvider(''))
print("Client Connected?: ", web3.isConnected())
Next, we import the package and then create the client configured in the web3 variable. The Web3.HTTPProvider method is used to initialize a connection to an RPC-Provider with the JSON-RPC protocol.
The last line shows whether we have successfully connected to the RPC provider, or not. If so, True is output here, otherwise False. We now have successfully connected to the Anyblock JSON-RPC Node API.

To run the script in the command line, change to its directory and type:

Anyblock RPC example

Image: Connecting to the Anyblock JSON-RPC Node API. Click to enlarge.

Following, we will show you some features of and RPCs. Feel free to check out the documentation for more examples.


Information about the latest block, or any other, can be obtained with method web3.eth.get_block(). The output is presented in a Python dictionary (JSON).

# Latest Block 
print("Information about the latest Block: " , web3.eth.get_block('latest'))
Transaction information can be obtained with method web3.eth.get_transaction():
# Transaction Information
print("Information about Transaction : " , web3.eth.get_transaction(“”))
Transaction information

Image: Transaction information. Click to enlarge.

Let’s look at a more detailed example. This is about the POAP token. In this example, we will interact with a smart contract.

First, the ABI (Application Binary Interface) of the POAP token is retrieved using the etherscan API and stored in a variable.

Then a contract instance is created using method web3.eth.contract(address= POAP_CONTRACT, abi = ABI).

Finally, one of the ERC-721 functions is called for the POAP contract instance. With the help of function “tokenURI” and the passing of a token ID, the URI can be found out as well as where the metadata of this particular NFT is stored.

Again here, replace YOUR-API-KEY-HERE with the API key from your account page.

from web3 import Web3
import urllib.request
import json

web3 = Web3(Web3.HTTPProvider(''))
print("Client Connected?: ", web3.isConnected())

# load the ABI
response = urllib.request.urlopen("")
ABI = json.loads( # Loading the Application Binary Interface
# POAP Contract which has tokenURI Method
POAP_CONTRACT = "0x22C1f6050E56d2876009903609a2cC3fEf83B415"

tokenInst = web3.eth.contract(address=POAP_CONTRACT, 

print("Token Metadata for Token 437283: " , tokenInst.functions.tokenURI(437283).call()) # Calling the defined method
Poap token metadata

Image: Retrieving POAP token metadata. Click to enlarge.

We hope that this short tutorial could help you to use the Anyblock JSON-RPC Node API with Python and Of course, there are countless other examples of how to use For those, it is worth having a look at the documentation.

Interested or questions?


Freddy Zwanzger
(Co-Founder & Chief Data Officer)
+49 6131 3272372


Looking to create an Anyblock account? Takes seconds and it’s free!

>> You can also browse related posts below or go back to all posts.

Pin It on Pinterest