Created
February 18, 2021 03:01
-
-
Save alejoasotelo/d8f11881dd1cee25d652da0d372da1f9 to your computer and use it in GitHub Desktop.
get BSC Tokens info from https://bscscan.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let search = async (name) => { | |
let response = await fetch('https://bscscan.com/searchHandler?term=' + encodeURIComponent(name) + '&filterby=0'); | |
response = await response.json(); | |
return response | |
.map((item) => { | |
item = item.split("\t"); | |
let data = item[2].split("~"); | |
return { | |
name: item[0], | |
address: item[1], | |
contractAddres: data[0], | |
url: data[1], | |
price: data[3], | |
validate: item[4] != "0" | |
}; | |
}); | |
} | |
console.log('Cake', (await search('cake'))[1].price); | |
console.log('Bake', (await search('bake'))[1].price); | |
console.log('Helmet', (await search('helmet'))[1].price); | |
console.log('BDO', (await search('bdo'))[1].price); | |
console.log('SBDO', (await search('sbdo'))[1].price); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't know but you can use coingecko api (it's free) to search tokens. Coingecko has outdated prices (not real time) so you can search tokens with coingecko api's then use web3 to get the real time price from pancakeswap, apeswap, sushiswap or any uniswap fork.
You can get the real time price with this code.