local gamesUrl = "https://games.roproxy.com/v2/users"
local url4 = "https://games.roproxy.com/v1/games?universeIds="
local data4 = http.get(gamesUrl .. "/"..userId.."/games?accessFilter=Public&sortOrder=Asc&limit=50")
data4 = data4.data
local totalVisits = 0
for i=1,#data4 do
local gameId = data4[i].id
local visitsData = http.get(url4..gameId)
visitsData = visitsData.data
totalVisits=totalVisits+visitsData[1].visits
wait()
end
This code is used to get a players Place Visits, and It makes multiple API calls to do so.
Is there a better and more efficient way of getting a Players place visits?
If you didn’t realise already, the API mentions the argument “universeIds”.
And yes ladies and gentlemen, that statement is not false, you can put multiple games in once request.
local gamesUrl = "https://games.roproxy.com/v2/users"
local url4 = "https://games.roproxy.com/v1/games?universeIds="
local data4 = http.get(gamesUrl .. "/"..userId.."/games?accessFilter=Public&sortOrder=Asc&limit=50")
data4 = data4.data
local totalVisits = 0
local Games = {}
for i = 1, #data4 do
local gameId = data4[i].id
table.insert(Games, gameId)
end
local visitsData = http.get(url4.. table.concat(Games, ","))
visitsData = visitsData.data
for _, gameData in ipairs(visitsData) do
totalVisits = totalVisits + gameData.visits
end
Did Not Test
Just store all the game id’s and pack them together.