Hi, I have a problem where this script gets stuck in pending. Is it because there are too many requests or something else?
const removeBots = async (arr) => {
try {
for (let i = 0; i < arr.length; i++){
console.log(i)
axios.get('https://api.etherscan.io/api?module=account&action=txlist&address=${arr[i]}&apikey=${apiKey}')
.then(res => console.log(res.data.result.length))
}
console.log("Done");
console.log(walletsFinal);
} catch (e) {
console.log("error", e)
}
}
I would assume you are getting rate-limited.
API Key Rate Limit & Errors
The APIs are free for the community with a maximum rate limit of up to 5 calls per sec/IP with a valid API key.
2 Likes
How do I get around the rate limit? Can you provide me an example of how to get past the limit?
Make 5 or less calls a second or pay is the simple answer.
Or sleep
function sleep (ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function removeBots (arr) {
try {
for (let i = 0; i < arr.length; i++) {
const res = await axios.get('https://api.etherscan.io/api?module=account&action=txlist&address=${arr[i]}&apikey=${apiKey}');
console.log(res.data.result.length))
await sleep(300);
}
console.log("Done");
console.log(walletsFinal);
} catch (e) {
console.log("error", e)
}
}
1 Like
Thanks, it worked! Your explanation really helped me understand everything.
1 Like
system
closed
#6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.