HTTP 429 (Too Many Requests)?

Hi there,

I’ve got this script that gets Group Members via HTTP but i’m getting the Error code: HTTP 429 (Too Many Requests) Note it’s not always but its about 50/50

Script:

local part = game.Workspace.Part
local part2 = game.Workspace.Part2

local GroupService = game:GetService(“GroupService”)
local Players = game:GetService(“Players”)
local HttpService = game:GetService(“HttpService”)
GroupID = nil

local function playerAdded(player)
wait(2)
local groups = GroupService:GetGroupsAsync(player.UserId)
for _, groupInfo in pairs(groups) do
for key, value in pairs(groupInfo) do
if groupInfo.IsPrimary then print(groupInfo.Name,groupInfo.Id)
GroupID = groupInfo.Id
part2.Decal.Texture = (groupInfo.EmblemUrl)
part.SurfaceGui.GroupNameText.Text = (groupInfo.Name)
end
end
end
end

Players.PlayerAdded:Connect(playerAdded)
wait(5)
local groupData = HttpService:JSONDecode(HttpService:GetAsync(“https://groups.rprxy.xyz/v1/groups/“..GroupID..””))
part.SurfaceGui.MembersText.Text = (groupData.memberCount)

Thanks,

1 Like

Too many requests means it happens too many times

This means that you’re sending to many request to the Web Server that is hosting the api.

You could avoid hitting rate limits by making a request at certain intervals.

This is nothing you can fix rather than have good practices, and only make requests when you need too.

Although your rate-limit may reset in about 15 minutes -1h Somewhere in that range. And you’ll be good. As this is the time most Api’s use when setting their rate limits.

Yeah i understand the error but surely its not sending to much?, It should only run once a Player has joined right?

Lets pretend you have 1,000 active players. That’s a LOT of http requests. This isn’t the correct way to go about things

First, create a web server. I recommend https://repl.it

then send the http request to your own server

GET request to https://domain.com/membercount

the code for the server:

const express=require("express")
const app=new express()
const fetch=require("node-fetch")
const GROUP_ID=1
var mc=0
app.get('/',(req,res)=>{
res.send("meow")
})
fetch(`https://groups.roblox.com/v1/groups/`+GROUP_ID).then(res=>res.json()).then(res=>{
mc=res.memberCount

})

setInterval(function(){
fetch(`https://groups.roblox.com/v1/groups/`+GROUP_ID).then(res=>res.json()).then(res=>{
mc=res.memberCount

})


},10000)
app.get('/membercount',(req,res)=>{
res.send(`{"mc":${mc}}`)
})

app.listen(3000)

(its nodejs)

3 Likes

This happens to me as well, and only simply from having too much assets in my experience, is there a way to slow load the items?

u gotta pay money to keep it running for the entire month glitch.com is free however if u send 4000 requests an hour it rate limits

I’ve had this issue before, in my case here I needed to retrieve a person’s outfit from their ID and I constantly kept getting the “too many requests” error.

My script loops through 2 pages of the players outfits and checks if its a bundle or not before using them further, i used task.spawn() functions to load both pages in advance, see what you can learn from it.

-- lv_ver
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")

local GetPlayerOutfitsEvent = ReplicatedStorage:WaitForChild("GetPlayerOutfitsEvent")

local function GetPlayerOutfits(userid)
	local ProxyUrl = "https://avatar.roproxy.com/v1/users/%d/outfits?page=%d"
	local Outfits = {}

	local function fetchPage(PageNumber)
		local RequestUrl = string.format(ProxyUrl, userid, PageNumber)
		local Success, Result = pcall(HttpService.GetAsync, HttpService, RequestUrl)

		if Success and Result then
			local success2, result2 = pcall(HttpService.JSONDecode, HttpService, Result)
			if success2 and result2 and result2.data then
				local pageOutfits = {}
				for _, outfitItem in ipairs(result2.data) do
					if outfitItem["isEditable"] then
						table.insert(pageOutfits, {
							id = outfitItem["id"],
							name = outfitItem["name"]
						})
					end
				end
				return pageOutfits
			end
		end
		return nil
	end

	local outfits1, outfits2
	local success1, success2

	task.spawn(function()
		outfits1 = fetchPage(1)
		success1 = outfits1 ~= nil
	end)
	task.spawn(function()
		outfits2 = fetchPage(2)
		success2 = outfits2 ~= nil
	end)

	while outfits1 == nil or outfits2 == nil do
		task.wait(0.1)
	end

	if success1 then
		for _, outfit in ipairs(outfits1) do
			table.insert(Outfits, outfit)
		end
	end
	if success2 then
		for _, outfit in ipairs(outfits2) do
			table.insert(Outfits, outfit)
		end
	end

	return Outfits
end

GetPlayerOutfitsEvent.OnServerEvent:Connect(function(player, userId)
	local outfits = GetPlayerOutfits(userId)
	GetPlayerOutfitsEvent:FireClient(player, outfits)
end)

Sorry for the (extremely) late response, I was looking for solutions as well but managed to come up with this.