Using the Roblox Api On Glitch.com!(proxy) - A long tutorial (Noblox.js wrapper and Cookie less)

The Roblox API is extremely powerful - it can be used to create anything from group ranking bots to game statistics websites.

As a developer, there are two main ways you’ll want to access the Roblox API: sending the requests yourself or using one of the multiple wrappers for your favorite programming language. In this tutorial, I’ll go over both methods on how to use a wrapper for it called noblox.js

If you don’t know anything about the Roblox Api I suggest you go to this Devforum Post.

THIS WILL BE A TUTORIAL ON HOW TO USE FUNCTIONS WHICH DON’T REQUIRE ANY LOGGING IN

What is Glitch.com?

Glitch.com is a free hosting service which allows us to keep our bots on a webserver.

Why do I need to use Glitch?

Well if say you wanted a ranking bot it wouldn’t be very good if it was running on your computer as it would be very hard to access. However with Glitch we can put that bot on a website and can then call it through HTTP Service. It is also great as you can get Roblox resources directly via get/post request which is something you can’t do in the game itself.

Getting Started

So first thing you need to do I go on to glitch.com and create an account. After that it would look a bit confusing however all you need to do is go up to the search bar next to New Project
image

type in “hello-express” and hit enter. Once you have done that you should see I a few results however press the first one with blue and red on.
image

After you have clicked it scroll down to where it says remix your own.

image

As soon as you press that it’s coding time.

The bits that make it work

So first thing you want to do is go to the server.js file press ctrl+a then delete.
After go to package.json and at the top where it says add package just click that type in noblox.js and the first one is all you need.
image

So now your code should look like this:

Apart from some version numbers and node type.

Finally go over to the public folder and where it says client.js press the 3 dots on the right of it and then delete.

Coding Time

Starting Express

So first thing first we need to start the app. We can do this by doing

const express = require("express")
const app = express();

app.use(express.static("public"));



const listener = app.listen(process.env.PORT, () => {
  console.log("Your app is listening on port " + listener.address().port);
});

The listener bit is required and your website will not update without it! :warning:

This is a start but now we need to get the certain urls working. So we can do:

const express = require("express")
const app = express();

app.use(express.static("public"));

app.get("/", function(req, res) { //req and res just mean response and request we can get onto them later
  res.send("Hi") //This will return Hi
});


const listener = app.listen(process.env.PORT, () => {
  console.log("Your app is listening on port " + listener.address().port);
});

and if we got to our page by pressing preview then “in new window” or as a preview pane it will show:
image

but we don’t want it just to show “Hi”.

Using Noblox.js

We want it to show/do roblox interactions so let’s just put this a side for a second. Now you could use axios for this but I will be making a different tutorial on that instead we will be using the wrapper noblox.js. It should already be installed in the package.json folder meaning we can do:

const noblox = require("noblox.js")

I suggest taking a look through the documentation as it is really helpful

So for the first bit we a going to make something which checks if a user owns an asset. We can do this by calling the getOwnership function

const noblox = require("noblox.js")

let ownership = noblox.getOwnership(1, 1402432199) // first bit is user id second is item/asset id and can be a third which is type of asset
console.log(ownership)

(You can view the console in glitch by pressing a button that says logs)

You should of gotten this response:

Promise { <pending> }

this is a good thing as it means that our app is working and noblox is doing it’s thing.
To fix this all we need to do is add they key word await this is so the program knows to not return anything until the promise has been returned however await has to been inside an async function so your could would look like this instead:

const noblox = require("noblox.js")

async function Start(){
let ownership = await noblox.getOwnership(1, 1402432199) // first bit is user id second is item/asset id and can be a third which is type of asset
console.log(ownership)
}
Start()

You should receive an output of true

There is another way however we can do this. As it is a promise we can use a .then function which will call when a value is defined meaning your code could also look like this:

const noblox = require("noblox.js")

