Rblx-open-cloud - Roblox Open Cloud Wrapper for Python!

I made a Roblox Open Cloud API Wrapper for Python which allows developers to use Python to access Open Cloud. It has 100% API coverage and I plan to add all new Open Cloud additions to the library!

GitHub Repository: https://github.com/treeben77/rblx-open-cloud
Documentation: https://rblx-open-cloud.readthedocs.io/en/latest

Getting Started

  1. Install the library using your terminal:

    pip install rblx-open-cloud
    
  2. Create an API key from the Creator Dashboard. You can read Managing API Keys if you get stuck.

  3. Import the library:

    import rblxopencloud
    

Now, youā€™ve set up the library, and you can start using the API. Below are some examples of some of the APIs.

Examples

Basic Data Store Functionality

The following example shows how to get a data store, and get, set, increment, and remove keys.

# creates a DataStore object from an Experience object using the datastore name and scope.
experience = rblxopencloud.Experience(000000000, api_key="api-key-from-step-2")
datastore = experience.get_data_store("data-store-name", scope="global")

# sets the key 'key-name' to 68 and provides user ids
# DataStore.set does not return the value or an EntryInfo object, instead it returns a EntryVersion object.
datastore.set("key-name", 68, users=[287113233])

# gets the value with the key 'key-name'
# info is a EntryInfo object which contains data like the version code, metadata, userids and timestamps.
value, info = datastore.get("key-name")

# increments the key 'key-name' by 1 and ensures to keep the old users and metadata
# DataStore.increment retuens a value and info pair, just like DataStore.get 
value, info = datastore.increment("key-name", 1, users=info.users, metadata=info.metadata)

# deletes the key 'key-name'
datastore.remove("key-name")

If youā€™re using ordered data stores, use Experience.get_ordered_data_store instead of Experience.get_data_store, and remove users and metadata parameters. For more advanced uses, like versions, preconditions, etc, read the the documentation here: https://rblx-open-cloud.readthedocs.io/en/latest/datastore/

Publishing Messages with Messaging Service

Currently, you canā€™t recieve messages, but this is an example to send a message:

experience = rblxopencloud.Experience(000000000, api_key="api-key-from-step-2")
experience.publish_message("topic-name", "example data")

It should be noted that these messages will not be recieved by studio, and dicts are not supported, only strings (this is an open cloud limitation). Hereā€™s an example on how to recieve the message in-game:

local MessagingService = game:GetService("MessagingService")

MessagingService:SubscribeAsync("topic-name", function(message)
    print(message.Data)
end)

Uploading Assets

Currently, you may only uploads Decals, Audios, and Models (as fbx). This is a basic example to upload a image to a user or group:

user = rblxopencloud.User(287113233, api_key="api-key-from-step-2")
# or, create a Group object:
group = rblxopencloud.Group(9697297, api_key="api-key-from-step-2")

# this example is for uploading a decal:
with open("path-to/file-object.png", "rb") as file:
    asset = user.upload_asset(file, rblxopencloud.AssetType.Decal, "name", "description")

You could make it more complex and make sure the asset has been processed (asset may be a PendingAsset sometimes.) For more information, you can look at itā€™s documentation here: https://rblx-open-cloud.readthedocs.io/en/latest/creator/

If youā€™re using another API like place publishing, you can view examples for them in the examples folder in the repository.


If you find the library useful, please like the DevFroum post, and/or star the GitHub repository! If you need help, feel free to ask here. If youā€™d like to report a bug or request a feature, please use the issue tab on GitHub.

Latest Update

23 Likes

v0.3.1 - All Scopes Support

To update/change back to v0.3.1, simply run this command in the terminal

pip install rblx-open-cloud==0.3.1

Changelog

  • The scope paramater in get_data_store and list_data_stores now accepts None
  • list_keys will return results from all scopes if DataStore.scope is None.
  • DataStore methods which accept a key now are required to formated like scope/key if DataStore.scope is None.
  • empty EntryInfo.users objects from DataStore.increment are now a list instead of a dictionary.
  • ValueError can now be raised by DataStore methods which accept a key.
  • Fixed some issues in the documentation

v0.3.2 - Preconditions

To update/change back to v0.3.2, simply run this command in the terminal

pip install rblx-open-cloud==0.3.2

Changelog

  • Added exclusive_create to DataStore.set(). When True it will not update and raise PreconditionFailed if they is already a value for the key.
  • Added previous_version to DataStore.set(). When provided, it will not update and raise PreconditionFailed if previous_version is not the latest version ID.
  • Added docstrings to functions
  • ListedEntry and EntryVersions now support being compared with the == operator.
1 Like

v0.4.1 - Iterable Limits & Python 3.9 Requirement

To update/change back to v0.4.1, simply run this command in the terminal

