HTTP service not allowed to access ROBLOX resources?

Hello!
So I heard about API and im REALLY interested in it. So I started using the API services today…
The first task which is to find out how many friends you got in your roblox profile!
using this document (Roblox offical document)
after reading its information. I attempt to write this code:

wait()

local url = "https://friends.roblox.com/v1/my/friends/count"

local httpservice = game:GetService("HttpService")

local response = httpservice:GetAsync(url)

local data = httpservice:JSONDecode(response)

if data.message == "success" then

print(data.count)

end

The problem is when i finished it. It throws me an error:
image
Since this is my first to encounter the API. I have no idea how to fix it

I read the API carefully and other devforum topics. But nothing seems to work :frowning:

Please help!

A proxy is required to use APIs when working with HTTP in Studio. A good proxy is www.roproxy.com, and you should use friends.roproxy.com instead of friends.roblox.com.

1 Like

Thanks let me try real quick! :smiley: :smiley: :smiley:

Ahh it is HTTP 403 Forbidden code. How do I fix it?

Go to game settings in studio (home) and in security turn on http services

1 Like

image
I opended, nothing seems to work :frowning:

That was the only thing i could help you with lol :smiley:

I never really did anything with HTTP services so i can’t really help you, sorry

1 Like

You might need to use this: friends.roproxy.com/v1/users/PUT_USER_ID_HERE/friends/count. You just need to get the ID of a player.

My guess as to why the previous link doesn’t work might be because it requires something browsers typically have, which Studio doesn’t (maybe login cookies)?

1 Like

It doesnt work :frowning: , instead got the first error here
image

The roproxy link that you’ve send me.


Im pretty sure thats the reason with the forbidden?

Replace “PUT_USER_ID_HERE” with the player’s user ID. That’s what I meant when I said “get the ID of a player.”

1 Like
wait(7)

print("Loaded!")

local url = "friends.roproxy.com/v1/users/2036013757/friends/count"

local httpservice = game:GetService("HttpService")

local response = httpservice:GetAsync(url)

local data = httpservice:JSONDecode(response)

if data.message == "success" then

local count = data.count

game.Workspace:WaitForChild("Part").SurfaceGui.TextLabel.Text = tostring(count)

else

print("Not sucess..")

end

The new code (i use my own id)

1 Like

Ah, it appears that using the v1/users/ID/friends/ or v1/users/ID/friends/count is actually restricted.

Alternatively, you can use this link for counting followers. Just replace PUT_YOUR_ID_HERE again with an ID.
friends.roproxy.com/v1/users/PUT_YOUR_ID_HERE/followers/count

Or with a non-HTTP method, get friend count:
https://developer.roblox.com/en-us/api-reference/function/Players/GetFriendsAsync

1 Like

Tried the roblox id instead.


Game ouput:

But this time. The roxproxy api wasnt declined.

Forgot the code:

wait(7)

print("Loaded!")

local id = '2036013757'

local url = "friends.roproxy.com/v1/user/1/followers/count"

local httpservice = game:GetService("HttpService")

local response = httpservice:GetAsync(url)

local data = httpservice:JSONDecode(response)

if data.message == "success" then

local count = data.count

game.Workspace:WaitForChild("Part").SurfaceGui.TextLabel.Text = tostring(count)

else

print("Not sucess..")

end

Whoops, I may have mistyped the link. It’s supposed to be v1/users, not v1/user. I’ll edit my post.

2 Likes


You’re soooo AMAZING
AFTER A LONG WORK. Thanks!

However some is not useable like /friends
however, it still works! Thanks!!! You made my day

2 Likes