How to check if a game is public

Touched upon most of this in the RoProxy thread already, but worth mentioning for anyone else looking to do the same thing in the future:

No game/place detail APIs will return a simple “private” or “public” property, they return an “isPlayable” property based on your team create access, group roles, etc. Previously, the “isPlayable” property would return a value corresponding to the game’s privacy settings when unauthenticated - however a recent change means it now always returns false.

However, I thought of a (somewhat hacky) solution since then.

local HttpService = game:GetService("HttpService")

--works equivalently to your getUniverseData function, pretty self-explanatory
function getUniverseData(universeId)
	local response = HttpService:GetAsync("https://games.roproxy.com/v1/games?universeIds="..universeId)
	return HttpService:JSONDecode(response)
end

--get a list of public games created by a user or group
function getCreatorPublicGames(creatorType, creatorId)
	local endpoint = (creatorType == "User" and "https://games.roproxy.com/v2/users/%s/games?accessFilter=2&limit=50" or "https://games.roproxy.com/v2/groups/%s/games?accessFilter=2&limit=50")
	local response = HttpService:GetAsync(string.format(endpoint, creatorId))
	return HttpService:JSONDecode(response)
end

--return a boolean corresponding to the experience privacy
function isGamePublic(universeId)
	local creatorData = getUniverseData(universeId).data[1].creator
	
	local creatorGames = getCreatorPublicGames(creatorData.type, creatorData.id)
	
	for i, gameData in pairs(creatorGames.data) do
		if gameData.id == universeId then return true end
	end
	
	return false
end

--note that you should be generating game/universe ids as opposed to place ids, as typically only the root place is accessible.
local universeId = math.random(1, 1000000000)

print(isGamePublic(universeId))
5 Likes