[v1.5.1] RBLX - Roblox Open Cloud & Web APIs for NodeJS

AssetManager is here!

About

The rblx library is meant for easy interactions with the Roblox Open Cloud & Web APIs. Currently, this includes all of the Open Cloud Assets API functions, Open Cloud Datastore API functions, Open Cloud OrderedDatastore API functions, Open Cloud Place Management API functions, Open Cloud MessagingService API functions, and almost all Web API functions.

Installation + Setup

Step 1

  • Install via npm: npm install rblx (includes type declarations)

Step 2 (optional, but more secure)

Create a new file* in the root of your project called .env with the following content:

RBXTKN= + your Open Cloud API key
RBXROBLOXSECURITY= + your bot account’s (do NOT use your own) .ROBLOXSECURITY token (cookie value)

*Don’t forget to add this .env file to your .gitignore!

Docs

Open Cloud

OpenCloudAssetManager {Class}

new OpenCloudAssetManager(id: number)

Creates a new OpenCloudUniverse object

OpenCloudAssetManager.authenticate(apikey: string)

Pass the API key through this function, or use the npm dotenv package and process.env.RBXTKN from above

OpenCloudAssetManager.createAsset(assetType: Util.AssetType, filePath: string, name: string, desc: string)

Create a new asset

OpenCloudAssetManager.getOperation(id: string)

Get operation data related to an asset uplooad

OpenCloudAssetManager.updateAsset(assetId: number, filePath: string)

Update an asset (currently locked to only Models on Roblox’s end)

OpenCloudUniverse {Class}

new OpenCloudUniverse(id: number)

Creates a new OpenCloudUniverse object

OpenCloudUniverse.authenticate(apikey: string)

Pass the API key through this function, or use the npm dotenv package and process.env.RBXTKN from above

OpenCloudUniverse.getDatastores(limit?: number, prefix?: string, cursor?: string)

Return an object containing the previous page cursor, next page cursor, and datastore objects.

OpenCloudUniverse.getOrderedDatastore(name: string, scope: string)

Return an OrderedDataStore.

OpenCloudUniverse.save(placeId: number, pathToFile: string)

Save the rblx file located at pathToFile to Roblox, therefore not publishing.

OpenCloudUniverse.publish(placeId: number, pathToFile: string)

Publish the rblx file located at pathToFile to Roblox, therefore also saving to Roblox.

OpenCloudUniverse.publishToTopic(topic: string, data: any)

Publish some data to a MessagingService topic (this only works in Live Servers as of 7/8/22)

OpenCloudDataStore {Class}

new OpenCloudDataStore(uid: number, name: string, scope: string = "global")

Creates a new OpenCloudDataStore class - THIS IS NOT MEANT TO BE CALLED MANUALLY

OpenCloudDataStore.authenticate(apikey: string)

Authenticate the OpenCloudDataStore with your API key

OpenCloudDataStore.listKeys(limit?: number | LimitOptions, allScopes?: boolean, prefix?: string, cursor?: string)

IF LIMIT IS NUMBER: Return an object containing the previous page cursor, next page cursor, and keys on the current page

IF LIMIT IS LIMITOPTIONS: Return an object with the number of keys specified

LimitOptions is used if you want to receive the number of keys you made as the limit. The intended functionality of Roblox’s limit parameter does not guarantee you will receive as many keys as you have requested, but using LimitOptions instead of a number value will do so.

LimitOptions follows this schema:

{
    limit: number,
    useV2Limit: boolean // true to get all keys specified
}

OpenCloudDataStore.get(key: string)

Get the value of a key

OpenCloudDataStore.set(key: string, value: any = null, exclusiveCreate?: boolean, matchVersion?: string)

Set/update the value of a key

NOTE: You cannot use exclusiveCreate and matchVersion in the same request!

OpenCloudDataStore.increment(key: string, incrementBy: number = 1)

Increment a value by incrementBy units

OpenCloudDataStore.delete(key: string)

Delete a key from the OpenCloudDataStore

OpenCloudDataStore.listVersions(key: string, limit: number = 1, sortOrder: 'Ascending'|'Descending' = 'Ascending', cursor?: string, startTime?: string, endTime?: string)

List all versions of a key (with versionIds for getting)

Note: startTime and endTime must be ISO dates in UTC time!

OpenCloudDataStore.getVersion(key: string, versionId: string)

Get the value of key at version versionId

OpenCloudOrderedDataStore {Class}

new OpenCloudOrderedDataStore(uid: number, name: string, scope: string = "global")

Creates a new OpenCloudOrderedDataStore class - THIS IS NOT MEANT TO BE CALLED MANUALLY

OpenCloudOrderedDataStore.authenticate(apikey: string)

Authenticate the OpenCloudOrderedDataStore with your API key

OpenCloudOrderedDataStore.listEntries(maxPageSize: number, cursor: string, order: OrderType, filter: string)

List all entries in an OpenCloudOrderedDataStore

OpenCloudOrderedDataStore.createEntry(id: string, value: number)

Create a new entry in an OpenCloudOrderedDataStore

OpenCloudOrderedDataStore.getEntry(id: string)

Get an entry from an OpenCloudOrderedDataStore

OpenCloudOrderedDataStore.deleteEntry(id: string)

Delete a new entry from an OpenCloudOrderedDataStore

OpenCloudOrderedDataStore.updateEntry(id: string, value: number, allowMissing: boolean = true)

Update an entry in an OpenCloudOrderedDataStore

OpenCloudOrderedDataStore.incrementEntry(id: string, amount: number)

Increment an entry in an OpenCloudOrderedDataStore by a certain amount

Web API

Client {Class}

new Client()

Creates a new Client class

Client.login(token: string)

