How does Roblox HTTP work?

Hello, I’m trying to get a list of a players avatar items. I noticed my current system is extremely inefficient and fires like 30 http requests. Is there a way I can limit it to one?
(It loops through a table of inventory types and sends a request for each one then puts it into a table.)

script: local HttpService = game:GetService("HttpService");
local remote = game.ReplicatedStorage.Inventory
local clothings = {
"TShirt","Hat","Shirt","Pants","Head","Face","Torso","RightArm","LeftArm","LeftLeg","RightLeg","Package","HairAccessory","FaceAccessory","NeckAccessory","ShoulderAccessory","FrontAccessory","BackAccessory","WaistAccessory","TShirtAccessory","ShirtAccessory","PantsAccessory","JacketAccessory","SweaterAccessory","ShortsAccessory","LeftShoeAccessory","RightShoeAccessory","DressSkirtAccessory"
}
local keepgoing = false
remote.OnServerInvoke = function(plr, UserId)
    local followers = {};
    
    for i,category in pairs(clothings) do
        print("running")
        local url = ("https://inventory.roproxy.com/v2/users/%s/inventory?assetTypes="..category.."&limit=100&sortOrder=Asc"):format(tostring(UserId))
    local success, output = pcall(function() return HttpService:JSONDecode(HttpService:GetAsync(url)) end);
        if not (success) then
            print(output .. " was caused because of a nooby item known as: " .. category)
            return followers
        end
    for _, v in pairs(output.data) do
        table.insert(followers, {Name = v.name; Category = category; Ca = "Avatar"});
        end
    end
    return followers;
end

Note: sorry i would love to provide my sources but I can’t find them at the moment. How would i limit all of these requests into 1 request since I have to wait forever with this current system

1 Like

Yes, you can limit it to one request. Here’s a past script I provided to someone:

local HTTP = game:GetService("HttpService")
local assettypes = {
	"Pants",
	"Shirt",
	"Hat",
	"Face",
	"Gear",
	"Place",
	"Audio",
	"Face",
	"Package",
	"Animation",
	"Torso",
	"RightArm", 
	"LeftArm", 
	"LeftLeg", 
	"RightLeg",
	"HairAccessory",
	"FaceAccessory",
	"NeckAccessory",
	"ShoulderAccessory",
	"FrontAccessory",
	"BackAccessory",
	"WaistAccessory",
	"EmoteAnimation",
	"Video",
	"JacketAccessory",
	"SweaterAccessory",
	"ShortsAccessory",
	"LeftShoeAccessory",
	"RightShoeAccessory",
	"DressSkirtAccessory"
}

local assetlist = table.concat(assettypes, ",")

