Bloxy - Roblox Web API Library

image

Introduction

Hello, everyone, my name is Martin, and today I have created yet another resource that’s open for the public. Today, I’m introducing an open-sourced library (“wrapper”), bloxy, to interact with Roblox’s Web API endpoints.

If you have ever heard of “noblox” or “roblox.js”, this is a library that wants in on the fun. Bloxy basically handles everything related to making / sending requests to Roblox, so you don’t have to worry about that.

Features

Why consider using bloxy, compared to the alternatives:

  • It’s open-sourced and written in TypeScript (:tada:)
  • It’s object-oriented in a “discord.js fashion”
  • It’s got the highest coverage of the Roblox Web APIs to date. *1
  • Most endpoints added have typings, both for the options but also for the response.
  • It’s implemented with CI and tests, which means that it’s more reliable, and once an endpoint changes, we’ll know *2

*1: As of 23/08/2020, bloxy has the most APIs added compared to the most popular alternatives on NPM

*2: Even though we’re trying to test as much as possible, testing web endpoints is never easy, but where it’s possible and viable, we have added tests


Typings on APIs

(You can see the amount of APIs added)

(Detailed typings)

Installation & Setting Up

Now, it’s not a big deal to install bloxy, either. Once you have Node.JS and NPM installed, execute the following command and it’ll be installed:

npm install bloxy --save

In order to log in with bloxy, you need to fetch your .ROBLOSECURITY cookie, as it provides instantaneous access to your account, and does not need captcha-solving. Once you’ve installed bloxy and retrieved your cookie, you can see the video below for a quick example on how to log in!

Code
const COOKIE = "[REDACTED]";
const bloxy = require("bloxy");

// Creating an async environment

(async () => {
    const client = new bloxy.Client({
        credentials: {
            cookie: COOKIE
        }
    });

    const authenticatedUser = await client.login();
    console.log(`Logged in as ${authenticatedUser.name} (${authenticatedUser.id})`)
})();

Example usages

Now, to allow you to see how great bloxy really is, we’ve got to add some examples!

Getting a group's funds
// Async environment //

const bloxy = require("bloxy");
const client = new bloxy.Client({
    credentials: {
        cookie: "your cookie"
    }
});

const group = await client.getGroup(123);
const funds = await group.getFunds();

console.log(`Group ${group.name} has ${funds} Robux in funds!`);
Giving a user a role
const bloxy = require("bloxy");
const client = new bloxy.Client({
    credentials: {
        cookie: "cookie"
    }
});
 
await client.login();
 
const group = await client.getGroup(6969);
await group.updateMember(
    321, // User id
    123 // Role id
);

Notes

  • Bloxy is still under development, and bugs may occur. If you do find any, please, open an issue on the GitHub page or reach out to me.
  • Since bloxy still is in development, documentation is not at its best, however, it’s definitely being worked on. You do have access to the typings and all of that to help you, though.
  • If you encounter an issue, need help, or want to talk about Roblox API in general, feel free to visit this Discord server
34 Likes

Very nice.
Just a few questions though.

How often does the token from Roblox get reset by this application? noblox tends to reset it occasionally.
How does this package handle API errors? Are they thrown as new Error() or are they caught with .catch?
Does this package support the usage of .then with promises or do we need to wrap that in its own container to allow other code to run around it?

Appreciate the questions,

First of all, the CSRF token is refreshed in an unknown interval, I’ve found that refreshing it every 5 minutes works fine, however, if a request does fail because of the token, it will retrieve a new one and retry.

Once you experience API errors, bloxy does provide a somewhat detailed description of the issue, along with potential troubleshooting steps.

The module is implemented in an async way, meaning, there are only promises (.then and .catch) and no callbacks.

2 Likes

Looks really good!
Looks nice and easy to use, thank you for this contribution!

i love bloxy best library i love martini noob <3