Get all gamepasses under the game

I’m making a gamepass shop and dont really want to make all the buttons myself, so I would like to know how I can get all the gamepasses made under my game.
Preferably it would give me the image, description, id, and name of each gamepass.

https://games.roblox.com/v1/games/{universeId}/game-pass

Use HttpService to fetch the data.

Thank you! How would I use HttpService for the images?

To Get a Description of the Gamepass, you will need to use MarketplaceService:GetProductInfo

game:GetService("MarketplaceService"):GetProductInfo(GamepassId,Enum.InfoType.GamePass)

Here is a list of the Info it returns:
https://create.roblox.com/docs/reference/engine/classes/MarketplaceService#GetProductInfo

And yes, it does include the Gamepass Icon, Its known under IconImageAssetId

1 Like

You can use MarketPlaceService:GetProductInfo() which returns a table with the info about the item you pass by Id as parameter.

You can use a for loop to iterate over the data returned by the API to call this function over every pass, it will return the ImageId which you can use to display the image.

You should also notice that if you have too many gamepasses the API won’t return them all in one request so you will need to use the nextPageCursor returned in every response to fetch more gamepasses

Thank you for your help, but the only issue is this:
HttpService is not allowed to access ROBLOX resources

HttpService doesnt work on Roblox stuff, you use MarketplaceService

Not by default, use a proxy since requests from roblox games are blocked.

1 Like

Do you recommend any proxies i could use?

OP wants to automatically get all the passes and the function you provided won’t return the info for all gamepass at once so he would need to make a table of ids to iterate over, instead the API endpoint returns a set of gamepass es with their IDs which can then be iterated over to get the info through the function you provided.

There are many proxies made by the community, a common one is RoProxy.

Yes, MarketplaceService:GetProductInfo will help with that

That function requires an asset id so OP would need to update a table of IDs every time a new gamepass is created, that is not needed if a list of IDs is fetched from an API which will always return up to date data.

I did a Bit of Research, These Topics might help:

(woops, accidental reply)

will give you a table with the image, description, name, and id

You can use MarketplaceService:GetProductInfo

local Gamepasses = {}
for i,v in pairs(MarketplaceService:GetGamePassIdsForGame(game.GameId)) do
    table.insert(Gamepasses, MarketplaceService:GetProductInfo(v, Enum.InfoType.Product))
end

For future readers: Don’t waste your time with this code.

MarketplaceService:GetGamePassIdsForGame does not exist.

4 Likes

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