[SOLVED] Web3 API error while calling /erc20/:address/price

I have a function to get the price of a token every 5s.
const options = {
address: ‘xxxx’,
chain: “bsc”,
exchange: “PancakeSwapv2”,
};
const tokenPrice = await Moralis.Web3API.token.getTokenPrice(options);
Recently it’s always error on the console log, even I still can get the price sometimes.

can you share server subdomain/url?

https://jms66zb8h4zr.moralishost.com:2053/server

I see this in logs:

{"functionName":"getTokenPrice","error":{"message":"Too many requests to Web3API from this particular client, the clients needs to wait before sending more requests. This can be adjusted using Moralis.settings.setAPIRateLimit. Read More: https://docs.moralis.io/moralis-server/web3-sdk/rate-limit.","code":141}

ah i see. I open many tabs and this function is running on each tab so that’s why it’s limited.
How can i increase the rate limit? write this one in the cloud function, right?

Moralis.settings.setAPIRateLimit({
  anonymous:100, authenticated:200, windowMs:60000
})

yes, adding something like that in cloud code

1 Like

Hi @cryptokid,

I have a same issue. I cannot access web3 api with moralis sdk. What can i do for solve this problem?

Thanks.

usually you can get that error when the server has some issues, can you try again?
if still not working, try to restart/update the server

1 Like

Thank you @cryptokid , solved.

1 Like