How can I loop through all of the user's tshirts that they put up for sale?

How can I loop through all of the user’s T-Shirts that they have put up for sale?

I want to achieve something like the ‘Donate Pls’ game. As you can see, they were able to get the player’s owned tshirts and put them all on the gui.
I have no idea how to do this and any other posts relating to this don’t work for me.

I have no idea where to start. I found this from another post:

local InventoryUrl = "https://robloxdevforumproxy.glitch.me/users/inventory/list-json?assetTypeId=11&cursor=&itemsPerPage=100&pageNumber=%x&sortOrder=Desc&userId=%i" 


	-- In an event
	local Inventory = HttpService:JSONDecode(HttpService:GetAsync(string.format(InventoryUrl, 1, plr.UserId))) -- function
	for i, v in pairs(Inventory.Data.Items) do
		print(v.Creator.Name)
	end

But it doesn’t even loop once.

1 Like

That API endpoint is for fetching a list of t-shirts a particular user owns.

local http = game:GetService("HttpService")

local baseUrl = "https://catalog.roproxy.com/v1/search/items/details?Category=3&Subcategory=13&Limit=30&CreatorName=%s&cursor=%s"

local function getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
	tshirts = tshirts or {}
	cursor = cursor or ""
	local requestUrl = baseUrl:format(username, cursor)
	local success, result = pcall(function()
		return http:GetAsync(requestUrl)
	end)
	
	if success then
		if result then
			local success2, result2 = pcall(function()
				return http:JSONDecode(result)
			end)
			
			if success2 then
				if result2 then
					for _, tshirt in ipairs(result2.data) do
						table.insert(tshirts, tshirt.id)
					end
					
					cursor = result2.nextPageCursor
					if cursor then
						return getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
					else
						return tshirts
					end
				end
			else
				warn(result)
			end
		end
	else
		warn(result)
	end
end

local username = "Roblox"
local userTShirts = getUserGeneratedTShirtsRecursive(username)
print(#userTShirts) --3
print(table.concat(userTShirts, " ")) --1031862 1036727 1031864

When testing the same script with a user that has uploaded more than 30 t-shirts (maximum page-size per request) these were the results.

local username = "robosapien626"
local userTShirts = getUserGeneratedTShirtsRecursive(username)
print(#userTShirts) --323
print(table.concat(userTShirts, " ")) --323 shirt IDs.
16 Likes

Thanks!
Is there a way I could do this with normal shirts and pants, too? Would i have to use a different api?

1 Like

You’d change the subcategory bit from Subcategory=13 to 12 for shirts and 14 for pants.

2 Likes

Hey there,

I was using this technique yesterday and it worked fine but all of a sudden, the requests weren’t working anymore. Can you help? (no errors)

image

Appears to still be working fine on my end.

weird cause mine just shows up with a HTTP connection fail. I might look for other methods maybe

That usually means you either have HTTP requests disabled in the game’s settings or your own internet connection dropped while making the request.

Your ISP may have also blocked the particular proxy being used roproxy. If this is the case then consider hosting your own proxy, there are tutorials out there for this.

1 Like

Does this even work if the player inventory is hidden

Yes, it will still work if the user has their inventory privated.

local username = "superyoshi64"
local userTShirts = getUserGeneratedTShirtsRecursive(username)
print(#userTShirts) --1
print(table.concat(userTShirts, " ")) --1719488

https://www.roblox.com/users/130347/profile

1 Like

Is there a way to access shirts from their groups too? Or does this already do that

For some reason I keep getting “HTTP 400 (Bad Request).” When it does http:GetAsync(requestUrl), the pcall is making it go to the warn message. How do I fix this?

1 Like

Did you figure out how to fix it? Im getting the same issue

what if i wanted to get the updated value for the t shirt? or do you know of a way to prevent players from buying a t shirt in game and manipulating the price of that t shirt?

for gamepasses you just get the updated value and check. but for t shirts that value does not hold true.

i keep getting a bad request error.