Convert data received from GitHub download API

Hello. I need help converting data i get from a GitHub download API link. The problem is that i don’t really understand what kind of data is received as that link visited on the browser would start a download, instead i want to download a repository from GitHub and insert it into studio.

What i am using is:

game:GetService("HttpService"):GetAsync("https://api.github.com/repos/iKingNinja/Roblox-plugins-info/zipball/main")

What i get is:

Do you have any idea on how to convert that data into files?

:warning: The example repository contains just a JSON file so JsonDecode() is not the solution as this will need to act on entire repos with subfolders etc

2 Likes

If this doesn’t work, I have nothing for you. Anyway, It’s worth a shot! :smile:

local HttpsService = game:GetService("HttpService")
local Data = HttpsService:GetAsync("https://api.github.com/repos/iKingNinja/Roblox-plugins-info/zipball/main")
local Result = HttpsService:JSONDecode(Data)

It doesn’t work as the data is not in json

This could be of use to you, otherwise, I have no idea.

How can it help? the problem is not with the url

It is a ZIP File, you gotta get txt or lua in order to make it work.

maybe i didn’t explain it well but that’s what i am trying to do

You are requiring a zip file, simple just put the link on the unpacked zip file, as i see the file inside is a json file, so you can Directly take that file and then decode it.

EDIT: Since Forum Is not working

Try This:

local HttpsService = game:GetService("HttpService")
local Data = HttpsService:GetAsync("https://raw.githubusercontent.com/iKingNinja/Roblox-plugins-info/main/info.json")

print(HttpsService:JSONDecode(Data))

@NinjaFurfante07

You may be able to convert the data, but even then, it is pretty much useless unless you use it for something like a plugin. Roblox prohibits the live editing of scripts, so you could not possibly create a script while the game is running unless you are coding it for a plugin.

Yes the file inside is a json document but that was just a test repository because then i want to make this work for repos containing folders and other files

What do you mean?

I am making a CLI and i want to include GitHub support so it won’t be used in game, it’s a plugin

1 Like

This is because you’re requesting a zipball.

You’ll need to use the Git Trees API to get a list of files and their download links. From there, you can download the files and insert them into the game (if applicable).

1 Like

Hi @NinjaFurfante07 Forum Is not working, I edited my last post with the code

Take a look at: Convert data received from GitHub download API - #8 by Sonostrano20

1 Like

Well as i told you before this is not going to just act on single files repositories but repositories with subfolders and multiple files so this won’t work unless i can get all the files listed

You can use this, it may help you find the answer:

-- SERVICES
local HttpService = game:GetService("HttpService")
-- VARIABLES
local PluginInfo = HttpService:JSONDecode(HttpService:GetAsync("https://raw. githubusercontent.com/iKingNinja/Roblox-plugins-info/main/info.json"))
-- SOURCE
print(PluginInfo)

The link in the GetAsync function has a hidden space that is after the https://raw., remove it since I had to add that space because the forum wasn’t letting me send the reply.

Sorry can you please explain what a three_sha is, to be honest i never used this API and the GitHub documentation does not explain what it is

not single files but entire repositories

1 Like

Try this:

-- SERVICES
local HttpService = game:GetService("HttpService")
-- VARIABLES
local PluginInfo = HttpService:JSONDecode(HttpService:GetAsync("https://api.github.com/repos/iKingNinja/Roblox-plugins-info/git/trees/096b93c0977c8bdc9bc58c77e3536c6b00baa1ef"))
-- SOURCE
print(PluginInfo)

If you see the URL in the browser, then you can see the files:

But note that to get that information you need to get a tree_sha, which it’s kinda like the unique ID of a commit.

Meaning that if you update the repository and create a new commit, you will have to get the new commit tree_sha so it gets reflected on the plugin.

1 Like

A tree is a folder.

The SHA1 hash of the root tree is the latest commit hash.

For your repository, the URL would be:

root URL repo owner repo name commit hash recursive
https://api.github.com /repos /iKingNinja /Roblox-plugins-info /contents /c096b93c0977c8bdc9bc58c77e3536c6b00baa1ef ?recursive=false

:warning: Even though we said ?recursive=false, it will still be recursive. You need to omit it entirely if you don’t want it to get files recursively.

If you don’t understand what any of this means, you might want to see Git basic concepts.

1 Like

Oh ok thanks i didn’t know that

Yes i read it in the documentation

1 Like