How to retrieve all existing gamepass id's for a game

  1. What do you want to achieve?
    I want to retrieve a list of all existing gamepass id’s for a game and add them to a table. To be clear, I do not want to update the IDs manually every time I create a new gamepass.
  2. What is the issue?
    I can not find any documentation, syntax, or existing forum posts that have an effective way of doing this.
  3. What solutions have you tried so far?
    Looked for solutions on Developer Hub, YouTube, and any websites I could find.
1 Like

The BTRoblox README is usually where I look to answer my own roblox API questions.

For your question, first you’re going to need your universe ID. We can make an api request to
https://api.roblox.com/universes/get-universe-containing-place?placeid=1818. (the number being your place id of choice)

This responds with JSON data that looks like this:

{
    "UniverseId": 13058
}

Once you retrieve your universe ID with HttpService:JSONDecode(), we can move on to requesting gamepasses.

We need to make requests to
https://games.roblox.com/v1/games/13058/game-passes?limit=100&sortOrder=1. (the number after /v1/games being the universe ID.)
In your case, we do not need to change sortOrder because all we need is a list of gamepass IDs.

The response JSON data looks somewhat like this:

{
  "previousPageCursor": "id_2zwAAAYSGa_2rzgY7JK0",
  "nextPageCursor": null,
  "data": [
    {
      "id": 104539309,
      "name": "a",
      "displayName": "a",
      "productId": null,
      "price": null,
      "sellerName": "Roblox",
      "sellerId": null,
      "isOwned": false
    }
  ]
}

You can iterate through the data and add each ID to a table, but for your code to scale correctly, I would suggest recursively using the nextPageCursor in the response to keep re-requesting more gamepasses by adding another query parameter: &cursor=1234 (1234 being the nextPageCursor).

1 Like

Thanks so much for the help! This is exactly what I needed. However what exactly is a cursor in this case?

When trying to retrieve the JSON I get the following error: HttpService is not allowed to access ROBLOX resources

Replace Roblox with roproxy. This is what I use at least to access Roblox API in game.

I heard about that. Is it secure, though? Does it have any security risk?

I wouldn’t be using it if it had any Security Risks. You aren’t really supposed to use Token Information with the Roblox API within’ Roblox. Hence why they locked it in the first place, so people didn’t try and risk putting their cookie token in their game.

If your scared that the spooky dookie government is going to spy on your Tax Evasion. Just don’t use it. But if your terrified that a person is going to see your requests. Your fine.

Alright thanks. I just know they say not to send HTTP requests to non trusted links because they can provide security risks for your games.