This module facilitates DataStore
and OrderedDataStore
communication between different Roblox experiences or games using HttpService
. Currently, it allows basic CRUD operations by passing parameters to the Standard Data Store and Ordered Data Store API endpoints and sending them over as requests.
- Copy the
DataStoreApi.lua
module file insideReplicatedStorage
orServerStorage
. - Import it in your scripts.
local DataStoreApi = require(game.ReplicatedStorage.DataStoreApi)
- Create a new Roblox API Key and copy it. The key should have read and write access permissions to both
Ordered DataStore
andDataStore
. For the Accepted IP Addresses, you can just include0.0.0.0/0
as stated in here. - Identify the game/experience's universe ID that you want to target. It can be identified using
game.GameId
. - Pass the
api_key
anduniverse_id
to theDataStoreApi.new
constructor.
local api = DataStoreApi.new("api_key", "universe_id")
local response = api:set("store_name", "key", {a=1, b="b", c=3})
print(response and "succeeded!" or "failed!")
local response = api:set_ordered("store_name", "key", 1)
print(response and "succeeded!" or "failed!")
local response = api:get("store_name", "key")
print(response)
local response = api:get_ordered("store_name", "key")
print(response and response.value)
local response = api:update("store_name", "key", "new_value")
print(response and "succeeded!" or "failed!")
local response = api:update_ordered("store_name", "key", 5)
print(response and "succeeded!" or "failed!")
local response = api:delete("store_name", "key")
print(response and "succeeded!" or "failed!")
local response = api:delete_ordered("store_name", "key")
print(response and "succeeded!" or "failed!")