A familiar OOP wrapper for Roblox's Open Cloud API.
The goal of this project is to simplify the Open Cloud API into a familar format which mimics Roblox's in-engine API, as well as simplify some of the tedious functionality.
Contributions are much welcome!
This is the default export of the module.
import CloudClient from "rbx-open-cloud"
const client = new CloudClient(process.env.RBLX_API_KEY)
- registerService(serviceName :
string
,...args
) :Service
const messagingService = client.registerService("MessagingService", 1234567890)
- getService(serviceName :
string
) :Service
;const messagingService = client.getService("MessagingService")
import { DataStoreService } from "rbx-open-cloud"
const newDataService = new DataStoreService(1234567890, process.env.RBLX_API_KEY)
- baseUrl:
string
- universeId:
number
- listDataStores(params?:
ListDataStoresParams
) :Promise<ListDataStoresResponse>
const data = await newDataService.listDataStores({prefix: "Test", pageSize: 1, cursor: ""})
- getDataStore(name:
string
, params?:DataStoreParams
) :DataStore
const targetDataStore = newDataService.getDataStore("Test_1", {scope: "global"})
- name:
string
- universeId:
number
-
listKeys(params? :
ListEntriesParams
) :Promise<ListEntriesResponse>
; -
get(key :
string
) :Promise<GetDataResponse>
; -
set(key :
string
, value :JsonDataType
, params? :SetDataParams
) :Promise<SetDataResponse>
; -
delete(key :
string
) :Promise<void>
; -
increment(key :
string
, amount :number
, params? :EntryMetaData
) :Promise<GetDataResponse>
; -
getVersion(key :
string
, versionId :string
) :Promise<GetDataVersionResponse>
; -
listVersions(key :
string
, params? :ListVersionsParams
) :Promise<ListVersionsResponse>
;
import { MessagingService } from "rbx-open-cloud"
const newMessageService = new MessagingService(1234567890, process.env.RBLX_API_KEY)
- baseUrl:
string
- universeId:
number
- getTopic(topicName:
string
) :Topic
const targetTopic = newMessageService.getTopic("Topic1")
- topicName:
string
- universeId:
number
- publish(message:
string
) :Promise<void>
targetTopic.publish("Message Text") .then(() => { console.log("Sent message successfully!") }) .catch(err => { console.log("Failed to send message") })
import { PlaceService } from "rbx-open-cloud"
const newPlaceService = new PlaceService(1234567890, process.env.RBLX_API_KEY)
- baseUrl:
string
- universeId:
number
- getPlace(placeId:
number
) :Place
const targetPlace = newPlaceService.getPlace(123467)
- placeId:
number
- universeId:
number
- publish(versionType:
"Saved" | "Published"
, fileType:"rbxlx" | "rbxl"
, content:Buffer
) :Promise<PlacePublishResponse>
import fs from "fs" fs.readFile("./PlaceFile.rbxl", "binary", (content) => { const contentBuffer = Buffer.from(content, "binary") targetPlace.publish("Published", "rbxl", contentBuffer) .then(result => { console.log("Place published successfully", result.versionNumber) }) .catch(err => { console.log("Failed to publish place", err) }) })
import { AssetService } from "rbx-open-cloud"
const newAssetService = new AssetService(1234567890, false, process.env.RBLX_API_KEY)
- baseUrl:
string
- ownerId:
number
- isGroup:
boolean
-
create(assetType, name, fileContent, options) :
Promise<AssetCreateResponse>
- assetType :
"Audio" | "Decal" | "Model"
- name :
string
- fileContent :
Blob
- options :
{ description : string }
const assetPromise = newAssetService.create("Audio", "NewAudio!", FileBlob, { description: "Cool new asset" }) // Response used in .get()
- assetType :
-
get(operationIdPath :
string
) :Promise<AssetGetResponse>
assetPromise.then((uploadResult) => { let getResult = undefined; while (!getResult || !getResult.response) { // Roblox backend has a race condition. This is a hacky fix. await new Promise(r => setTimeout(r, 1000)); getResult = await newAssetService.get(uploadResult.path) const unusualResult = (getResult as unknown) as {[key : string] : string}; if (unusualResult.error) { throw new Error(unusualResult.error); } } console.log(getResult.response.assetId); }).catch((err) => { console.log("Upload failed") });
-
update(assetId :
number
, fileContent :Blob
) :Promise<AssetCreateResponse>
const assetPromise = newAssetService.update(0123456789, FileBlob)
import { GroupService } from "rbx-open-cloud"
const newGroupService = new GroupService(1234567890, process.env.RBLX_API_KEY)
- baseUrl:
string
- groupId:
number
- getInfo() :
Promise<GroupInfoResponse>
- getMembers(amount : number, params :
GroupMemberParams
) :Promise<GroupMembersResponse>
- getRoles(amount : number, params :
GroupRolesParams
) :Promise<GroupRolesResponse>
- getShout() :
Promise<GroupShoutResponse>