How can I get all the game's gamepasses

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I wanna know how can I get all the gamepasses found in a game, from a script or an API.
  2. What is the issue? Include screenshots / videos if possible!
    I tried using every single API I found, but none of them worked…
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I searched everywhere, on youtube, devforum, but I found nothing

Thanks.

1 Like
local httpService = game:GetService("HttpService")

local gameID = game.GameId

local baseUrl = "https://games.roproxy.com/v1/games/%s/game-passes?limit=100&sortOrder=Asc"
local URL = baseUrl:format(gameID)

local response
local jsonData

local success, err = pcall(function()
	response = httpService:GetAsync(URL)
end)

if success then
	jsonData = httpService:JSONDecode(response)
	print(jsonData.data[1].name)
else
	print(err)
end

This code uses the RoProxy endpoint to get the gamepasses.

If you want to do this with other games, you will need to get their UniverseID. To do this, you can visit the endpoint below and replace PLACEID with the game’s PlaceID.

FROM:
image

TO:
image

Then you can change the variable gameID to the numbers displayed in the brackets.

2 Likes

EDIT:

I completely forgot about JSONDecode which can be used in this scenario to get bits of data from the string. I have updated the code which now uses JSONDecode.

JSONDecode documentation

1 Like

Will try this as soon as I get home. Thanks so much :smiley:

1 Like

Alright so it actually works but,
It only prints one gamepass, how could I print the name of all the gamepasses?
Should I use a for loop?

Wait nevermind, I figured it out.

image

1 Like

If you are looking for just the name, something like this could work:

for i = 1, amnt do
   print(jsonData.data[i].name)
end
1 Like

Thanks so much for the help man. I really appreciate it. :heart:

1 Like

Anytime! Glad it works as intended.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.