Authenticate the Client with your .ROBLOSECURITY token (recommended: store in .env file)

Client.acceptRequest(userId: number)

Accept a friend request from userId

Client.acceptTrade(tradeId: number)

Accept a trade of id tradeId

Client.addFriend(userId: number)

Send a friend request to userId

Client.block(userId: number)

Block :x: userId

Client.canTradeWith(userId: number)

See if you can trade with userId

Client.claimOwnership(groupId: number)

Claim ownership of group groupId

Client.counterTrade(tradeId: number, offers: TradeOffer[])

Counter a trade of id tradeId with your offers

Client.declineAllRequests()

Decline all friend requests

Client.declineRequest(userId: number)

Decline a friend request from a single user of id userId

Client.declineTrade(tradeId: number)

Decline trade of id tradeId

Client.getBirthdate()

Get your account’s birthdate

Client.getConsecutiveLoginDays()

Get your account’s (xbox) consecutive login days

Client.getDescription()

Get your account’s description

Client.getDisplayName()

Get your account’s display name

Client.getFriendCount()

Get your account’s friend count

Client.getFriendRequests()

Get your account’s friend requests

Client.getFriendRequestsCount()

Get your account’s number of friend requests

Client.getGender()

Get your account’s gender

Client.getLocale()

Get your account’s locale (language)

Client.getPhone()

Get your account’s phone number (if applicable)

Client.getPromotionChannels()

Get your account’s social links (if applicable)

Client.getStatus()

Get your account’s status

Client.getTrade(tradeId: number)

Get a trade with id tradeId

Client.getTrades(tradeStatusType: TradeStatus = TradeStatus.Inbound)

Get your account’s trades

Client.getTradesCount(tradeStatusType: TradeStatus = TradeStatus.Inbound)

Get your account’s trades count

Client.getUserId()

Get your account’s user id

Client.getUsername()

Get your account’s username

Client.isFollowing(userId: number)

Check if you are following userId

Client.removeFriend(userId: number)

Remove friend with id userId

Client.removePrimaryGroup()

Remove your primary group

Client.sendTrade(offers: TradeOffer[])

Send trades (specify who in the form of an id in the offers parameter’s options)

Client.setBirthdate(birthdate: Birthdate)

Set your account’s birthdate

Client.setDescription(description: string)

Set your account’s description

Client.setDisplayName(displayName: string)

Set your account’s display name

Client.setGender(gender: Gender)

Set your account’s gender

Client.setPrimaryGroup(groupId: number)

Set your account’s primary group to the group of id groupId

Client.setPromotionChannels(tbl: { [key: string]: string }, privacy: PromotionChannelPrivacy)

Set your account’s social links

Client.setStatus(status: string)

Set your account’s status

Client.unblock(userId: number)

Unblock the user of id userId

Example Usage

// Open Cloud
const { OpenCloudUniverse } = require('rblx');

let uni = new OpenCloudUniverse(0000);
uni.authenticate(process.env.RBXTKN);

let dstore = (await uni.getDatastores(1)).datastores[0];
let newKey = await dstore.set('newkey', 100);

await dstore.increment('newkey', 50);

let newValue = await dstore.get('newkey');

console.log(newValue); // 150

// Web API
const { Client } = require('rblx')

let bot = new Client();
bot.login(process.env.RBXROBLOXSECURITY)
	.then(async () => {
		let status = await bot.getStatus();
		let newStatus = status.replace('day 1', 'day 2');
		await bot.setStatus(newStatus);
	});

Links

Closing

Thanks for reading! If you have any suggestions or bug reports, please file an issue on GitHub and I’ll get back to you ASAP!

24 Likes

This is great!
I appreciate you open sourcing it.

Version 1.2.0

The Web APIs have finally been brought to rblx - it’s no longer just an Open Cloud library! Use the Client class to interact with your bot account and do actions such as updating your status and sending friend requests.

Please read the updated docs for more information.

1 Like

Omg this is sooooo much easier to use than others like noblox.js.

You are my hero. Thanks!

This is really nice module, Thanks

Version 1.3.0

MessagingService has been added to rblx

Datastore.listKeys now has a second option for the limit parameter if you want to return the number of keys that limit specifies

Please read the updated docs for more information.

3 Likes

Can you please tell me where the documentation is for MessagingService in Rblx? :slightly_smiling_face:

I don’t see it in the OP.

It’s under the OpenCloudUniverse class documentation, labelled as publishToTopic(topic: string, data: any)

1 Like

How would I subscribe to a topic?

Please update this with the new APIs!

I’ve been working on a patch, should be finished tomorrow.

1 Like

Awesome, thank you! been using this on my server to get stats from my game :stuck_out_tongue:

1 Like

Version 1.4.0

OrderedDataStore has been added to rblx

I haven’t finished adding the Assets API, but I figured I might as well push OrderedDataStores ASAP.

Please read the updated docs for more information.

(cc: @clxr)

1 Like

Version 1.4.1

OpenCloudUniverse.getOrderedDataStore was mistakenly omitted from the docs

Please read the updated docs for more information.

Version 1.4.2

OpenCloudOrderedDataStore was never exported from index.ts

There have been no changes to the docs.

It doesn’t really work, when I try logging into my rank bot, it disconnects me and it says that the token is not correct or something simmilar.

Also this,

-- TypeError: obj.toJSON is not a function
 obj = obj.toJSON();

Could you DM me specific info related to the bug, such as the surrounding code in the obj.toJSON instance?

If you run the code normally from the client example, on a replit cluster, , you’ll see the error too.

AND YES I DID INFACT PUT MY RANK BOT’S TOKEN.

Version 1.5.0

AssetManager has been added to rblx

Please read the updated docs for more information.