Hi guys. I recently created a module which allows easier communication with your jsonstore.io endpoints. It’s really simple to use, so thought I’d share it with the community, rather than keeping it to myself.
You can grab a copy here: https://www.roblox.com/library/2756363731/jsonstore-API
I’ve also added RoDocs support, so all available methods can be viewed from your documentation viewer. Here they are in case you don’t have this plugin.
Methods
Summary
<string> JsonStore.GenerateEndpoint()
<table> JsonStore.new(<string> Token)
<boolean> JsonStore:Ping()
<table> JsonStore:GET(<string|nil> Path)
<boolean> JsonStore:DELETE(<string|nil> Path)
<table> JsonStore:PUT(<string> Path, <table> Content)
<table> JsonStore:POST(<string> Path, <table> Content)
JsonStore.GenerateEndpoint()
Generates a new endpoint token.
Returns
<string>
Token to access the new jsonstore.io endpoint.
JsonStore.new(Token)
Instantiates a new JsonStore.
Parameter | Description | Data Type |
---|---|---|
Token | The token for your jsonstore.io endpoint | string |
Returns
<table>
API ready to communicate with your endpoint.
JsonStore:Ping()
Returns true
if HTTP requests are enabled, and server is online.
Returns
<boolean>
True if server is online.
JsonStore:GET(Path)
Send a GET
request to your endpoint. Path can be nil
if no path is required.
Parameter | Description | Data Type |
---|---|---|
Path | Path to perform GET request to. | `string |
Returns
<table>
Data returned from database.
JsonStore:DELETE(Path)
Send a DELETE
request to your endpoint. Path can be nil
if no path is required.
Parameter | Description | Data Type |
---|---|---|
Path | Path to perform DELETE request to. |
`string |
Returns
<boolean>
true
ifDELETE
request was successful.
JsonStore:PUT(Path, Content)
Send a PUT
request to your endpoint. Path can be nil
if no path is required.
Parameter | Description | Data Type |
---|---|---|
Path | Path to perform PUT request to. |
`string |
Content | Data to PUT into the database. |
table |
Returns
<table>
The contentPUT
into the database.- on error -
<nil>, <string>
Error message.
JsonStore:POST(Path, Content)
Send a POST
request to your endpoint. Path can be nil
if no path is required.
Parameter | Description | Data Type |
---|---|---|
Path | Path to perform POST request to. |
`string |
Content | Data to POST to the database. |
table |
Returns
<table>
The contentPOST
’ed to the database.- on error -
<nil>, <string>
Error message.
Side note;
I’m pretty sure jsonstore.io’sPUT
andPOST
methods handle the request in exactly the same way. The entire document is overwritten regardless of which of these methods you choose. Perform aGET
request and update the necessary key/value pairs, thenPUT
orPOST
the data back to the endpoint if you need to update a document.