Player Created Gamepasses

Here’s a script I just wrote which you can use to scrape all of the gamepasses created by a particular user. All you need to do is call the function and pass to it the ID of the user you want to query. It’ll return an array of gamepass IDs created by the user.

local http = game:GetService("HttpService")

local baseUrl = "https://www.roproxy.com/users/inventory/list-json?assetTypeId=34&cursor=&itemsPerPage=100&pageNumber=%s&userId=%s"

local function getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
	gamepasses = gamepasses or {}
	pageNumber = pageNumber or 1
	lastLength = lastLength or math.huge
	
	local requestUrl = baseUrl:format(pageNumber, userId)
	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 _, gamepass in ipairs(result2.Data.Items) do
						if gamepass.Creator.Id == userId then
							table.insert(gamepasses, gamepass.Item.AssetId)
						end
					end
					
					if result:len() ~= lastLength then
						lastLength = result:len()
						pageNumber += 1
						getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
					end
				end
			else
				warn(result)
				getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
			end
		end
	else
		warn(result)
		getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
	end
	return gamepasses
end

local userGamepasses = getUserCreatedGamepassesRecursive(2032622)
print(#userGamepasses) --6 gamepasses.
for _, gamepassId in ipairs(userGamepasses) do
	print(gamepassId) --6 gamepass IDs.
end
58 Likes