GistUtil: Interact with Gist API from In-Game

Hello, Roblox Developers!

I’m excited to introduce you to GistUtil, a powerful new utility module that I’ve been working on. This module is designed to streamline your development process by providing an easy way to interact with GitHub’s Gist API directly from your Roblox games.

Features

GistUtil comes packed with a variety of features, including:

  1. JSON Encoding and Decoding: Easily convert tables to JSON strings and vice versa.
  2. Gist Creation and Deletion: Create and delete gists with ease.
  3. Gist Reading and Writing: Read the content of a gist or write new content to it.
  4. File Reading and Writing within a Gist: Read and write to specific files within a gist.

Benefits

Here’s how GistUtil can benefit you:

  1. Efficiency: By providing a simple and intuitive interface for interacting with the Gist API, GistUtil can save you time and effort in your development process.
  2. Flexibility: Whether you need to store data, share code snippets, or anything else, GistUtil gives you the power to do it all directly from your Roblox games.
  3. Ease of Use: With clear function names and documentation, GistUtil is easy to use even for developers who are new to working with APIs.

Absolutely, I can provide a brief explanation for each function in the GistUtil module. Here’s an updated version of the “How to Use GistUtil” section with explanations for each function:


How to Use GistUtil

To get started with GistUtil, you can require the module in your code and start calling its functions. Here’s a brief explanation of each function:

  1. encode(data: table?): JSONString?: This function takes a table and converts it into a JSON string. If the input is already a string, it simply returns the input.

  2. decode(data: JSONString?): table: This function takes a JSON string and converts it into a table. If the input is already a table, it simply returns the input.

  3. new(id: string, token: string): Gist: This function creates a new Gist object with the given ID and token.

  4. create(token: string, fileName: string?, content: JSONString?): table: This function creates a new gist with the given token, file name, and content. The file name defaults to “README.md” and the content defaults to “Hello, world!” if not provided.

  5. delete(gist: Gist): table: This function deletes the given gist.

  6. read(gist: Gist): table: This function reads the content of the given gist.

  7. readFile(gist: Gist, fileName: string): table: This function reads the content of a specific file within the given gist.

  8. write(gist: Gist, data: JSONString): table: This function writes new content to the given gist.

  9. writeFile(gist: Gist, fileName: string, data: JSONString): table: This function writes new content to a specific file within the given gist.

Here’s a simple example of creating a new gist:

local gistUtil = require(path.to.gistUtil)

local token = "your GitHub token"
local fileName = "example.txt"
local content = "Hello, world!"

local response = gistUtil.create(token, fileName, content)

Please replace "your GitHub token" with your actual GitHub token. You can find more detailed usage instructions in the comments of the module’s code.


I’m excited to see what you all create with GistUtil! If you have any questions or need help, feel free to ask. I’m here to help.

Happy developing!


Source Code


Special thanks to @astraIboy for making this tutorial

5 Likes

@RuizuKun_Dev Dude this is super clean, glad were the first ones to hop on this, thank you so much for the support on my tutorial!

If you could find out a way so that we can use multiple Gists in our game to save data that would be super awesome, like lets say you have 5 Gists so thats 5MB of data in total so maybe youd be able to retrieve all the contents of the 5 Gists and concatenate them and then decode them, but I havent tried this but I feel like it could work though

Again, this is awesome I’ll probably be using this thank you!

… please just use datastores. Save yourself the trouble.

4 Likes

I agree with @nakoyasha, just use DataStores if you want to store data greater than 1MB. Even if such a system did exist, I doubt GitHub would be pleased with Roblox servers spamming the Gist API with data storage requests which could potentially lead to another Roblox-Discord scenario.

With that being said, here’s my WIP implementation (I’m bored):

2 Likes

yo this is a W, can you explain how to use it though?

also keep in mind most people disagree with doing this so i doubt most people are going to even use this method beside me so yeah!

2 Likes

I know I’m the dumb one here, but where would you use gist in your development? Like for making plugins or for public games or what? I simply don’t get it.

For myself I use it to store information when I don’t particularly can’t or want to use DataStore, it could be for debugging, feature flags, custom database for game data (not player session data) or anything else you’d possibly need, you can even store Luau code and yes i’d work great for plugins.

1 Like

It exports (or should, I may have forgot to return it) a Gist Manager class that essentially manages Gist instances with Read/Write functions and internally hold the references to the files in the Gist.

1 Like

Yeah @RuizuKun_Dev @R0bl0x10501050
I’ve decided im just going to use regular roblox datastores, although of course if I was able to hos my own json or there was a free service with really good rates and alot of space i’d use that but, im making a pretty good game right now and this shit is stressing me out, thanks so much for your contributions!

1 Like

Any Ideas for plugin support??

You can integrate this module into your plugins with no additional support required.

Thank you for your interest

1 Like