1

What I need

I need all information of tab "Token Transfers" in token info at etherscan. Exactly in format at the site. For example I want to get all Token Transfers from here https://etherscan.io/token/Decentraland. And question is: How to get this data through api?

What I tried to do

  1. For local solution I got it manually downloading CSV through interface on Etherscan, but I need update data regularly and manual solution is a pain.

  2. I found this answer Obtain token transfer data from an address and it seemed to me as very useful but it didn't give me a token quantity information. Actually, it gave me transactionHash and I tried to get desired result through transactions api-methods (where is used these params module=account&action=txlist), but it didn't get me valid quantity (0.5 eth were showed like value=500000).

Moreover, I think it could be more simplier way to get this info — that's why I'm here.

A bit of code

The python code I used to get transaction info

import requests
url = 'https://api.etherscan.io/api?module=logs&action=getLogs\
&fromBlock=0\
&toBlock=latest\
&address=0x0f5d2fb29fb7d3cfee444a200298f468908cc942\
&apikey='+apikey
request = requests.get(url)
results = request.json()
2

Moreover, I think it could be more simplier way to get this info — that's why I'm here.

You're right, there is a different approach that is probably easier...

One issue is that you're approaching this from a 'legacy', centralised, fragile API mindset - all of the data that Etherscan is using; all of the data that you need is stored in Ethereum. The approach that you are taking could result in your code breaking if Etherscan charge their API, their service goes down or they decide to charge for it etc.

A better approach is to go straight to the source - Ethereum.

I want to get all Token Transfers from here

The Decentraland token is an ERC20 token; that means that we can be sure that every time that a token is transferred that the Transfer event is fired:

event Transfer(address indexed from, address indexed to, uint tokens);

There are libraries such as web3js that let you process all of these events - historically and/or using an event subscription approach.

There are even services such as Infura that can be used to access the Ethereum data (so that you don't have to run your own local node).

And documentation on how to create a web3 enabled web application using Infura.

This is how I would suggest that you approach the problem.

  • Thank you for ways. It's a bit compicated for me yet, because I'm not good in js. But it's cool opportunity to start. – Andrey Pushvincev Mar 14 '18 at 13:16
  • Since the question is tagged with python, you might be interested in web3.py: web3py.readthedocs.io/en/stable – carver Mar 21 '18 at 18:11
  • @carver yeah, actually I'm using it now. And it turned out to install geth node on my pc instead using infura. Infura doesn't support filter method yet. Thank you – Andrey Pushvincev Apr 3 '18 at 14:08
0

I tried the Infura and Web3.py route, but found that there's limitations around the types of methods you can call. Unless you want to run a full node, I think the Etherscan API is a decent route. It's one that I returned to for the time being to analyze token contracts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.