pip install rblx-open-cloud==0.4.1

Changelog

  • Added limit paramater to DataStore.list_keys(), DataStore.list_versions() and Universe.list_data_stores(). This will limit the number of items returned so you donā€™t have to set up a system to break out of a loop yourself!
  • Added rblxopencloud.VERSION and rblxopencloud.VERSION_INFO values.
  • Added requirements for Python 3.9 because the library will not work with earlier versions.

I also made some examples!! you can have a look at them in the examples/ directory!

1 Like

Very underrated but also very helpful.
More people need to find out about this.

4 Likes

v1.0.0 - Full Release (Breaking Changes)

To update/change back to v1.0.0, simply run this command in the terminal

pip install rblx-open-cloud==1.0.0

Iā€™m sorry for the breaking change, but I changed the rblxopencloud.Universe name to rblxopencloud.Experience, and I also changed DataStore.universe to DataStore.experience. I had to do this because I didnā€™t want to live on forever knowing that I used the wrong name for Experiences (after the V1 release I canā€™t really make breaking changes)

Iā€™ve released V1 of the library now. I wanted to wait until after OAuth2 was fully released for this, but it was delayed from end of 2022 to ā€˜over the next monthsā€™: https://devforum.roblox.com/t/open-cloud-oauth20-alpha-program/1791194/65?u=treeben77

NOTE: If you have intentionally installed a version of the library for alpha usage, it does NOT have the Universe name changes yet. I wonā€™t change the name for them until theyā€™re fully released into the library (which is when Roblox releases the update.)

2 Likes

v1.0.1

  • Fixed a small bug which skipped some keys in datastore.list_keys

still patiently waiting for oauth2

1 Like

v1.1.0 - Assets API Support

NOTE: Assets API is not documented yet (coming later today), for now use this example: rblx-open-cloud/assets.py at main Ā· TreeBen77/rblx-open-cloud Ā· GitHub

NOTE FOR BETA TESTERS: I changed the syntax from what was in beta, so it will work with future apis better.

1 Like

v1.2.0 - Ordered Data Stores Support

NOTE: Assets API is also now documented!

1 Like

Just to note, you should make it clear when uploading an image if the status code is 400, you currently say ā€œThe file is not a supported type, or is corruptedā€, 400 seems to also get returned if the name or description get moderated.
Or at least renaming files solves the issue and there seems to be no pattern to it.

2 Likes

didnā€™t have access to very good documentation during the beta when I coded it, so Iā€™ll look over it and update the error messages. Iā€™ll keep you updated!

From my testing, I concluded that it would just tag out the name and description instead of rejecting it.

1 Like

It might be worth waiting, Roblox have said they intend on the API making it clear when items are moderated etc. in the future.
Great wrapper btw, has saved me alot of time fiddling around with trying to get images to post properly.

3 Likes

True, but itā€™s bets to implement it sooner, rather than later. It took Roblox about 6 months to get from private beta to public beta, so it could take quite a while for the change to happen.

Iā€™ve already made a change thatā€™s in the beta version of the library, which can be installed using this command:

git+https://github.com/TreeBen77/rblx-open-cloud

Thanks! Iā€™m glad you enjoy using the library!

1 Like

Is there anyway to clear datastore.list_versions("some random key")
Because it seems once I remove a key my API seems to still see the key as if it still exists.

Code

Entrys: int = 0

for Entry in NEX_Datastore.list_keys():
    Entrys += 1

print('Total Entrys: ',Entrys)

This is my current solution

Entrys: int = 0

for _ in NEX_Datastore.list_keys():
    try:
        NEX_Datastore.get(_.key)
        Entrys += 1
    except (rblxopencloud.NotFound):
        continue

print(Entrys)
1 Like

No, that is a Roblox Open Cloud limitation (not a library one).

2 Likes

Thatā€™s really disappointing,
My solution still works but is very annoying

1 Like

is there a way to make it work for .js ?

1 Like

No as Python and JavaScript are two distinct languages.

2 Likes

v1.3.0 - OAuth2 Support

Added OAuth2 Support

During the beta, the following changed (may not be full list):

  • Resources.creators became Resources.accounts
  • Removed AccessTokenInfo.raw
  • Renamed PartialAccessToken.client to PartialAccessToken.app

Uploading and Updating Assets Changes

  • Now raises ModeratedText instead of InvalidAsset when text is censored by Roblox.

Upgrading

Upgrading to new version:

pip install rblx-open-cloud --upgrade

GitHub release: Release v1.3.0 - OAuth2 Support Ā· TreeBen77/rblx-open-cloud Ā· GitHub

1 Like

hey uhhh I donā€™t know if this is just me problem

but even without your Open Cloud wrapper

The API key seems to always comes off Invalidated for me :confused:

1 Like