Grabbing player thumbnail

I’m unable to use the api endpoints at all, as every get request that contains a roblox cdn link just gets censored/removed.

These two methods did not work for me;

shared.getAvatarUrl = function(user)
	local thumbnail_request = string.format("https://thumbnails.roproxy.com/v1/users/avatar-headshot?userIds=%d&size=48x48&format=png", user.UserId)
	local response = http_service:RequestAsync({
		Url = thumbnail_request,
		Method = "GET"
	});
	local b = response.Body
	print(b)
	print(b:match('"https:\/\/tr.rbxcdn.com\/.+["]'):gsub('"', ""))
	
	return b:match('"https:\/\/tr.rbxcdn.com\/.+["]'):gsub('"', "")

	
end
shared.getAvatarUrl = function(user)
	local thumbnail_request = string.format("https://thumbnails.roproxy.com/v1/users/avatar-headshot?userIds=%d&size=48x48&format=png", user.UserId)
	local response = http_service:RequestAsync({
		Url = thumbnail_request,
		Method = "GET"
	});
	
	local data = http_service:JSONDecode(response.Body).data
	
	return data[1].imageUrl

	
end

I need the imageURL for a discord embed

1 Like

There is an official method for grabbing the thumbnail called Players/GetUserThumbnailAsync. Remember to wrap it in a pcall and send a fallback if it fails.

2 Likes

Here’s code that I used for a guilded embed:

local ThumbnailGet = HS:GetAsync("https://thumbnails.roproxy.com/v1/users/avatar-headshot?userIds="..UserID.."&size=48x48&format=Png&isCircular=false")

local data = HS:JSONDecode(ThumbnailGet).data[1]
local imageURL = data.imageUrl

Does this work?

1 Like

Doesn’t work for me, check the thread. I’m doing the same thing as you but for some reason when I print out the body I don’t get the whole headshot link

1 Like

The reason I suggested it was because the behavior could differ from RequestAsync.
Are you sure you are inputting the UserID correctly? Did you try what I sent?
I need a bit more info to help.

1 Like

I tried it and same result, it works in roblox Studio but not when I join the actual published place…

1 Like

Sorry to bump but I would like to know if anyone has figured out what could be done as a workaround for this. I’m dealing with the same thing, so I’m pretty dumbfounded.
Here is an image of what im doing,
image
And here are some images comparing the response body on the website and the response body in-game,


I have a part on the workspace with a decal inside of it shaped like a picture.

--local script
local Player = game:GetService("Players").LocalPlayer
local userid = Player.UserId
local image = game.Players:GetUserThumbnailAsync(userid,Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)
workspace.Pic.Decal.Texture = image

This is a snippet of it being used with a highscore board.

local pages = dataKey:GetSortedAsync(false, 100, 1, 10e15) -- 10e30                           -- T↓/F↑, 1-100, Lowest, Highest
	local page, data = pages:GetCurrentPage(), {}                                             -- First page / Create new data
	for _, dat in ipairs(page) do                                                             -- Loop through data
		local username = "[Failed To Load]"                                                   -- preset		
		local userid, points = dat.key , dat.value                                            -- User
		local suc, err = pcall(function()                                                     -- Get username
			username = game.Players:GetNameFromUserIdAsync(userid)
		end) if suc == true then -- add user image to table
			local image = game.Players:GetUserThumbnailAsync(userid,
				Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)                  -- Add player image
			table.insert(data, {username, points, image})
		else warn("Getting name for "..userid..". Error: "..err)
		end
	end

This is not the full script but it is showing how to slip this in a highscore board.

Just found out that the value for “imageUrl” does get provided when you get it in the script, you just cannot print it into the console (which is weird)