Module: GithubContributionsApi

Defined in:
lib/github_contributions_api.rb,
lib/github_contributions_api/version.rb

Overview

A ruby interface to the GitHub Contributions Archive API (https://githubcontributions.io). To the author's knowlege, this API is undocumented.

Constant Summary collapse

URL_BASE =

The prexix for all GitHub Contributions API endpoints.

"https://githubcontributions.io/api"
VERSION =

The current version of this library. Follows semantic versioning (http://semver.org/).

"1.0.0"

Class Method Summary collapse

Class Method Details

.user(github_username) ⇒ Hash

Get information about a given github user.

Examples:

GithubContributionsApi.user("octocat")

Parameters:

  • github_username (String)

    The username of the github user.

Returns:

  • (Hash)


14
15
16
17
18
# File 'lib/github_contributions_api.rb', line 14

def self.user(github_username)
  request_url = "#{URL_BASE}/user/#{github_username}"
  response = HTTParty.get(request_url)
  JSON.parse(response.body)
end

.user_events(github_username, options = {}) ⇒ Hash

Get events for a given github user.

Examples:

GithubContributionsApi.user_events("octocat")

GithubContributionsApi.user_events("octocat", :page => 1)

GithubContributionsApi.user_events("s2t2", :page => 2)

Parameters:

  • github_username (String)

    The username of the github user.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :page (Integer) — default: 1

    The requested page number.

Returns:

  • (Hash)


28
29
30
31
32
33
# File 'lib/github_contributions_api.rb', line 28

def self.user_events(github_username, options = {})
  page_number = options[:page] || 1
  request_url = "#{URL_BASE}/user/#{github_username}/events/#{page_number}"
  response = HTTParty.get(request_url)
  JSON.parse(response.body)
end