2

Take this whale wallet for example:

https://etherscan.io/tokenholdings?a=0xa929022c9107643515f5c777ce9a910f0d1e490c

If you look at the top right, it says Value in USD.

enter image description here

Is there any any API that can help me derive this USD value irrespective of what all ERC20 tokens are in wallet?

APIs so far either need a contract address or return eth valuation

PS:

  • m trying to fetch all this using python's requests library
  • sorry for wrong tags if any
1

Okay, I had a quick look at a dumb (scraping-based) answer to this, but gave up. So this answer is more of an idea of what not to do, or what to take further.


Given you're already using Python, you could have gone one step further and scraped that page with BeautifulSoup. (pip install beautifulsoup4)

However, Etherscan is protected by Cloudflare, so you can't just scrape the page directly. What you can do is use a package such as Cloudscraper. (pip install cloudscraper -U)

However, the page you're looking at is also dynamically generated, so you can't just scrape the HTML. What you can do is use a browser driver such as Selenium to programatically create the page and grab the data. (pip install selenium)

But then... it'd probably be quicker to find an appropriate API! (Caution: I've noticed different chain explorers will index tokens slightly differently, as well as use different sources for prices. You're unlikely to find a different explorer with exactly the same overall price as Etherscan.)

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.