I edited my thread to clarify my goal. Is there some sort of proxy so I can use the API you provided? I’m fairly certain I can’t access Roblox domains using HTTPService.
There’s a recentAveragePrice field in the return you get from this GET API. Have you tried deconstructing the return value you get from a GET request or checking the array’s composition on the endpoint documentation site?
I don’t know how to get the API to work. I currently use http service on the standard roblox catalog api and decode the json data which doesn’t include RAP
Well, that’s probably the first thing you need to start on. Remember that you won’t be able to fetch a user’s collectibles inventory if they’re hidden - something to account for depending on your use case.
The first thing you need to do is send a GET request to the endpoint. Use rprxy, since you can’t directly send requests to Roblox. You must also ensure that Http requests are enabled, either by using the Game Settings tab or setting HttpEnabled to true via the command bar.
local HttpService = game:GetService("HttpService")
local UserId = 1
local Endpoint = "https://inventory.rprxy.xyz/v1/users/%d/assets/collectibles"
local success, result = pcall(HttpService.GetAsync, HttpService, Endpoint:format(UserId))
Once you’ve done this, you can work with the data that’s retrieved. The data returned is in JSON format, so you will need to use JSON decode. Then, simply iterate through the table. This is assuming that the call is successful and returns data.
HttpService:JSONDecode(result)
for key, value in pairs(result) do
print(key, value)
end
If success is false, then the call most likely failed for some reason - such as the endpoint being down or the user’s inventory being hidden. If that’s so, you can check if success is false and print out the error that was received, then handle the rest (e.g. by changing a RAP label to “hidden”).
Here’s an implementation I wrote which achieves this.
local http = game:GetService("HttpService")
local players = game:GetService("Players")
local baseUrl = "https://inventory.roproxy.com/v1/users/%d/assets/collectibles?sortOrder=Asc&limit=100&cursor=%s"
local function getTotalRecentAveragePriceRecursive(userId, recentAveragePriceCumulative, cursor)
recentAveragePriceCumulative = recentAveragePriceCumulative or 0
cursor = cursor or ""
local requestUrl = baseUrl:format(userId, cursor)
local success, result = pcall(function()
return http:GetAsync(requestUrl)
end)
if success then
if result then
local success2, result2 = pcall(function()
return http:JSONDecode(result)
end)
if success2 then
if result2 then
for _, collectible in ipairs(result2.data) do
if collectible.recentAveragePrice then
recentAveragePriceCumulative += collectible.recentAveragePrice
end
end
cursor = result2.nextPageCursor
if cursor then
return getTotalRecentAveragePriceRecursive(userId, recentAveragePriceCumulative, cursor)
else
return recentAveragePriceCumulative
end
end
else
warn(result2)
getTotalRecentAveragePriceRecursive(userId, recentAveragePriceCumulative, cursor)
end
end
else
warn(result)
getTotalRecentAveragePriceRecursive(userId, recentAveragePriceCumulative, cursor)
end
end
local totalRecentAveragePrice = getTotalRecentAveragePriceRecursive(1)
print(totalRecentAveragePrice) --133674592