A Roblox OpenCloud API wrapper for Deno (and NodeJS) written in TypeScript.

Overview

Active Development

This module is currently in active development. Nothing is going to stay consistent as it reaches a stable release.

Dynablox

Docs | deno.land/x | NPM

An API wrapper for the OpenCloud Roblox API using the Deno runtime (with full web compatibility and mostly NodeJS compatbility).

This is a stripped-down version of the original library, for Open Cloud.

Installation

Node Installation

Steps to install Node can be found here.
Run npm install @dynabloxjs/opencloud to install.

Import it with CommonJS:

const dynablox = require("@dynabloxjs/opencloud");

or ESModule:

import * as dynablox from "@dynabloxjs/opencloud";

For pre-release builds:

Run npm install dynabloxjs/dynablox_opencloud#node to install.

Deno Installation

Steps to install Deno can be found here.

Unlike Node or Python, Deno modules only need to be imported via a path (and then cached).

Once you have done the necessary steps, import it:

import * as dynablox from "https://deno.land/x/dynablox_opencloud/mod.ts";

NOTE: You can also specify a version by appending @{version} to the module name.

... and it's done! Only the --allow-net flag is needed for Dynablox Open Cloud, see more information about flags in the Deno manual.

For pre-release builds:

Replace https://deno.land/x/dynablox_opencloud/mod.ts with https://raw.githubusercontent.com/dynabloxjs/dynablox_opencloud/main/mod.ts, or clone onto your machine and import mod.ts from the downloaded folder in your code.

Starting Guide

NOTE: If you are not using tooling, you are silly.

All Uses (Functional Programming)

In BaseClient, there is almost no usage of OOP. All APIs on Open Cloud endpoints can be accessed via <BaseClient>.services, though with little documentation.

Import BaseClient from the module entrypoint, either the module name (NodeJS) or mod.ts (Deno) Construct a new BaseClient with either API key or other credentials.

const client = new BaseClient({
    credentials: {
        type: "APIKey",
        value: "APIKEYHERE"
    }
})

Open Cloud (API Key, OOP)

In OpenCloudClient, it is mostly object-orientated, with all methods available on <OpenCloudClient> with clear documentation, though APIs on Open Cloud endpoints are still accessible via <BaseClient>.services.

Import OpenCloudClient from the module entrypoint, either the module name (NodeJS) or mod.ts (Deno) Construct a new OpenCloudClient with your APIKey.

const client = new OpenCloudClient({
    credentialsValue: "APIKEYHERE",
})

Permission Scopes

It is also possible to define scopes to tell the client what and what it can not access. This is similar to the actual Scopes system Roblox uses for OpenCloud and oAuth.

By default, all scopes are allowed.

const client = new OpenCloudClient({
    credentialsValue: "APIKEYHERE",
    scopes: [{
        // The scope type, see TSDoc for more options.
        scopeType: "universe-datastores.objects",
        // Allows for universe ID 13058 and datastoreName.
        // a Target part can also be "*" to allow all. Some target parts may be optional.
        targetParts: ["13058", "datastoreName"],
        // Allows for reading entry values in the DataStore.
        operations: ["read"],
        // NOTE: this is optional. If set to `true`, `operations` is ignored.
        allowAllOperations: false,
    }]
})

Ratelimiting

the OpenCloudClient also has a built-in ratelimit helper. If a ratelimit is reached, it will throw an OpenCloudClientError.

You can opt in for yielding behavior by setting ratelimiterShouldYield to true:

const client = new OpenCloudClient({
    credentialsValue: "APIKEYHERE",
    ratelimiterShouldYield: true,
})

It also exposes the Ratelimiter helper publicly, so you can have mutiple OpenCloudClients using the same ratelimit helper instance:

const client1 = new OpenCloudClient({
    credentialsValue: "APIKEYHERE",
});

const client2 = new OpenCloudClient({
    credentialsValue: "APIKEYHERE",
    ratelimiter: client1.ratelimiter,
});

Examples

Publishing a Place
Deno
import { OpenCloudClient } from "https://deno.land/x/dynablox_opencloud/mod.ts";

const client = new OpenCloudClient({
    credentialsValue: "APIKEYHERE",
    scopes: [{
        // Tell the client we have access to updating place data in the universe 13058, and no other universe.
        type: "universe-places",
        targetParts: ["13058"],
        operations: ["write"],
    }],
});

