-
What do you want to achieve? I want to make a discord countdown of game visits. In Java of course!
-
What is the issue? I have no idea how to catch the visits of a game into a code.
-
What solutions have you tried so far? I have looked on this forum and there were a few posts, but they did not help me out.
Roblox has a Games API with the endpoint /v1/games. You just need to pass the universeIds(s) of the games you want to get information from in the query string.
A GET request sent to https://games.roblox.com/v1/games?universeIds=1686227767 returns this:
If it’s only one universeId you used or the first one, you can get the visits by JSON decoding it and doing:
visits = decodedTable.data[1].visits
But how can I get the universal id of any game?
Head to Develop > Find Your Game > Click the drop down button next to the gear icon of your place > Configure Game
In the url, you should see an ID – that’s the universe Id:
But how can you get the universe id of a game which you do not have permission to develope on?
I’ve been experimenting for a bit in studio to try and get the visits from a place and I found something that works:
local ID = 3213485397;
local body = game:GetService("HttpService"):GetAsync("https://www.rprxy.xyz/games/"..ID)
print(body:match("id=game%-visit%-count class=\"text%-lead font%-caption%-body wait%-for%-i18n%-format%-render\" title=([%d+,]+)"))
Basically, you send an HTTP request to the page of a roblox game and find the visits using string patterns from the page’s HTML markdown. You need to send it to https://www.roblox.com/
+ the ID of the game and it should print its visits.
You see that i’ve used rprxy.xyz instead of roblox.com, that’s because I tested this in studio and of course roblox doesn’t allow you to send requests to their domain from the roblox player client and studio. If you’re obtaining the data outside of roblox, there’s no need to use rprxy.xyz
hm now I just have to figure out how to get it into VSC