async function Start(){
let ownership = noblox.getOwnership(1, 1402432199) // first bit is user id second is item/asset id and can be a third which is type of asset
.then(function(response){
console.log(response)
})

}
Start()

That should also say true. We can take this 1 step further aswell because if this function errored because we ran it to much then it would break the rest of the script however we can use the .catch function which is like a pcall in lua or just a function that when errored will not let anything else break.
Now your code could look like this:

const noblox = require("noblox.js")

async function Start(){
let ownership = noblox.getOwnership(1, 1402432199) // first bit is user id second is item/asset id and can be a third which is type of asset
.then(function(response){
console.log(response)
}).catch(function(error){
console.log(error)
})

}
Start()

Multiple functions

Say I wanted to do this twice but at different times then instead of making 2 separate projects we can use the different urls bit from earlier and so now we could do:

const express = require("express")
const app = express();

app.use(express.static("public"));


const noblox = require("noblox.js")

async function GetValk(){
let ownership = noblox.getOwnership(1, 1402432199) // first bit is user id second is item/asset id and can be a third which is type of asset
.then(function(response){
console.log(response)
}).catch(function(error){
console.log(error)
})

}

async function GetDominus(){
let ownership = noblox.getOwnership(1, 48545806) // first bit is user id second is item/asset id and can be a third which is type of asset
.then(function(response){
console.log(response)
}).catch(function(error){
console.log(error)
})

}

app.get("/Valk", function(req, res) { 
GetValk()
  res.send("Hi") //This will return Hi
});

app.get("/Dominus", function(req, res) { 
GetDominus()
  res.send("Hi") //This will return Hi
});

Accessing the url

So now pressing the preview in a new window button in the should bring up the page in the url after it says .me type either /Valk or /Dominus
image

Now once the page loads you might find that it is still saying “Hi” we don’t want this as HttpService won’t work so instead we need to make the functions return a value all we need to do is put return infront of response so:

async function GetValk(){
let ownership = noblox.getOwnership(1, 1402432199) // first bit is user id second is item/asset id and can be a third which is type of asset
.then(function(response){
console.log(response)
return response
}).catch(function(error){
console.log(error)
return "Error"
})

}

async function GetDominus(){
let ownership = noblox.getOwnership(1, 48545806) // first bit is user id second is item/asset id and can be a third which is type of asset
.then(function(response){
console.log(response)
return response
}).catch(function(error){
console.log(error)
return "Error"
})

}

Sadly that wouldn’t work so instead we have to revert a bit back to our old code so can do:

async function GetValk(){
let ownership = noblox.getOwnership(1, 1402432199) // first bit is user id second is item/asset id and can be a third which is type of asset
.then(function(response){
console.log(response)

}).catch(function(error){
console.log(error)
return "Error"
})
return ownership
}

async function GetDominus(){
let ownership = await noblox.getOwnership(1, 48545806) // first bit is user id second is item/asset id and can be a third which is type of asset
.then(function(response){
console.log(response)
  
}).catch(function(error){
console.log(error)
return "Error"
})
return ownership
}

Now that the functions return something in the url bits we can do:

app.get("/Valk", function(req, res) { 
let Result = GetValk()
  res.json(Result) //This will return if they have the valk
});

app.get("/Dominus", function(req, res) { 
let Result = GetDominus()
   res.json(Result) //This will return if they have the Dominus
});

All the code together:

const express = require("express")
const app = express();

app.use(express.static("public"));


const noblox = require("noblox.js")

async function GetValk(){
let ownership = noblox.getOwnership(1, 1402432199) // first bit is user id second is item/asset id and can be a third which is type of asset
.then(function(response){
console.log(response)
return response
}).catch(function(error){
console.log(error)
return "Error"
})

}

async function GetDominus(){
let ownership = noblox.getOwnership(1, 48545806) // first bit is user id second is item/asset id and can be a third which is type of asset
.then(function(response){
console.log(response)
return response
}).catch(function(error){
console.log(error)
return "Error"
})

}

