How to get all a players badges?

Hello I’m trying to get a table of all a players badges they ever have owned. How would i do this?

You can use HttpService to send a get request to the badge API: Badges Api and use a proxy since you can’t directly access roblox’s apis

Edit: I’m not sure but roproxy might be an option

how do i do it by just running code on the server?

for example i was trying to get a list of the players followers and i used this code in a script to do it:

local HttpService = game:GetService("HttpService");
local remote = game.ReplicatedStorage.RemoteFunction
remote.OnServerInvoke = function(plr, UserId)
	local followers = {};
	local url = ("https://friends.roproxy.com/v1/users/%s/followers?limit=100"):format(tostring(UserId))
	local success, output = pcall(function() return HttpService:JSONDecode(HttpService:GetAsync(url)) end);
	if not (success) then
		return followers;
	end
	for _, v in pairs(output.data) do
		table.insert(followers, {
			name = v.name;
			displayName = v.displayName;
			userId = v.id;
		});
	end
	return followers;
end

how would i do this but for badges

1 Like

The code for getting the badges is very similar. This is what the api looks like:

image
image
image

For the url, this is what the format would look like: “https://badges.roproxy.com/v1/users/1020531782/badges?limit=100&sortOrder=Asc”.
I suggest you take a look at the api itself:Badges Api so you can see your options.

1 Like

Hello, you said the code was similar. What exactly is the code for it?

i tried doing this:

local HttpService = game:GetService("HttpService");
local remote = game.ReplicatedStorage.Badges
remote.OnServerInvoke = function(plr, UserId)
	local followers = {};
	local url = ("https://friends.roproxy.com/v1/users/%s/followers?limit=100"):format(tostring(UserId))
	local success, output = pcall(function() return HttpService:JSONDecode(HttpService:GetAsync(url)) end);
	if not (success) then
		return followers;
	end
	for _, v in pairs(output.data) do
		table.insert(followers, {
			name = v.name;
			displayName = v.displayName;
			userId = v.id;
		});
	end
	return followers;
end

however it did not give me the players badges

Did you read my post?


1 Like
local HttpService = game:GetService("HttpService");
local remote = game.ReplicatedStorage.Badges
remote.OnServerInvoke = function(plr, UserId)
	local followers = {};
	local url = ("https://badges.roproxy.com/v1/users/1020531782/badges?limit=100&sortOrder=Asc"):format(tostring(UserId))
	local success, output = pcall(function() return HttpService:JSONDecode(HttpService:GetAsync(url)) end);
	if not (success) then
		return followers;
	end
	for _, v in pairs(output.data) do
		table.insert(followers, {
			name = v.name;
			displayName = v.displayName;
			userId = v.id;
		});
	end
	return followers;
end 

hey this isnt working either…

add a print state to the output and tell me what it says

it says
21:53:36.618 ▼ {
[“displayName”] = “First Join”,
[“name”] = “First Join”,
[“userId”] = 1011040086
}

I looked at my badges and i have like 1000

Oh wait the reason i was only getting the badge named “First join” is because when i was calling the badge i said Name instead of name which stopped the code only giving me the first badge which was “first join”

Thanks for the help!

By the way, make sure you replace the “1020531782” after “users/” with a “%s” so you can use the UserId to format

thanks

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee