Skip to content

Latest commit

 

History

History
76 lines (68 loc) · 2.9 KB

README.md

File metadata and controls

76 lines (68 loc) · 2.9 KB

Overview

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.


Installation

  1. Copy the DataStoreApi.lua module file inside ReplicatedStorage or ServerStorage.
  2. Import it in your scripts.
local DataStoreApi = require(game.ReplicatedStorage.DataStoreApi)

Quickstart

Creating a DataStoreApi instance

  1. Create a new Roblox API Key and copy it. The key should have read and write access permissions to both Ordered DataStore and DataStore. For the Accepted IP Addresses, you can just include 0.0.0.0/0 as stated in here.
  2. Identify the game/experience's universe ID that you want to target. It can be identified using game.GameId.
  3. Pass the api_key and universe_id to the DataStoreApi.new constructor.
local api = DataStoreApi.new("api_key", "universe_id")

Creating a store entry

Standard

local response = api:set("store_name", "key", {a=1, b="b", c=3})
print(response and "succeeded!" or "failed!")

Ordered

local response = api:set_ordered("store_name", "key", 1)
print(response and "succeeded!" or "failed!")

Getting a store entry

Standard

local response = api:get("store_name", "key")
print(response)

Ordered

local response = api:get_ordered("store_name", "key")
print(response and response.value)

Updating a store entry

Standard

local response = api:update("store_name", "key", "new_value")
print(response and "succeeded!" or "failed!")

Ordered

local response = api:update_ordered("store_name", "key", 5)
print(response and "succeeded!" or "failed!")

Deleting a store entry

Standard

local response = api:delete("store_name", "key")
print(response and "succeeded!" or "failed!")

Ordered

local response = api:delete_ordered("store_name", "key")
print(response and "succeeded!" or "failed!")

References