app.get("/Valk", function(req, res) { 
let Result = GetValk()
  res.json(Result) //This will return if they have the valk
});

app.get("/Dominus", function(req, res) { 
let Result = GetDominus()
   res.json(Result) //This will return if they have the Dominus
});


//And don't forget the important bit!
const listener = app.listen(process.env.PORT, () => {
  console.log("Your app is listening on port " + listener.address().port);
});

Finished?

Now you might be thinking what about functions which require you to log in with cookies. Well this is already an EXTREMELY long tutorial so if you read it all so I shall be doing that on a different post very soon. Anywhere you basically already there I am sure in a few days you would know how to. :slight_smile:

Thank you and any questions please post down below also do account for any limits on glitch and noblox

7 Likes

Nice tutorial! It goes very in-depth in the code which is exactly how a tutorial should be. I’m sure that lots of people will earn from this tutorial :slight_smile:


I have a question:

What would be the use-case for using express to create a seperate endpoint rather than using noblox.js directly?

What I mean:

const noblox = require("noblox.js")

async function getOwnership() {
   const ownership = await noblox.getOwnership(1, 1402432199)
   return ownership
}

console.log(ownership)

Why would we go through the process of using express.js rather than using noblox.js directly like above?

1 Like

Express is the web framework that allows for HTTP requests to be sent to the API. noblox.js on the other hand is just a wrapper for the Roblox API.

1 Like

I’m aware of what they both are, but that doesn’t really answer my question given that noblox already handles the HTTP requests for you, hence the name “api wrapper”

1 Like

express allows you to do multiple functions on the same glitch page as you can just change the url. You could do it how you said but that would mean making loads of profjects/functions and then needing to access the via roblox httpService would be very hard

noblox.js only interacts with the Roblox API. Express handles the requests to the Glitch project.

1 Like

Ah, you’re referring to making a proxy. That makes sense.

Your title says using the roblox api on glitch, not on Studio.

I know what express does.

1 Like

Ok I will change the title to say it is a proxy

Hey there!

This is a great tutorial! Very helpful, and to the point, however I have leading questions for you.

  1. Is this supported for real-time interaction?
    → If so, you may want to use a different host provider, as Glitch is overly filled with traffic. Sending a POST/GET from ROBLOX < - > Glitch yields up to 2 minutes.

  2. If it isn’t supported, how long does it take for a request?
    → When sending a GET to glitch, how long is the response time?

1 Like

I currently use glitch for a group shout bot and it has about a 1-2 second delay. So idk how you get 2 mins wait

1 Like

Very interesting. I was just toying around with Glitch recently past day/or two, and was receiving yielded responses from glitch. Had roblox sent a GET to the site, and it either will yield or timeout.

+OP For the tutorial anyways

1 Like

Thanks first time making also I am planning to a release a script on mobile plugin which utilizes the glitch website.

1 Like

As long as you have lightning fast responses, you should be all set to go. Great release, and will stay tuned for updates.

1 Like

In your previous post, you asked why Express is used instead of noblox.js directly.

1 Like

(post deleted by author)

PSA: Stop using Roblox proxies! (roproxy, rprxy.xyz, rprxy) have you tried looking at this

1 Like

It doesn’t just work on glitch, it also works on replit if you type in these at the shell bar

npm install noblox.js
npm install express

As a replit user, Please add some information that it also works on replit :wink: though it’s mainly about preference than anything

Roblox GET requests have a timeout as well so there will always be a yielding time

you are correct however it can be useful to create multiple glitch accounts and multiple projects and a math.random to choose with project to use this is for ratelimits if your game is large, this is what roproxy does

1 Like

Is glitch.com safe? I have code that requires .ROBLOSECURITY cookie for some stuff, but when I execute the code sometimes I get logged of from my account and it says there is a new log in in Virginia, USA…