getting info from Etherscan API using etherscan-python or Etherscan api
Resources:
Free account on Etherscan
How to get the information
The github gives info on how to access the data in categories:
- accounts:(examples)
get_normal_txs_by_address(address, startblock, endblock, sort)
eth.get_erc20_token_transfer_events_by_address(address, startblock, endblock, sort)
You will get these columns from normal txs:
['blockHash', 'blockNumber', 'confirmations', 'contractAddress', 'cumulativeGasUsed', 'from', 'gas', 'gasPrice', 'gasUsed', 'hash', 'input', 'isError', 'nonce', 'timeStamp', 'to', 'transactionIndex', 'txreceipt_status', 'value']
Balances from multiple addresses
https://api.etherscan.io/api?module=account&action=balancemulti&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a,0x63a9975ba31b0b9626b34300f7f627147df1f526,0x198ef1ec325a96cc354c7266a038be8b5c558f67&tag=latest&apikey=YourApiKeyToken
Get a list of "ERC20 - Token Transfer Events" by Address
https://api.etherscan.io/api?module=account&action=tokentx&address=0x4e83362442b8d1bec281594cea3050c8eb01311c&startblock=0&endblock=999999999&sort=asc&apikey=YourApiKeyToken
Get Block Number by Timestamp
https://api.etherscan.io/api?module=block&action=getblocknobytime×tamp=1578638524&closest=before&apikey=YourApiKeyToken
On the question on decimals
Other resources than Etherscan:
- Coingecko --> we can create an api and request info
- Infura: https://infura.io/ --> they have free tier with up to 100 k requests/day
To use Infura with python, this is an example of code to use in python:
from web3 import Web3
w3 = Web3(Web3.HTTPProvider(projectID))
receipt=w3.eth.get_transaction_receipt(trHash)
-- Once you get the receipt, you need to get the DEX smart contract ABI --
-- ABI basically tells you how does which function look like when you see it in logs --