Skip to content

HauptJ/Golang-API-Github

Repository files navigation

Golang-API-GitHub

Golang API that returns Github user / stargazer usernames and repositories as well as follower repositories. Utilizes the go-github package to interface with the Github API

To Build and Run:

  • NOTE 1: Port 8880 or the one specified in docker-compose.yml and main.go must be available.
  • NOTE 2: On Windows 10 Pro or greater? You can use Chocolatey to install Docker CE for Windows and everything else listed below.
  1. Install Golang if you want to run the API on your host machine. If you wish to run the API in a Docker container, you can skip this step.
  1. Install Golang dependencies if you want to run the API on your host machine. If you wish to run the API in a Docker container, you can skip this step.
  • go get github.com/gorilla/context
  • go get github.com/gorilla/mux
  • go get github.com/google/go-github/github
  • go get golang.org/x/oauth2
  • go get golang.org/x/net/context/ctxhttp
  1. Install Docker and Docker Compose. If you wish to run the API on your host machine, you can skip this step.
  1. Get a GitHub API key / token with the following permissions Github Token Permissions

  2. Set the token as an environment variable named TOKEN

  • Windows: $env:TOKEN="Github API TOKEN"
  • Linux: export TOKEN="Github API TOKEN"
  1. To run on host system

  2. go build main.go

  3. ./main or .\main.exe

  4. To run in a docker container

  • docker-compose up

Endpoints:

/followers

  • TYPE: GET
  • Returns a list of 5 followers for the specified Github user as well as the followers of the followers 3 levels deep.
  • /followers/{:Github User}
  • Example: /followers/torvalds
  • Followers Screenshot

/repos

  • TYPE: GET
  • Returns a list of 5 repositories for a specified Github user and a list of 5 stargazers for each repository. The lists go 3 levels deep.
  • /repos/{:Github User}
  • Example: /repos/torvalds
  • Repos Screenshot

devel

About

Golang API that returns Github follower and stargazer usernames and follower repositories

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published