Data Store
rblxopencloud.DataStore
Represents a regular data store in an experience.
Warning
This class isn't designed to be created by users. It is returned by Experience.get_data_store()
and Experience.list_data_stores()
.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The data store's name. |
scope |
Optional[str]
|
The data store's scope. If it is |
experience |
Experience
|
The experience the data store belongs to. |
created |
Optional[datetime]
|
The time the datetime was created. Only present if returned by |
list_keys(prefix='', limit=None)
Returns an Iterable of keys in the database and scope, optionally matching a prefix. Will return keys from all scopes if the scope
attribute is None
.
Example
This will print every key in the data store.
If you'd like the keys in a list, you can use the list method:Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix |
str
|
Only return keys that start with this prefix. |
''
|
limit |
Optional[int]
|
Will not return more keys than this number. Set to |
None
|
Returns:
Type | Description |
---|---|
Iterable[ListedEntry]
|
An Iterable of all keys in the data store. |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to list data store keys, or is from an invalid IP address. |
NotFound
|
The experience or data store does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
get(key)
Fetches the value of a key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to find. If |
required |
Returns:
Type | Description |
---|---|
tuple[Union[str, dict, list, int, float], EntryInfo]
|
A tuple with the key's value in the first index, and the key's metadata as an |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to get data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, or entry does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
set(key, value, users=None, metadata={}, exclusive_create=False, previous_version=None)
Sets the value of a key with the new data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to set. If |
required |
value |
Union[str, dict, list, int, float]
|
The key's new value. |
required |
users |
Optional[list[int]]
|
a list of Roblox user IDs to attach to the entry to assist with GDPR tracking/removal. |
None
|
metadata |
dict
|
A dictionary of custom metadata for the entry. |
{}
|
exclusive_create |
bool
|
whether to update the entry if it already has a value. Raises |
False
|
previous_version |
Optional[str]
|
don't update if the current version is not this value. Raises |
None
|
Returns:
Type | Description |
---|---|
EntryVersion
|
An |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to create/update data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, or entry does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
ValueError
|
|
PreconditionFailed
|
A precondition such as |
Warning
If users
and metadata
parameters are not included, they will be removed from the entry.
increment(key, increment, users=None, metadata={})
Increments the value of a key with the provided number. Numbers may be negative to decrement the value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to increment. If |
required |
increment |
Union[int, float]
|
The amount to increment the value. This number can be negative to decrement the value. |
required |
users |
Optional[list[int]]
|
a list of Roblox user IDs to attach to the entry to assist with GDPR tracking/removal. |
None
|
metadata |
dict
|
A dictionary of custom metadata for the entry. |
{}
|
Returns:
Type | Description |
---|---|
tuple[Union[str, dict, list, int, float], EntryInfo]
|
A tuple with the key's value in the first index, and the key's metadata as an |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to increment data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, or entry does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
ValueError
|
The |
Warning
If users
and metadata
parameters are not included, they will be removed from the entry.
remove(key)
Removes the key. The key isn't permanently deleted for 30 days after it is removed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to remove. If |
required |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to remove data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, or entry does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
ValueError
|
The |
list_versions(key, after=None, before=None, limit=None, descending=True)
Returns an Iterable of versions avaliable for the key. Optionally within a ceartin time period.
Example
This will print every version avaliable for the key, and fetch their values.
If you'd like the versions in a list, you can use the list method:Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to find versions for. If |
required |
after |
Optional[datetime]
|
Only find versions after this datetime |
None
|
before |
Optional[datetime]
|
Only find versions before this datetime |
None
|
limit |
Optional[int]
|
Will not return more versions than this number. Set to |
None
|
descending |
bool
|
Wether the versions should be sorted by date ascending or descending. |
True
|
Returns:
Type | Description |
---|---|
Iterable[EntryVersion]
|
An Iterable of all versions of the key. |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to list data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, or key does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
ValueError
|
The |
get_version(key, version)
Gets the value of a key at a specific version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to find. If |
required |
version |
str
|
The ID of the version to find. |
required |
Returns:
Type | Description |
---|---|
tuple[Union[str, dict, list, int, float], EntryInfo]
|
A tuple with the key's value in the first index, and the key's metadata as an |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to get data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, entry, or version does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
Tip
Since DataStore.list_versions()
, and DataStore.set()
return rblxopencloud.EntryVersion()
, you can use the EntryVersion.get_value()
method as a shortcut when using those methods.
rblxopencloud.OrderedDataStore
Represents an ordered data store in an experience.
Warning
This class isn't designed to be created by users. It is returned by Experience.get_ordered_data_store()
.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The data store's name. |
scope |
Optional[str]
|
The data store's scope. If it is |
experience |
Experience
|
The experience the data store belongs to. |
sort_keys(descending=True, limit=None, min=None, max=None)
Returns an Iterable of keys in order based on their value.
Example
This will print every key in the datastore.
If you'd like the keys in a list, you can use the list method:Parameters:
Name | Type | Description | Default |
---|---|---|---|
descending |
bool
|
Wether the largest number should be first, or the smallest. |
True
|
limit |
Optional[int]
|
Will not return more keys than this number. Set to |
None
|
min |
int
|
Minimum entry value to retrieve |
None
|
max |
int
|
Maximum entry value to retrieve. |
None
|
Returns:
Type | Description |
---|---|
Iterable[SortedEntry]
|
An Iterable of all keys in the data store. |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to list ordered data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, or key does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
ValueError
|
The |
get(key)
Gets the value of the key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to get. If |
required |
Returns:
Type | Description |
---|---|
int
|
The integer value of the key. |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to get ordered data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, or entry does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
ValueError
|
The |
set(key, value, exclusive_create=False, exclusive_update=False)
Sets the value of the key, and then returns the new value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to get. If |
required |
value |
int
|
The new integer value. Must be positive. |
required |
exclusive_create |
bool
|
Wether to fail if the key already has a value. |
False
|
exclusive_update |
bool
|
Wether to fail if the key does not have a value. |
False
|
Returns:
Type | Description |
---|---|
int
|
The integer value of the key. |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to create/update ordered data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, or entry does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
PreconditionFailed
|
A precondition such as |
ValueError
|
The |
increment(key, increment)
Increments the value of the key, and then returns the new value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to get. If |
required |
increment |
int
|
The amount to increment the value. You can use negative numbers to decrease the value. |
required |
Returns:
Type | Description |
---|---|
int
|
The integer value of the key. |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to increment ordered data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, or entry does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
ValueError
|
The |
remove(key)
Removes a key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to remove. If |
required |
Raises:
Type | Description |
---|---|
InvalidKey
|
The API key isn't valid, doesn't have access to remove ordered data store keys, or is from an invalid IP address. |
NotFound
|
The experience, data store, or entry does not exist. |
RateLimited
|
You've exceeded the rate limits. |
ServiceUnavailable
|
The Roblox servers ran into an error, or are unavailable right now. |
rblx_opencloudException
|
Roblox returned an unexpected error. |
ValueError
|
The |
rblxopencloud.EntryInfo
Represents a Data Store entry, and contains metadata about the entry.
Warning
This class isn't designed to be created by users. It is returned by DataStore.get()
, DataStore.increment()
, and DataStore.get_version()
.
Attributes:
Name | Type | Description |
---|---|---|
version |
str
|
The version ID of this entry. |
created |
datetime
|
The timestamp the entry was created. |
updated |
datetime
|
The timestamp the entry was last modified. |
users |
list[int]
|
A list of user IDs associated with the entry. |
metadata |
dict
|
The dictionary of custom metadata. |
rblxopencloud.EntryVersion
Represents a Data Store entry version, and contains data about the version.
Warning
This class isn't designed to be created by users. It is returned by DataStore.set()
, and DataStore.list_versions()
.
Attributes:
Name | Type | Description |
---|---|---|
version |
str
|
The version ID of this entry. |
deleted |
bool
|
Wether this version has been marked as deleted. |
content_length |
int
|
The number of characters the value is. |
created |
datetime
|
The timestamp the version was created. |
key_created |
datetime
|
The timestamp the entry was first created. |
rblxopencloud.ListedEntry
Represents a Data Store entry iterated by DataStore.list_keys()
.
Warning
This class isn't designed to be created by users. It is returned by DataStore.list_keys()
.
Attributes:
Name | Type | Description |
---|---|---|
key |
str
|
The entry's key. |
scope |
str
|
The entry's scope. |
rblxopencloud.SortedEntry
Represents an Ordered Data Store entry when listed with OrderedDataStore.sort_keys()
.
Warning
This class isn't designed to be created by users. It is returned by OrderedDataStore.sort_keys()
.
Attributes:
Name | Type | Description |
---|---|---|
key |
str
|
The entry's key. |
scope |
str
|
The entry's scope. |
value |
int
|
The value of the entry. |