In the web application I am working on , I need to find the current price of an ERC20 token listed on etherscan . How can this be done using code or some etherscan api ? Any help is appreciated.
To be honest it depends on exchanges. Different exchanges will have different trade value and It depending on demand. Unfortunately there is no common value for token. Usually there will be 1-5 some times 15% price different because it depending on country/exchange/local law/exchange commission etc..,
Yes there will be api is available. Refer below link's
For ERC-20 tokens, I assume you are looking for example how to find the market price of Basic Attention Token (BAT), an ERC-20 token deployed on Ethereum.
Reason being that, token names/symbols are tricky. There can be many "BAT" symbol tokens and say you don't want the hassle of maintaining a mapping of ids.
The CoinGecko API allows you to query token using contract address which is unique to a given token
Knowing the contract address for Basic Attention Token 0x0d8775f648430679a709e98d2b0cb6250d2887ef
As long as you know the ERC-20 contract address, you can query almost any market data so long its supported on CoinGecko in which it is quite likely the case.