game.Players.PlayerAdded:Connect(function(plr)
	local data = HTTP:GetAsync("https://inventory.roproxy.com/v2/users/"..plr.UserId.."/inventory?assetTypes="..assetlist.."&itemsPerPage=100",true)
	data = HTTP:JSONDecode(data)
	if #data.data > 0 then
		local randomaccessory = data.data[math.random(#data.data)]
		print(randomaccessory)
	end
end)

Of course, this was to get a random item from their inventory, but you could do it like this:

local url = ("https://inventory.roproxy.com/v2/users/%s/inventory?assetTypes="..table.concat(clothings, ",").."&limit=100&sortOrder=Asc"):format(tostring(UserId))

This should be able to go through all of the categories within one request.

If this works then god bless americia and god bless our troops. God bless you as well.
Saluting Face on Emojipedia 14.0 Flag: United States on Apple iOS 15.4

If you want to get the items a player is using on their avatar then you should be using the avatar api.
Specifically with the url that get’s the avatar details

https://avatar.roblox.com/v1/users/UserId/avatar

This is a sample script i made that gets the avatar details and prints all the assets in the avatar

local HTTP = game:GetService("HttpService")

local URL = "https://avatar.roproxy.com/v1/users/%s/avatar"

local function GetAvatarDetails(UserId: number)
	local url = string.format(URL, UserId)
	
	local success, response = pcall(function()
		return HTTP:GetAsync(url)
	end)
	
	if success and response then
		return HTTP:JSONDecode(response)
	else
		warn(response)
	end
end

print(GetAvatarDetails(UserId).assets) -- prints a table of the assets

hey by the way does avatar api work when there inventory is disabled

(and im not trying to just get the currently wearing items, but ALL their items)

If you getting the entire player’s inventory then you should check first if the player’s inventory is viewable. And no the avatar api does not do inventory related stuff. So you can probably discard the example code since i didn’t know you wanted to get all a player’s items

So can the avatar API see what the player is currently wearing even if their inventory is off or does the inventory still have to be on? (sorry for late response I went to bed it was like 2am)_

The currently worn avatar items of a player can be fetched regardless if their inventory is viewable or not

With the release of the ‘AvatarEditorService’ this no longer needs to be handled by the ‘HttpService’.
https://developer.roblox.com/en-us/api-reference/function/AvatarEditorService/GetInventory

1 Like

I’m already using it but it’s blocked with inventory set to off

The API wouldn’t be able to get the inventory of a user that’s hidden theirs either. If you just need a player’s on-site appearance you can use GetCharacterAppearanceInfoAsync.
https://developer.roblox.com/en-us/api-reference/function/Players/GetCharacterAppearanceInfoAsync

1 Like

okay. BTW I’m working on furry detector 2.0

hey I know this is a late response but i noticed that this solutioned has an accessory cap. It’s not showing their ENTIRE inventory and only like the first 50.

I rely HEAVILY on getting ALL their info. What’s up with this???

edit: this is the url:

["Avatar"] = "https://inventory.roproxy.com/v2/users/"..UserId.."/inventory?assetTypes="..AvatarList.."&itemsPerPage=100",

(changing the “&itemsPerPage=100” to a higher number than 100 has no effect.)

Oh, I forgot to say that it only goes through the first 100 items of the player’s inventory. Also, I would provide a fix to this, if Roblox’s API wasn’t broken and didn’t error when trying to go to the next page of the user’s inventory. Inventory Api If you were to enter all of the data properly and try to use the next page cursor to view the next page, it just returns (it sometimes lets you go through one or two pages, but it’s quite rare and is usually when you aren’t showing many items at once).


Therefore, there is currently no fix to this problem that I can provide or know of. Here is the code I was going to provide, but realized that it didn’t work due to that:

local HTTP = game:GetService("HttpService")
local assettypes = {
	"Pants",
	"Shirt",
	"Hat",
	"Face",
	"Gear",
	"Place",
	"Audio",
	"Face",
	"Package",
	"Animation",
	"Torso",
	"RightArm", 
	"LeftArm", 
	"LeftLeg", 
	"RightLeg",
	"HairAccessory",
	"FaceAccessory",
	"NeckAccessory",
	"ShoulderAccessory",
	"FrontAccessory",
	"BackAccessory",
	"WaistAccessory",
	"EmoteAnimation",
	"Video",
	"JacketAccessory",
	"SweaterAccessory",
	"ShortsAccessory",
	"LeftShoeAccessory",
	"RightShoeAccessory",
	"DressSkirtAccessory"
}

local assetlist = table.concat(assettypes, ",")

game.Players.PlayerAdded:Connect(function(plr)
	local inventory = {}
	local cursor = nil

	repeat
		local url = "https://inventory.roproxy.com/v2/users/"..plr.UserId.."/inventory?assetTypes="..assetlist.."&itemsPerPage=100"

		if cursor then
			url ..= "&cursor="..cursor
		end

		local data = HTTP:GetAsync(url ,true)
		data = HTTP:JSONDecode(data)

		if #data.data > 0 then
			table.insert(inventory, data.data)
		end

		if data.nextPageCursor then
			cursor = data.nextPageCursor
		end
	until not data.nextPageCursor

	print(inventory)
end)

Maybe i could request the information in seperate requests

That is what it does, separate requests. It needs to do them one by one until there is no longer another page. But, it errors on the second or third request since Roblox’s API has quite a few problems.

Are they going to fix it soon? also when i mean multiple requests I mean doing different tables not pages

The table isn’t the problem. The problem is on Roblox’s side, as it’s their API having trouble going through the pages. I’m not sure if they will fix it soon, you would have to ask a Roblox staff about that one.

When i add less items to the table it brings more different items up. When i add those items that i removed and add them to a seperate table then get the info of both tables it works just fine getting the info of both everytime

maybe its already fixed? did you test if it was still broken

Not sure. It might be because you are doing fewer items at once, which I wanted to avoid since it would be using a lot of requests, but I will try it on my side with fewer items.

Edit: Even with fewer items, it still returned HTTP 403 (Forbidden) for me. (My inventory was private, scratch that, I will retest)

Edit 2: Tested again, inventory was allowed to everyone this time, but still error on the second run (the one with the cursor) and I only had 10 items at a time.