node package manager

github-commits

Framework to get users and organization commit stats from github

GitHub-Commits

Framework to get users and organization commit stats from github

A simple framework to get users and organization commit stats from github. Can filter stats by a date range. Can be used to integrate, git stats into a dashboard.

Inspired by one of Fred George's talk on Programmer Anarchy, in which his team has a dashboard indicating commits for a week.

npm install github-commits

var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .currentWeekCommits()
            .toArray(function(repositories){
              console.log(repositories);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .currentWeekCommits()
            .sumCommits(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .currentWeekCommits()
            .sumOpenIssues(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .commitsUntil("2020-12-31T23:59:59Z")
            .toArray(function(repositories){
              console.log(repositories);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .commitsUntil("2020-12-31T23:59:59Z")
            .sumCommits(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .commitsUntil("2020-12-31T23:59:59Z")
            .sumOpenIssues(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .commitsSince("2013-01-01T23:59:59Z")
            .toArray(function(repositories){
              console.log(repositories);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .commitsSince("2013-01-01T23:59:59Z")
            .sumCommits(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .commitsSince("2013-01-01T23:59:59Z")
            .sumOpenIssues(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .commitsBetween("2013-01-01T23:59:59Z","2020-12-31T23:59:59Z")
            .toArray(function(repositories){
              console.log(repositories);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .commitsBetween("2013-01-01T23:59:59Z","2020-12-31T23:59:59Z")
            .sumCommits(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .commitsBetween("2013-01-01T23:59:59Z","2020-12-31T23:59:59Z")
            .sumOpenIssues(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("github")
            .currentWeekCommits()
            .toArray(function(repositories){
              console.log(repositories);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("github")
            .currentWeekCommits()
            .sumCommits(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("github")
            .currentWeekCommits()
            .sumOpenIssues(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forUser("tjchaplin")
            .commitsUntil("2020-12-31T23:59:59Z")
            .toArray(function(repositories){
              console.log(repositories);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("github")
            .commitsUntil("2020-12-31T23:59:59Z")
            .sumCommits(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("github")
            .commitsUntil("2020-12-31T23:59:59Z")
            .sumOpenIssues(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("tjchaplin")
            .commitsSince("2013-01-01T23:59:59Z")
            .toArray(function(repositories){
              console.log(repositories);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("github")
            .commitsSince("2013-01-01T23:59:59Z")
            .sumCommits(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("github")
            .commitsSince("2013-01-01T23:59:59Z")
            .sumOpenIssues(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("tjchaplin")
            .commitsBetween("2013-01-01T23:59:59Z","2020-12-31T23:59:59Z")
            .toArray(function(repositories){
              console.log(repositories);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("github")
            .commitsBetween("2013-01-01T23:59:59Z","2020-12-31T23:59:59Z")
            .sumCommits(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
var gitHubCommits = new GitHubCommits();
 
gitHubCommits.forOrg("github")
            .commitsBetween("2013-01-01T23:59:59Z","2020-12-31T23:59:59Z")
            .sumOpenIssues(function(sum){
              console.log(sum);
            });
var GitHubCommits = require("github-commits");
//Can specify the GitHub api authorization key for the private or enterprise instance 
var gitHubCommits = new GitHubCommits("<SOME_GITHUB_AUTHORIZATION_KEY>");
var GitHubCommits = require("github-commits");
 
var gitHubUrl = "https://api.github.com";
var apiAuthorizationKey = "<SOME_GITHUB_AUTHORIZATION_KEY>";
 
//Can specify the GitHub api authorization key for the private or enterprise instance 
var gitHubCommits = new GitHubCommits(apiAuthorizationKey,gitHubUrl);
var gitHubCommits = require("github-commits");
 
//Can specify the GitHub api authorization key for the private or enterprise instance 
var enterpriseGitHubUrl = "https://<ENTERPISE_GITHUB_URL>";
var apiAuthorizationKey = "<SOME_GITHUB_AUTHORIZATION_KEY>";
 
var gitHubCommits = new GitHubCommits(apiAuthorizationKey,enterpriseGitHubUrl);

For additional examples see the tests. To run them: npm test

Github limits unauthorized requests to 60 per hour. If you exceed the limit an error will be thrown. An authorization key can be easily obtained as sepecified below, and easily used in the api

var GitHubCommits = require("github-commits");
 
var gitHubUrl = "https://api.github.com";
var apiAuthorizationKey = "<SOME_GITHUB_AUTHORIZATION_KEY>";
 
//Can specify the GitHub api authorization key for the private or enterprise instance 
var gitHubCommits = new GitHubCommits(apiAuthorizationKey,gitHubUrl);

curl -d '{"scopes":["repo"],"note":"Help example"}' https://api.github.com/authorizations