Skip to content

A wrapper module that handles the basic CRUD operations of the DataStore API of Roblox.

Notifications You must be signed in to change notification settings

enaielei/roblox-datastore-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

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

About

A wrapper module that handles the basic CRUD operations of the DataStore API of Roblox.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages