Help with code: 141, error: 'Rate limit exceeded.'

Can anyone help to understand why I’m being rate limited, and maybe reset my account?

Just started out with Moralis free tier. After first day, started getting the “rate limit exceeded” error.

I’m doing only manual runs of a low-resource Moralis tutorial app.

Following individual instructions from Discord support, and Email support, to post to this forum. Thanks.

there is this info about the rate limits:

but in case that it doesn’t work as planned, you can say a way to reproduce that rate limit that you get with few requests

Thanks for replying. I can’t figure out how I could be exceeding any of the rate limits. I haven’t found anyplace where Moralis shows me my usage, or how exactly I’m exceeding any of the limits?

I’m running this Moralis tutorial/demo app:

Only one user on one chain. After fetching a subset of the user’s token balance and price information, the app quits with the code: 141 error: “Rate limit exceeded.” It doesn’t make sense.

I’m hoping an admin can help. Either explain what the problem is, or reset my account, or something.

do you use pagination there?

Interesting. I am not using pagination. Should I be? Dashboard shows 49 tokens for this single user/single chain. The app uses this query construct to retrieve them:

const query = new Moralis.Query(dbRef)
query.equalTo("address", Moralis.User.current().get("ethAddress"))
query.notEqualTo("balance", "0");
const results = await query.find();

What’s the threshold for number of tokens returned without pagination? I haven’t found that in the docs. Also how to paginate the query?

you get 500 results on first page, you don’t have to use pagination when you have less than 500 results.

how many runs you do before getting the rate limit error?

I get it every single time. Also I have now tried using rest api instead. 429 response for every single get.

Can you give an example of what request are you trying?

The request is:
await Moralis.Web3API.token.getTokenPrice({chain:chn, address: e.get("token_address")})

I wonder if you would get the same results. Starting with a free tier server, grab the app from Use BSC mainnet with an address containing some legit tokens along with plenty of airdropped scamcoins (not hard to find).

I performed maybe a dozen runs on day 1, didn’t notice any rate limiting (although I wasn’t looking for it). Starting with first run on day 2, and ever since, always rate limiting.

I think I may have figured it out. The app blasts out all of the getTokenPrice requests all at once, via map technique:
prices = await Promise.all( (e) => await Moralis.Web3API.token.getTokenPrice({chain:chn, address: e.get("token_address")})

So I did an experiment and instead serialized the requests, waiting for a response from each before sending the next request. Viola, no more 141 Rate Limit errors. (Although it’s now painfully slow.)

The rate limit page mentions 3000 requests/minute. Does that also mean 50/sec? Because it was well within the 3000/min, even taking into account the “3 requests per request” below.

And it states 3 “requests” per each /erc20/{address}/price fetch. So maybe an app should somehow impose self-rate-limiting to the tune of 16.67 getTokenPrice per second?

the app should somehow make a lower number of requests per second, if you do all the requests in parallel then you will get that rate limit error

the app could also use some caching if it needs to do same requests for every user that uses the interface so that it doesn’t do the same requests for every user