[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?


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?

  anonymous:100, authenticated:200, windowMs:60000

yes, adding something like that in cloud code

1 Like