Skip to content

Miqueas/Github-REST-API-Examples

Repository files navigation

License

What is this?

A set of basic examples of what you can do with Github's REST API written in different programming languages.

Running/Building

Lua

The Lua example needs some libraries:

# For easy GET requests to the API
luarocks install lua-requests
# Fast JSON encoding/decoding
luarocks install rapidjson
# Commandline options, flags and arguments parsing
luarocks install argparse

After you have all these libraries, then run the example:

lua Github.lua

Nim

Build the Nim example with:

nim c -d:ssl Github.nim

And run:

./Github ...

NOTE: On Windows (and probably macOS too) you'll need to download a SSL/TLS Certificate and put it into the folder where you compiled the example. This is due to a Nim bug and that's the temporary fix.

Go

Just run with:

go run Github.go

Or build if you want:

go build Github.go

Vala

You'll need this before compile the example:

  • json-glib-1.0
  • libsoup-2.4

Then:

valac Github.vala --pkg=json-glib-1.0 --pkg=libsoup-2.4

Ruby

Same as the Go example:

ruby Github.rb

C#

Note: I made this on Linux and I tested the example using Mono (compiling with command line tools), Idk how this can be compiled on Windows. Also, this is my first time using C#, so the code can suck a lot.

Before to compile, you'll need Newtonsoft.Json and Mono.Options, install it using NuGet:

nuget install Newtonsoft.Json
nuget install Mono.Options

Mono.Options is included with Mono, but when I try to use it compiling the example, I give an error, so I used NuGet to solve that.

Anyway, after you have all the dependencies, just copy the downloaded .dll file by NuGet to the root folder where is the C# example and compile it:

csc Github.cs -r:Newtonsoft.Json.dll -r:Mono.Options.dll

And, finally, run it:

mono Github.exe

Postdata: I tried these commands on Windows and it works in the same way.

Python

Just run:

python3 Github.py ...