Is there like an API I could use to access said data above?
For context, I’m trying to make a discord app command ( a / command) where anyone executing the command can find what game I’m playing and would send a link to the game however every time time I’ve tried to implement this command it always fails giving errors such as:
Failed to check presence (Status 404)
Error: {"errors":[{"code":0,"message":""}]}
Now I’m unsure if the methods I was using to get this data was deprecated, Some of the code was AI generated as I used AI to debug the code.
This was my def to get the .json and I assume the .json would contain the data I needed to get the game that I was playing:
async def get_json(session, url, method="GET", json_body=None):
try:
timeout = aiohttp.ClientTimeout(total=5)
if method == "GET":
async with session.get(url, timeout=timeout) as resp:
if resp.status != 200:
return None
return await resp.json()
elif method == "POST":
async with session.post(url, json=json_body, timeout=timeout) as resp:
if resp.status != 200:
return None
return await resp.json()
except asyncio.TimeoutError:
print(f"Timeout fetching {url}")
return None
except Exception as e:
print(f"HTTP request error fetching {url}: {e}")
return None
To get stuff like the URL I used "https://presence.roblox.com/v1/presence/users" and https://games.roblox.com/v1/places/{place_id}" and I’m unsure if those are deprecated too
The full code snippets are here:
async def get_roblox_user_game(session, user_id):
url = "https://presence.roblox.com/v1/presence/users"
json_body = {"userIds": [user_id]}
data = await get_json(session, url, method="POST", json_body=json_body)
if not data:
return None
presences = data.get("userPresences", [])
if not presences:
return None
presence = presences[0]
return presence.get("placeId")
async def get_place_details(session, place_id):
url = f"https://games.roblox.com/v1/places/{place_id}"
return await get_json(session, url)
So in summary, is there an alternative, maybe more simplier way to get this information? I’ve already tried to use things such as API keys but I will be honest I have no clue what I’m doing when It comes to APIs.
