Any way to make this faster? Proxy servers and roblox api's to get a badge

Basically in some badge counting games it takes .1-.5 seconds to fetch the next page from the badge api’s but my code takes far too long, it works though, I managed to count 14000 badges that I own even though it took almost 15 minutes, 2 seconds to fetch each page…

local dataa2 = Proxy:Get("https://badges.roblox.com/v1/users/51967249/badges?limit=100&sortOrder=Asc")

local ReturnedJSon = game:GetService("HttpService"):JSONDecode(dataa2.body)
local origLenth = 0 -- current badges
--print(ReturnedJSon.nextPageCursor)
local function recurseGetLen(nextpagecursor)
	if nextpagecursor then
		local newData = Proxy:Get("https://badges.roblox.com/v1/users/51967249/badges?limit=100&cursor="..nextpagecursor.."&sortOrder=Asc")
		local ReturnedJSon = game:GetService("HttpService"):JSONDecode(newData.body)
		if ReturnedJSon.nextPageCursor then
			origLenth = origLenth + #ReturnedJSon['data']
			print('continuing recursion: ',origLenth)
			recurseGetLen(ReturnedJSon.nextPageCursor)
		else
			origLenth = origLenth + #ReturnedJSon['data']
			print('end recursion: ',origLenth)
		end
	else
		print('new recursion called')
		origLenth = origLenth + #ReturnedJSon['data']
		print('length: ',origLenth)
		recurseGetLen(ReturnedJSon.nextPageCursor)
	end
end
recurseGetLen()

Would there be a faster method? Would I need to stop using the proxy server and if so, how would I manage to bypass the trust check? I have seen the badges count way faster than 15 minutes…

4 Likes

I have necrobumped this post so many times now in search of a faster method, I did come up with this:

local function GetBadges2(id)
	local gamesData = HttpService:GetAsync("https://badges.rprxy.xyz/v1/users/"..id.."/badges?limit=100&sortOrder=Asc")
	gamesData = HttpService:JSONDecode(gamesData)
	
	local totalVisits = 0
	
	while gamesData.nextPageCursor do
		totalVisits=totalVisits+#gamesData.data
		print(totalVisits)
		gamesData = HttpService:GetAsync("https://badges.rprxy.xyz/v1/users/"..id.."/badges?limit=100&cursor="..gamesData.nextPageCursor.."&sortOrder=Asc")
		gamesData = HttpService:JSONDecode(gamesData)
	end
	
	return totalVisits
end
print(GetBadges2(51967249))

But it still takes forever… If the user has 100000 badges then it will take a LOAD of time… I tried a technique for getting 2 requests at a time but got script time execution thingy… Apparently the rprxy proxy is faster for me…

2 Likes