Get the player's RAP

How would I get the player’s RAP from their profile? I’ve been searching for a web endpoint but couldn’t find one.

Edit: To clarify, I’m looking for a web endpoint to retrieve the player’s RAP from the Roblox website for display in a game from a script.

4 Likes

Maybe try adding up the combined RAP of all the items they own?

1 Like

As extension to @EmeraldSlash his suggestion, use this API to get the full list of owned limiteds and add up their RAP.

https://inventory.roblox.com/docs#!/Inventory/get_v1_users_userId_assets_collectibles

6 Likes

I have never heard of that website before lol

Cool

Official Roblox API, there are quite some;

https://devforum.roblox.com/t/official-list-of-deprecated-web-endpoints/62889/16?u=taart

(the topic title is a bit misleading)

3 Likes

There are extensions to see this. However, it would be cool to actually have it built in to a player’s profile on ROBLOX.

1 Like

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.

That is asked often (a brief search of this forum for ‘roblox proxy’ gets you this as well), but in general it is best to make your own.

This thread lists a few though;

1 Like

How do I add up the RAP if the roblox API doesn’t show the rap of a limited item?

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”).

if not success then
    warn(result)
end
4 Likes

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

image

1 Like