// The methods have "base" because it doesn't actually make any HTTP requests.
const place = client.getBaseUniverse(13058).getBasePlace(1818);

const fileData = await Deno.readFile("./place.rbxl");

// Updates the content of the place for the Saved version type.
const placeVersion = await place.updateContents(fileData, "Saved");

console.log(`Updated place to version ${placeVersion}`);
NodeJS
const { OpenCloudClient } = require("@dynabloxjs/opencloud");
const fs = require("fs/promises");

const client = new OpenCloudClient({
    credentialsValue: "APIKEYHERE",
    scopes: [{
        // Tell the client we have access to updating place data in the universe 13058, and no other universe.
        type: "universe-places",
        targetParts: ["13058"],
        operations: ["write"],
    }],
});

// The methods have "base" because it doesn't actually make any HTTP requests.
const place = client.getBaseUniverse(13058).getBasePlace(1818);

(async () => {
    const fileData = await fs.readFile("./place.rbxl");
    
    // Updates the content of the place for the Saved version type.
    const placeVersion = await place.updateContents(fileData, "Saved");
    
    console.log(`Updated place to version ${placeVersion}`);
})();
Accessing DataStores
Deno
import { OpenCloudClient } from "https://deno.land/x/dynablox_opencloud/mod.ts";

const client = new OpenCloudClient({
    credentialsValue: "APIKEYHERE",
    scopes: [{
        // Tell the client we have access to reading and listing DataStore objects on universe 13058 and not any other universe.
        type: "universe-datastores.objects",
        targetParts: ["13058"],
        operations: ["read", "list"],
    }],
});

// The method has "base" because it doesn't actually make any HTTP requests.
const datastore = client.getBaseUniverse(13058).getStandardDataStore("TestStore");

// `ServicePage` has an async iterator implementation, let's use it.
for await (const keys of datastore.listEntries()) {
    keys.forEach(({key}) => {
        console.log(key);
        if (key.startsWith("Player")) {
            const data = await datastore.getEntry(key);

            console.log(`${key} data length: ${JSON.stringify(data).length}`);
        }
    });
}

// Or:
// const keys = await datastore.listEntries().getCurrentPage();
// keys.data.forEach(({key}) => ...);
// Get more data:
// const moreKeys = await keys.getNextPage();
// moreKeys.data.forEach(({key}) => ...);
NodeJS
const { OpenCloudClient } = require("@dynabloxjs/opencloud");

const client = new OpenCloudClient({
    credentialsValue: "APIKEYHERE",
    scopes: [{
        // Tell the client we have access to reading and listing DataStore objects on universe 13058 and not any other universe.
        type: "universe-datastores.objects",
        targetParts: ["13058"],
        operations: ["read", "list"],
    }],
});

// The method has "base" because it doesn't actually make any HTTP requests.
const datastore = client.getBaseUniverse(13058).getStandardDataStore("TestStore");

(async () => {
    // `ServicePage` has an async iterator implementation, let's use it.
    for await (const keys of datastore.listEntries()) {
        keys.forEach(({key}) => {
            console.log(key);
            if (key.startsWith("Player")) {
                const data = await datastore.getEntry(key);
                
                console.log(`${key} data length: ${JSON.stringify(data).length}`);
            }
        });
    }

    // Or:
    // const keys = await datastore.listEntries().getCurrentPage();
    // keys.data.forEach(({key}) => ...);
    // Get more data:
    // const moreKeys = await keys.getNextPage();
    // moreKeys.data.forEach(({key}) => ...);
})();
You might also like...

Here's a RESTful API that interacts with a PostgreSQL database written in NodeJS with Typescript, RESTify, and Sequelize ORM.

Here's a RESTful API that interacts with a PostgreSQL database written in NodeJS with Typescript, RESTify, and Sequelize ORM.

Basic description REST (Representational State Transfer) is a standard architecture for building and communicating with web services, It typically man

Jan 14, 2022

A free and open-source Roblox script hub

🐋 Orca A free and open-source Roblox script hub 🐋 Introduction Orca is a general-purpose Roblox script hub designed to make convenient tasks easy an

Dec 27, 2022

logs ROBLOX's updates and new versions

logs ROBLOX's updates and new versions

roblox-update-notifier logs ROBLOX's updates and new versions This is meant to be ran in NodeJS, 24/7, using something like pm2. NPM packages required

Oct 23, 2022

