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?