How to use APIs?

Do you know of any other APIs that allow you getting favorites? I haven’t seen any yet but at the same time I haven’t really looked too much either. Roblox loves their gosh darn cookies if you get.
Yeah, cookies must expire after a certain amount of time or else they wouldn’t be so secure. It’s a pain and I really wish Roblox added in bots that are similar to discord for stuff like this.

2 Likes

I can agree that Roblox should add some features that don’t require a cookie. I’d like to see a system similar to google’s one day, where some would require an API key or Oath 2.0 to even send requests to the API, so then Roblox can easily suspend suspicious API’s, and I actually do not know of any other API’s for that stuff, but I will begin some research to find some.

Well do you only need to get one games favorite count?
If you only need ones then you can get the unverseId by just going to this link and copying the universeId from what it returns:
https://games.roblox.com/v1/games/multiget-place-details?placeIds=0
Then you can change the URL in the script to this:

local HttpProxy = require(game.Workspace.HttpProxyService:Clone());
local universeId = 0;

local placeDetails = game.HttpService:JSONEncode(HttpProxy:GetAsync("https://games.roblox.com/v1/games/"..universeId.."/favorites/count"));

This in theory (I haven’t tested) should return the favorite count for one place.

If you have any more questions it’d probably be best to take it to DMs as it is getting slightly off-topic.

I would advise reading this reply to a thread;

If you can add some simple modifications, you can make this work for favorites.

So wait, can I do this for multiple games?

I wanted BSS, and then for example (not real), Vesteria and Bubble Gum Simulator.

Would I just use multiple instances of this same script?

Yes, you could probably do that if you changed the universeIds for all of them. There may be some HttpService restrictions but I doubt any would be so restricting.

Sweet! I’ll test now. Thanks so much!

Nope, it didn’t work. Is there a way to do this without APIs?

Looking back, since you can’t make requests to Roblox’s APIs from in a game, you could make a wrapper in NodeJS and Express to make a request to the Roblox API from a Roblox game.

var express = require("express"); // Make sure you have express installed.
var fetch = require("node-fetch");
var app = express();

app.get("/favorites/:id", function(req, res) {
    const getData = async url => {
        var response = nil, json = nil
        try {
          response = await fetch(url);
          json = await response.json();
        } catch (error) {
            console.log(error);
        }
        if(response !== nil){
            return json
        }
    };
    var json = getData("https://games.roblox.com/v1/games/" + req.params.id + "/favorites/count");
    res.json(json); // Send the JSON as the response.
});

app.listen(8000)

Then, in a Roblox script:

local httpService = game:GetService("HttpService")

local data = httpService:GetAsync("http://[URL/IP]:8000/favorites/12345678")
data = httpService:JSONDecode(data)
local favCount = data.favoritesCount  -- The amount of favorites
print(favCount) -- 12
3 Likes