A futuristic and lightweight data platform for upcoming ROBLOX games.

A futuristic and lightweight data platform for upcoming ROBLOX games.

A lightweight data platform for ROBLOX ⚠ Please restar this repo as it was accidentally deleted. We're still actively recovering. Introduction Datalin

Dec 15, 2022

Downloads & formats all of your Roblox private messages.

Downloads & formats all of your Roblox private messages.

Roblox Message Downloader This tool was created due to the recent news sent out by Roblox. On April 22nd, 2022, all private messages sent by Roblox be

Apr 7, 2022

RWP stands for Roblox web panel, it's a code snippet that you can run via developer console or the provided Google Chrome extension to try out early

RWP stands for Roblox web panel, it's a code snippet that you can run via developer console or the provided Google Chrome extension to try out early

RWP stands for Roblox web panel, it's a code snippet that you can run via developer console or the provided Google Chrome extension to try out early Roblox site features before they're officially out without any programming experience.

Nov 28, 2022

Technical indicators (TALib) written in typescript for deno.

Technical indicators (TALib) written in typescript for deno.

description cover coverY Technical Analysis written in Typescript for Deno .gitbook/assets/dylan-calluy-JpflvzEl5cg-unsplash.jpeg 0 🩕 deno-talib Inst

Aug 25, 2022

Grm is an improved Deno port of GramJS, written in TypeScript

Grm is an improved Deno port of GramJS, written in TypeScript. GramJS is a popular MTProto API Telegram client library written in JavaScript for Node.js and browsers, with its core being based on Telethon.

Dec 31, 2022

đŸ›Łïž A tiny and fast http request router designed for use with deno and deno deploy

Rutt Rutt is a tiny http router designed for use with deno and deno deploy. It is written in about 200 lines of code and is pretty fast, using an exte

Dec 10, 2022
Comments
  • [WIP] feat(assets-upload)

    [WIP] feat(assets-upload)

    WIP. We have the endpoints, we're just waiting for either documentation or the official release.

    ApiGateway entrypoint: https://apis.roblox.com/assets

    • [x] Implement AssetUploadService opencloud service

      • ✅ Implement from Swagger documentation
    • [ ] Implement AssetUploadService methods into OpenCloudClient

    opened by Julli4n 0
Releases(v0.2.2)
Owner
Organization for holding Dynablox repositories.
null
Opinionated collection of TypeScript definitions and utilities for Deno and Deno Deploy. With complete types for Deno/NPM/TS config files, constructed from official JSON schemas.

Schemas Note: You can also import any type from the default module, ./mod.ts deno.json import { type DenoJson } from "https://deno.land/x/[email protected]

deno911 2 Oct 12, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till mÀnniskor pÄ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Variant types in Roblox TypeScript - Ported from Vanilla TypeScript

Variant (for Roblox) This is a roblox typescript variant (heh, pun) of Variant. See the Variant documentation on how to use Variant. A variant type is

Australis 2 Jun 3, 2022
A full NodeJS sms-activate.org api wrapper up to date in Typescript

Sms-Activate.org This package fully supports all the https://sms-activate.org/ API with Typescript types. Installation Install the package using npm

SegFault 52 Dec 26, 2022
A CLI tool to create a NodeJS project with TypeScript CTSP is a CLI tool to make easier to start a new NodeJS project and configure Typescript on it.

CTSP- Create TS Project A CLI tool to create a NodeJS project with TypeScript CTSP is a CLI tool to make easier to start a new NodeJS project and conf

Jean RodrĂ­guez 7 Sep 13, 2022
Tiny Telegra.ph API wrapper for Deno

Telegra.ph API wrapper for Deno ?? This is a tiny Telegra.ph API wrapper for Deno written in TypeScript. All methods as listed here are available. See

Dunkan 9 Jul 28, 2022
TypeSafe MongoDB Atlas Data API SDK for Deno & Deno Deploy

Atlas SDK atlas_sdk is a TypeSafe MongoDB Atlas Data API SDK for Deno & Deno Deploy Links Docs Import Replace LATEST_VERSION with current latest versi

Erfan Safari 20 Dec 26, 2022
Argon - extension for VS Code and plugin for Roblox allowing easy two-way sync of code and instances

About Argon is a simple two-way sync plugin for Roblox and extension for Visual Studio Code allowing developers not only to sync code but every possib

DARK 16 Dec 29, 2022