Hey everyone! I have never used APIs before, so I was wondering if someone can explain how to use this API here?
https://games.roblox.com/docs#!/Favorites/get_v1_games_universeId_favorites_count
It would be greatly appreciated. Thanks!
Hey everyone! I have never used APIs before, so I was wondering if someone can explain how to use this API here?
https://games.roblox.com/docs#!/Favorites/get_v1_games_universeId_favorites_count
It would be greatly appreciated. Thanks!
If you’re talking about how to get the univserseId to put into it then you can get it with this. Just get the placeId from the game page link and copy the universeId into it.
If you’re talking about how to get it from inside a Roblox script then you’d have to use a proxy as Roblox disallows you from sending requests to its own server.
Hey there!
How can I make/get a proxy?
You would have to host your own web server that you send a request to from Roblox, then it sends a request to the API endpoint, then goes back down the chain. You may be able to host a free one with glitch.me or heroku. There may be one out there but I haven’t seen any yet.
You may actually be able to use this tutorial to get what you need.
Hey there! I looked over the tutorial and I’m just curious, what link would I use?
(As in, how can I provide a PlaceID for the UniverseID one?)
local HttpProxy = require(game.Workspace.HttpProxyService:Clone());
local placeId = 920587237;
local placeDetails = game.HttpService:JSONEncode(HttpProxy:GetAsync("https://games.roblox.com/v1/games/multiget-place-details?placeIds="..placeId));
From placeDetails you can decode what it returns and get the universeId from there. Here is an example of what it would send back.
Hello!
I keep getting, " [18:33:14.053 - Argument 1 missing or nil]" in my output. Is there a fix?
What is your current script and what line is the error on?
I just copied your script to see if this worked, and it’s line 4 (bottom)
Let me try to get my own example running and I’ll post a reply to this thread when I get it working.
Alright, thanks! I will wait for you before trying to make any changes, as I might screw it up.
Not sure if this applies here, but can’t you just use the endpoint (URL) from a script? E.G. Avatar image endpoints? Also, have you tried turning studio api access on in the game’s settings?
Whoops! Completely wrong way to read it! My bad.
I’m not sure, I’m completely new to APIs.
After looking at the error on the google script side of things, it appears you need to be authenticated in order to use this endpoint. You’d have to write code that provides a cookie on a bot account which involves setting Cookie header and updating the cookie every once in a while.
This means that it is technically still possible, but you’d have to look more into the Google api that is in the google script project.
This is a very bad idea, I highly recommend investing into a service, or using free hosting services for a proxy, instead of going above and beyond to get something simple to work.
You need to use HTTP Requests. (YOU CAN NOT MAKE HTTP REQUESTS TO *.roblox.com IN ROBLOX’S LUA!) HttpService | Documentation - Roblox Creator Hub
But, here’s how you’d go about that, with any other API:
local httpService = game:GetService("HttpService")
local url = "https://https://games.roblox.com/v1/games"
local data = httpService:GetAsync(url .. "/920587237/favorites/count") -- Adopt Me
data = httpService:JSONDecode(data)
print(data.favoritesCount) -- 5,833,570
First problem is that I’m 99% sure Roblox doesn’t allow http requests to their own servers so they don’t dos themselves. Secondly, the problem with what was happening before is that when you send a request through your browser it automatically sends the Cookie header which has all the cookies for the website you’re on. It includes an authorization token that Roblox can verify your user with instead of asking for your username and password for every request you go to. Getting the amount of favorites requires this cookie for some reason.
At one point, this cookie method wont work. I’d just refrain using these API’s, and attempting to find new ones. Cookies don’t stay the same and valid all the time, unless you are constantly changing the ROBLOSECURITY whilst it changes then you will not be able to have a constantly working system. This is because I am pretty sure that Roblox’s cookies change in events of sign out all users, or even after a certain time.
Right, I completely forgot about that. I’ll make an edit.
Will this just be impossible to make then?