This is not possible with their current API.
Depending on your project, a workaround could be web scraping. Here’s an example using Lua and xpath:
Get all contract addresses for which the given ETH address holds tokens:
function requestContractAddressesForEthAddress(ethAddress)
-- No API method for this (as of Mar 11, 2018), therefore using web scraping
local connection = Connection()
local html = HTML(connection:get("https://etherscan.io/address/" .. ethAddress))
local elements = html:xpath("//ul[@id='balancelist']/li/a")
local addresses = {}
elements:each(function (index, element)
local href = element:attr('href')
local address = string.match(href, "^%/token%/(0x[0-9a-fA-F]+)")
table.insert(addresses, address)
end)
return addresses
end
Get info on a token (name, USD price, divisor to calculate correct amount) for a given contract address:
function requestTokenInfo(contractAddress)
-- No API method for this (as of Mar 11, 2018), therefore using web scraping
local connection = Connection()
local html = HTML(connection:get("https://etherscan.io/token/" .. contractAddress))
local name = html:xpath("//*[@id='address']"):text()
local summary = html:xpath("//*[@id='ContentPlaceHolder1_divSummary']"):text()
local decimals = tonumber(string.match(summary, "Token Decimals:%s+([%d,]+)"))
return {
name = name,
price = tonumber(string.match(summary, "Value per Token:%s+$([%d%.,]+)")),
divisor = math.pow(10, decimals)
}
end
Please be aware that web scraping is considered bad practice. This can break without notice, as it is obviously relying on how the frontend is rendered.
I’ve contacted Etherscan.io support on Mar 12, 2018 to find out if those API calls are on their roadmap. The answer was that providing paid custom APIs services is not their short-term focus.