Creating a catalog game, Need help with the API limit

So the thing is I’m currently working on a catalog game of accessories/3d items but I’m having a huge problem with API limits so here’s the code btw:

local search = game.ReplicatedStorage:WaitForChild("Searched")
local MarketplaceService = game:GetService("MarketplaceService")
local HttpService = game:GetService("HttpService")
local fetchedresults = {}
local nextpage = ""
local notallowed = {
	[Enum.AssetType.TShirt.Value] = true,
	[Enum.AssetType.Pants.Value] = true,
	[Enum.AssetType.Face.Value] = true,
	[Enum.AssetType.Decal.Value] = true,
	[Enum.AssetType.Image.Value] = true,
	[Enum.AssetType.Head.Value] = true,
	[Enum.AssetType.Shirt.Value] = true,
	[Enum.AssetType.GamePass.Value] = true,
	[Enum.AssetType.Lua.Value] = true,
	[Enum.AssetType.MeshPart.Value] = true,
	[Enum.AssetType.Place.Value] = true,
	[Enum.AssetType.Animation.Value] = true,
	[Enum.AssetType.EmoteAnimation.Value] = true
}

function onsearch(plr, searchTerm)
	fetchedresults = {}
	nextpage = ""
	for i = 1, 3 do
		local url = "https://catalog.roproxy.com/v1/search/items?category=11&keyword=" .. HttpService:UrlEncode(searchTerm) .. "&limit=120&cursor=" .. HttpService:UrlEncode(nextpage)
		local result = HttpService:GetAsync(url)
		if result then
			local data = HttpService:JSONDecode(result)
			if data then
				if data.data then
					for _, item in ipairs(data.data) do
						task.spawn(function()
							local product = MarketplaceService:GetProductInfo(item.id)
							if not notallowed[product.AssetTypeId] then
								local price = product.PriceInRobux
								if not price then
									price = 0
								end
								fetchedresults[item.id] = {
									["ID"] = item.id,
									["Name"] = product.Name,
									["Description"] = product.Description,
									["Price"] = price
								}
								search:FireClient(plr, fetchedresults)
							end
						end)
					end
				end
				nextpage = data.nextPageCursor or ""
			end
		end
	end
end

search.OnServerEvent:Connect(function(plr, searchterm)
	onsearch(plr, searchterm)
end)

so it does work but the thing is if the player make’s like 2 searches then it shows the error for API limit, It is because :GetProductInfo is being run 360 times per search and the API limit is 400 for a server script, What alternative options do I have?

maybe avatar editor service can help, it has a couple of methods for searching the catalogue and other accessory related things

specifically this method AvatarEditorService | Documentation - Roblox Creator Hub

1 Like

you have 2 options. Limit the products you go through and use on client rate limiting like a gui showing up. Or you can call a third party server to do it for you, Utalizing proxies to call the 360 get requests. I would no matter what tho recommend drastically decreasing your api usage

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.