@slay-epic/roblx.js
v1.1.0
Published
Uses the Roblox OpenCloud API for third-parties applications to interact with roblox's servers
Downloads
5
Maintainers
Readme
@slay-epic/roblx.js
About
@slay-epic/roblx.js
is an npm package that allows the ease of interacting with Roblox's OpenCloud Api.
Documentation
To start using @slay-epic/roblx.js
simply require the package first.
const RobloxJs = require("@slay-epic/roblx.js")
Classes
RobloxApiClient
The main class that interacts with the api.
Constructor
new RobloxApiClient({
api_key: "abc123",
global_universeId: ""
})
Parameters
api_key
REQUIRED - This is your api key from the Creator Dashboard.global_universeId
- This parameter is optional but you would need to manually pass down the universe id when interacting with the api.
Methods
registerDataStore()
RobloxApiClient.registerDataStore(DataStoreName,universe_id)
Parameters
DataStoreName
REQUIRED - The name of the data store you want to manage.universe_id
- This parameter is optional. The universe id of the game you are managing the data store on. If there is nouniverse_id
passed then it uses the RobloxApiClient.data.global_universeId
Returns a DataStore class that is linked with the game via universe id (Note: Universe Id is NOT the same as Place Id)
DataStore
This class handles datastore management such as updating a key, removing it etc.
Constructor
new DataStore(RobloxApiClient,DataStoreName)
Parameters
RobloxApiClient
REQUIRED - The RobloxApiClient class.DataStoreName
REQUIRED - The name of the data store you are trying to manage.
Methods
async getEntry()
Returns the value and metadata associated with an entry.
DataStore.getEntry(options,universe_id)
Options
{
key: "123",
scope: ""
}
Parameters
options
key
REQUIRED - The key identifing the entry.scope
- See more information about Scopes.
universe_id
- This parameter is optional. The universe id of the game you are managing the data store on. If there is nouniverse_id
passed then it uses the RobloxApiClient.data.global_universeId
async setEntry()
Sets the value, metadata and user IDs associated with an entry.
DataStore.setEntry(options,universe_id)
Options
{
key: "123",
scope: "",
matchVersion: "",
exclusiveCreate: false
}
Parameters
options
key
REQUIRED - The key identifing the entry.scope
- See more information about Scopes.matchVersion
- Provide to update only if the current version matches this.exclusiveCreate
- Create the entry only if it does not exist.
universe_id
- This parameter is optional. The universe id of the game you are managing the data store on. If there is nouniverse_id
passed then it uses the RobloxApiClient.data.global_universeId
async incrementEntry()
Increments the value for an entry by a given amount, or create a new entry with that amount.
DataStore.incrementEntry(options,universe_id)
Options
{
key: "123",
scope: "",
increment: 0
}
Parameters
options
key
REQUIRED - The key identifing the entry.scope
- See more information about Scopes.increment
- The amount by which the entry should be incremented, or the starting value if it doesn't exist.
universe_id
- This parameter is optional. The universe id of the game you are managing the data store on. If there is nouniverse_id
passed then it uses the RobloxApiClient.data.global_universeId
MessagingService
This class manages the messaging-service api such as publishing information to the servers that runs on the specified experience.
Constructor
new MessagingService(RobloxAPIClient,Topic)
Parameters
RobloxApiClient
REQUIRED - The RobloxApiClient class.Topic
- This parameter is optional but you would need to manually pass down the topic when interacting with the api.
Methods
async publish()
Communicate with the servers that runs the experience
MessagingService.publish(message,topic,universe_id)
Parameters
message
REQUIRED - The message you want to send to the serverstopic
- This parameter is optional. The topic is the specific keyword the server uses to filter the incoming messages it recieves. If there is notopic
passed then it uses the MessagingService.topicuniverse_id
- This parameter is optional. The universe id of the game you are managing the messaging service on. If there is nouniverse_id
passed then it uses the RobloxApiClient.data.global_universeId
Additional Information
To have a communication with a third-party application and roblox's server using Messaging Service, you can do it like this
NodeJs App:
const RobloxJs = require("@slay-epic/roblx.js")
const {RobloxApiClient,MessagingService} = RobloxJS
const Client = new RobloxApiClient({
api_key: "your_api_key",
global_universeId: "your_universe_id"
})
const MessageManager = new MessagingService(Client,"topic")
async function publish(message){
await MessageManager.publish(message)
}
publish("It works!")
Roblox SeverScript
local MessagingService = game:GetService("MessagingService")
local HTTPService = game:GetService("HttpService")
MessagingService:SubscribeAsync("topic",function(msg)
local data = HTTPService:JSONDecode(msg.Data) -- Needs to be decoded since it recieves a json encoded data
print(data) -- "It Works"
end)
Side Note: When testing this you must be in a LIVE server, which means you cannot test it with Roblox Studio
Support
Need help with this package? Come on down to our discord server and go to the #roblox・js under support channel to get some help. Provide information as much as possible so it is easier for us to diagnose your issue