Get JobId/gameJoinAttemptId of a game using the API

Howdy! I’m trying to make a program to get the ping between my PC and roblox’s game server, so i’m using the gameJoin API, more specifically, https://gamejoin.roblox.com/v1/join-game

  1. What do you want to achieve? I want to use this endpoint to check the ping between my pc and roblox’s game server in an attempt to search 10 servers and check the one with the best ping, and join that server.

  2. What is the issue?

{'jobId': None, 'status': 12, 'joinScriptUrl': None, 'authenticationUrl': None, 'authenticationTicket': None, 'message': 'Unable to join Game 211', 'joinScript': None, 'queuePosition': 0}

Unable to join Game 211

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried using the “game-id” from the game’s page, didn’t change anything, I did look for solutions, The best result was this link: https://www.roblox.com/games/getgameinstancesjson but it doesn’t work now in 2023.

Alright, now that’s all out of the way, here’s the python code:

import requests
import time

ROBLOSECURITY = ""

with open(".ROBLOSECURITY") as rf:
    ROBLOSECURITY = rf.read()

CSRF = requests.post("https://auth.roblox.com/v2/logout", cookies={".ROBLOSECURITY": ROBLOSECURITY}).headers['X-CSRF-TOKEN']

# POST BODY: {"placeId": 0, "gameJoinAttemptId": "00000000-0000-0000-0000-000000000000"}
JOIN_GAME_JOB_URL = "https://gamejoin.roblox.com/v1/join-game"

def join(placeId: int):
    req = requests.post(JOIN_GAME_JOB_URL, cookies={".ROBLOSECURITY": ROBLOSECURITY}, json={
        "gameJoinAttemptId": "XXX",
        "placeId": placeId
    }, headers={
        "x-csrf-token": CSRF,
        "referer": "https://www.roblox.com",
        "origin": "https://www.roblox.com",
        "User-Agent": "XXX",
        "Content-Type": "application/json"
    })
    
    print(req.json())

join(286090429)

correct me if im wrong, but a authentication url may be needed.

iirc correctly it is used for both verifying your identity aswell as joining you with your account as it uses that token to retreive your account details and log you into the game.

Revisiting the issue of the gameinstancesjson issue, roblox wouldnt deprecate an API Endpoint unless it was replaced with another, and/or it was a risk for hackers/cheats.

In this case, This endpoint Below lists all game servers in a json format. it will also return a job id as “id” which iirc is also required for gamejoining.

https://games.roblox.com/v1/games/2788229376/servers/0?sortOrder=2&excludeFullGames=false&limit=10

This Endpoint Returns This Code:

{
  "previousPageCursor": null,
  "nextPageCursor": "eyJzdGFydEluZGV4IjoxMCwiZGlzY3JpbWluYXRvciI6InBsYWNlSWQ6Mjc4ODIyOTM3NnNlcnZlclR5cGU6MCIsImNvdW50IjoxMH0KYWJlOTFjOTc0NzBmOWJlODMwMGQ0YjIyNGQ5M2FhZWU3MGNiNGU2MzJmYmExYzY4ZDZmNWM4NTU0NWI5ZDVmMg==",
  "data": [
    {
      "id": "b32de54b-6a2f-4dac-a54e-a03a8105267b",
      "maxPlayers": 40,
      "playing": 40,
      "playerTokens": [
        "AAAF4144CAA7E74AF6E7F8955EEA9069",
        "ED6D95FDEC7D2A704D8857357B94D038",
        "DB97D36604539BBCD070B1C2A2C6C67E",
        "89D32FC50370EE987B296A02AFA588AB",
        "7B80F0D913DA9C4C5D322E5EA050418F"
      ],
      "players": [],
      "fps": 60.000629,
      "ping": 88
    },
    {
      "id": "47f7dc2a-b973-4f31-8eec-f69f9a8f982c",
      "maxPlayers": 40,
      "playing": 40,
      "playerTokens": [
        "78937D9D7866B68FEB0918701A067C52",
        "48665F778B3639F929108F97EFCEA322",
        "E714AC8067FC56CB21BA02C2DC7C9FE4",
        "544D27E8C2770206DF993846497335D3",
        "7377178EE9EABB02ACA806604196EAA4"
      ],
      "players": [],
      "fps": 59.93132,
      "ping": 83
    },
    {
      "id": "a396b503-53be-4c6d-b38a-7682c60aa1ea",
      "maxPlayers": 40,
      "playing": 40,
      "playerTokens": [
        "EF5A05D137C8526F4881A5E6830A7DF8",
        "43F7820C71F0BC1BEF467534DF2952DD",
        "B637A24CAFAA81D8BBDF2E79436F501E",
        "D7E63C44787CC6E5F8108225991D5101",
        "DFAF18F47DCBB75C1ED37944FDA3E21E"
      ],
      "players": [],
      "fps": 59.944923,
      "ping": 61
    },
    {
      "id": "b472e631-c485-4cd0-b668-fd8b7aac58cd",
      "maxPlayers": 40,
      "playing": 40,
      "playerTokens": [
        "9C13DF0395573A856752C278E0AA5B93",
        "555448EE066B0589FD05C2F626DB352F",
        "F427F667E8BEE28A5166BC4812A85E6F",
        "511362B783BA00889829BBD89C20EE46",
        "7312B02624801137300A66B76D8A1A7B"
      ],
      "players": [],
      "fps": 59.985958,
      "ping": 55
    },
    {
      "id": "b8734b6e-facb-48bf-9ed4-c17c603611a3",
      "maxPlayers": 40,
      "playing": 40,
      "playerTokens": [
        "B4CD9D358B8D2C745F55EC562369E7B2",
        "F224A22171E3EFE9B7D641CB6702591F",
        "865CD6DEDBF56A2DD41C7F0816C0F5DE",
        "DC6595EE8792C523FCC04FF8532D27E3",
        "38B2E8BEE1A47FADBC3CCAAEBAB91A7F"
      ],
      "players": [],
      "fps": 59.937588,
      "ping": 58
    },
    {
      "id": "b5ec0ae8-eea1-4e36-87db-09b15ec7b33b",
      "maxPlayers": 40,
      "playing": 40,
      "playerTokens": [
        "AB5C5A9E62A82E49DEC4151D23BD1BAE",
        "FF52F025089049592ECA27B9F9693964",
        "1B0C926341BA385F277B986A04CC8281",
        "A0F769F904C3DD41AF6839106D55BD89",
        "A87A8EB7BED425388A04C0CC733E3B2D"
      ],
      "players": [],
      "fps": 59.931255,
      "ping": 63
    },
    {
      "id": "83b82b3d-44ed-446c-ae31-fb146cebdc78",
      "maxPlayers": 40,
      "playing": 39,
      "playerTokens": [
        "F32DE86734257DDAD1B1EB4FFAE5C493",
        "90541340469820F9E2079CB2A0E6FC96",
        "46DE06BC6C063312575218E70C81413C",
        "EBC3C7F50E23AD5C6A5ABC1072E53E0D",
        "85D7237A01D454ACB398DDFB471F613B"
      ],
      "players": [],
      "fps": 58.701649,
      "ping": 82
    },
    {
      "id": "697cbd0a-e4ae-4294-8d92-3a9d710b8b27",
      "maxPlayers": 40,
      "playing": 39,
      "playerTokens": [
        "2D3CD8069C5F1D43475446E7910ED212",
        "737071CB4752E1ED3579F38B4D4D893E",
        "BE2A7C257A6086873B26987205907888",
        "DC3D0C0FA35695D19B4C3A35301E714F",
        "82686073CFE16EA26ED7F336D5B8334B"
      ],
      "players": [],
      "fps": 59.931576,
      "ping": 65
    },
    {
      "id": "8cb77a71-9496-4308-b2b5-9642ddcb27c6",
      "maxPlayers": 40,
      "playing": 39,
      "playerTokens": [
        "FB457FEE59C4EEB353EBA31EE0FC1FFE",
        "513EEB439949232B8569F2A81C05D680",
        "4B436AB699D016D759B78B80F87DBD01",
        "9918388C3376853CCAD964ED4CA208D7",
        "F47C5FA7952D2FD024C2A1B247EF1740"
      ],
      "players": [],
      "fps": 59.955715,
      "ping": 37
    },
    {
      "id": "1f9c9bab-ba41-403b-bd0b-d909ae33caec",
      "maxPlayers": 40,
      "playing": 38,
      "playerTokens": [
        "7335D1A4C89A7634F909A9386BB9751E",
        "630C4D3E94C82EABCB8503827940205D",
        "79436BF4FF4DF9103CBDBCE4EC4EF9C9",
        "5C0C9B67B2A73DCB015309D34E0DE111",
        "EDC9EF247FBB1BEEFABCAF41BB96F5E0"
      ],
      "players": [],
      "fps": 59.944077,
      "ping": 62
    }
  ]
}

Im sorry if im not helping as im pretty sure this is what you are trying to specify, if you need anymore help please feel free to reply with your question!

cheers, MrolivesGaming (Oliver)

1 Like

Awesome, You’ve led me to a lot of info, and I have found this project: https://github.com/recanman/RobloxServerGrabber/blob/main/index.js, which helped me achieve my goal, Here’s the code for anyone else who has the same issue as me:

import requests, json
import time

ROBLOSECURITY = ""

with open(".ROBLOSECURITY") as rf:
    ROBLOSECURITY = rf.read()

CSRF = requests.post("https://auth.roblox.com/v2/logout", cookies={".ROBLOSECURITY": ROBLOSECURITY}).headers['X-CSRF-TOKEN']

# POST BODY: {"placeId": 0, "gameJoinAttemptId": "00000000-0000-0000-0000-000000000000"}
JOIN_GAME_JOB_URL = "https://gamejoin.roblox.com/v1/join-game-instance"
GET_SERVERS_URL = "https://games.roblox.com/v1/games/{}/servers/0?sortOrder=2&excludeFullGames=true&limit=10"

def getGameServer(placeId: int):
    req = requests.get(GET_SERVERS_URL.replace("{}", str(placeId)))

    return req.json()["data"][0]

def join(placeId: int):
    server = getGameServer(placeId)

    req = requests.post(JOIN_GAME_JOB_URL, cookies={
        ".ROBLOSECURITY": ROBLOSECURITY,
        "path": "/",
        "domain": ".roblox.com"
    }, json={
        "placeId": placeId,
        "isTeleport": False,
        "gameId": server["id"],
        "gameJoinAttemptId": server["id"]
    }, headers={
        "Referer": f"https://www.roblox.com/games/{placeId}/",
        "Origin": "https://roblox.com",
        "User-Agent": "Roblox/WinInet",
    })

    full = req.json()

    full["joinScript"]["SessionId"] = json.loads(full["joinScript"]["SessionId"])
    full["joinScript"]["ClientPublicKeyData"] = json.loads(full["joinScript"]["ClientPublicKeyData"])

    json.dump(full, open("result.json", "w"), indent=2)
    
    return full
1 Like

Not A Problem, Enjoy your code!

1 Like

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