Help with api rate limting

So I want to create a menu that shows a list of your friends with their status.

The issue is that I get a rate limited: HTTP 429.

I don’t know how I would go about solving this problem…

This is the current code:


local GetFriends = Player:GetFriendsOnline()
local GetFriendsAsync = PlayerService:GetFriendsAsync(Player.UserId)

And after about 2-4 updates it gets rate limited!

How many times are you calling it per minute?

I don’t know, since that will depend on the user, it will be in a menu and everytime you open it, it will refresh.

You are sending too many requests to the web server that is hosting the api, You can avoid hitting the rate limits by setting up intervals.

Maybe only have it refresh every 60 seconds per player? Here’s some structural logic you can apply to your code and it might stop it from hitting the limit altogether:

  • Don’t call GetFriendsAsync until the player opens their menu, specifically the friends page in the menu if that exists.
  • After calling GetFriendsAsync, set a 60 second timer and don’t allow another GetFriendsAsync call until that 60 seconds has passed. You can do this by creating a simple debounce system.