This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
minizbot2012's profile picture

Github gist API

Started by minizbot2012, 04 August 2015 - 01:16 PM
minizbot2012 #1
Posted 04 August 2015 - 03:16 PM
So after reading albeit too much into the web github API here goes.

Introducing the github "gist" api for computercraft. Gist as you know is like a pastebin service, but on github, allowing people to use advanced features.

To download this API simply run


pastebin get 21t6LFZA gist
And load then it os.loadAPI("<file location>")

you need to get a personal access token from here: https://github.com/settings/tokens save it somewhere safe, you'll need it to use this and it will not save it for you.

The functions you will be most interested in are:

First you need to run the login

login: takes your Personal Access Token, and a nickname to store it under (this is to access the web API, and it is not available outside of the API)

ex login("token", "mini")

To create a gist use

createGist(the nick you provided, filetable, a description, and a bool)

If the bool is true the gist will be public!

returns the ID of the gist

To update an existing gist you will use
updateGist(nick, ID, filetable)
returns ID

filetable format:

{
	file1="contents",
	file2="contents of file 2"
}
To get files in the gist use:

getGistFiles(ID)

This will return a table that looks like:


{
	file1 = {
		content="contents"
	},
	file2 = {
		contents="contents of file 2"
	}
}
To get a list of gists that you have made call getUsersGists(nick)


ChangelogApril 11, 2016
Moved over to the token system
Feel free to use in your OS / program / whatever, just give me a shoutout.
Edited on 12 April 2016 - 12:40 AM
minizbot2012 #2
Posted 12 April 2016 - 02:44 AM
Update: This now uses github API tokens, opposed to base64 of username and passwords for "Basic auth"