0
votes

I am new to EOS Blockchain and try to setup a local node and pulling the transactions and Blocks data from Mainnet with the API.

I am following the example API on the EOS's developer site.

import requests

url = "http://host/:port/v1/chain/get_block"

headers = {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}

response = requests.request("POST", url, headers=headers)

print(response.text)

Would appreciate if anyone could provides me the example code in Python. Do I need an account to sync the transactions from Mainnet?

1

1 Answers

0
votes

The example code you posted is already a Python code.

All you have to do is to replace the host/ part to one of the real API endpoints and run the code in Python. If successful, you will receive a JSON format response with the block information.

Most block producers provide the API endpoint. You can see the list here. (Note that some of the endpoints in the list might not be working)

For some of APIs that simply queries for state of the blockchain (or say, querying for transactions), you don't need an account. But if you wish to invoke actions using APIs, like push_action, you are going to have to sign the pay load with the private key of a proper EOS account.

API is just a interface after all, it is just another way of communicating with the blockchain network. When invoking such actions, you might consider using cleos because they provide you simpler interface.