I can’t found anything about this topic, can you help me get / set etc. datastore in my place with python code. I created API-key with all datastore permissions.
You can access your data stores with the API key using the API. The documentation for each API endpoint is available on the Creator Hub. To send API requests in Python you can use a library such as requests. Here’s an example to get a data store value:
import requests
BASE_URI = "https://apis.roblox.com/cloud"
universe_id = 00000 # the experience ID for your game, NOT the place ID.
data_store = "PlayerData" # the data store to access
scope = "global"
entry = "key_to_fetch" # the key to fetch
r = requests.get(
f"{BASE_URI}/v2/universes/{universe_id}/data-stores/{data_store}/scopes/{scope}/entries/{entry}",
headers={"x-api-key": "YOUR SECRET API KEY"}
)
Example response
print(r.json())
>>> {
"path": "universes/123/data-stores/some-data-store/entries/some-data-store-entry",
"createTime": "2023-07-05T12:34:56Z",
"revisionId": "string",
"revisionCreateTime": "2023-07-05T12:34:56Z",
"state": "STATE_UNSPECIFIED",
"etag": "string",
"value": "string",
"id": "string",
"users": [
"string"
],
"attributes": {}
}
Alternatively, since dealing with Roblox’s API can be a little difficult, I made rblx-open-cloud to wrap the API and make it easier to use. The documentation is available at rblx-open-cloud and an example of fetching the keys is:
import rblxopencloud
experience = rblxopencloud.Experience(00000, "YOUR SECRET API KEY")
data_store = experience.get_datastore("PlayerData", scope="global")
entry, info = data_store.get_entry("key_to_fetch")
print(entry, info.users, info.version)
>>> {"key": "value"}, [287113233], "string"
I hope these solutions help and happy coding!
1 Like