How to use Roblox API with glitch?

I want to do Roblox API things like getting player follower amounts, games

I tried to do this but I have no idea how to access Roblox API

I tried to use glitch and noblox.js, and if I’m right I can use noblox.js now. But I still don’t know how to actually do the get follower thing.


The API page is kinda confusing for me to understand
Can someone tell me how to use the API on the Glitch script??

To get the followers of a user with the noblox package, you can do this:

  1. Login to Roblox in an incognito tab - this is required otherwise your cookie will expire.
  2. Open inspect element (ctrl+shift+i on most browsers, or right-click)
  3. Copy your ROBLOSECURITY token
  4. Use the example code to login
const noblox = require("noblox.js");
async function startApp() {
    const currUser = await noblox.setCookie("yourRobloSecurityCookie");
    
    let userInfo = await noblox.getPlayerInfo(userId);
    let followerCount = userInfo.followerCount;
    console.log(followerCount);
}

This is a very minimal example, and just displays the first thing you mentioned.

Read noblox.js.org for documentation on the package.

How to call it from Roblox script?

Set up a RESTful api - for that you’ll have to look more into Fastify for your webserver (or pick your own, Fastify is Glitch’s default though) and HTTPService

For example, on glitch:

const fastify = require("fastify", { logger: false });

fastify.get("/api/path", function(req, res) {
    // do stuff here, req will be the request object, and res will be the response object
});

from Roblox:

local HttpService = game:GetService("HttpService")

HttpService:GetAsync("https://your-project.glitch.me/api/path");

You may want to implement credentials and such too - I recommend looking at an actual node.js guide however.

Thank you so much I will try them later!

1 Like

Wait so one glitch project can only do one task?

No, you can add extra stuff. Example:

const fastify = require("fastify", { logger: false });

fastify.get("/api/path/1", function(req, res) {
    // do stuff here, req will be the request object, and res will be the response object
});

fastify.get("/api/path/2", function(req, res) {
    // do stuff here, req will be the request object, and res will be the response object
});

Then just make sure you use the right URL in your GET request on Roblox.

Or you could use query strings, headers and bodies to use one URL for everything but it’s much cleaner and easier to use multiple.