Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tomerfi/github-viewer-stats

Small NPM package for collecting your own GitHub statistics
https://github.com/tomerfi/github-viewer-stats

github npm-package npm-script statistics

Last synced: 17 days ago
JSON representation

Small NPM package for collecting your own GitHub statistics

Awesome Lists containing this project

README

        

Collect Your Own GitHub Statistics

Run as a script (using my own token)

```shell
npx github-viewer-stats contribs
```

```json
{
"name": "Tomer Figenblat",
"company": "Red Hat",
"status": "pr is coming",
"contributingSince": 2017,
"totalContributions": 10239,
"contributionsCollection": {
"totalCommitContributions": 7561,
"totalIssueContributions": 114,
"totalPullRequestContributions": 377,
"totalPullRequestReviewContributions": 663,
"totalRepositoriesWithContributedCommits": 202,
"totalRepositoriesWithContributedIssues": 52,
"totalRepositoriesWithContributedPullRequestReviews": 39,
"totalRepositoriesWithContributedPullRequests": 98,
"totalRepositoryContributions": 131,
"totalDiscussionContributions": 80,
"totalGistContributions": 7,
"totalPackageContributions": 0
}
}
```

```shell
npx github-viewer-stats repo aioswitcher
```

```json
{
"name": "aioswitcher",
"description": "PyPi module integrating with various Switcher devices",
"language": "Python",
"license": "apache-2.0",
"collaborators": 2,
"forks": 9,
"stars": 14,
"watchers": 2,
"latest": "3.2.1"
}
```

```shell
npx github-viewer-stats org my-organization
```

```json
{
"name": "My Organization Name",
"description": "My organization description",
"members": 217,
"teams": 2,
"repositories": 16,
"pending": 0,
"twoFactorAuthentication": false,
"webCommitSignoff": false,
"websiteUrl": "https://my-org-site.com/"
}

```

Requires a GITHUB_TOKEN environnement variable (click for the scopes)



  • repo

  • read:packages

  • read:user

  • read:discussion

  • admin:org

admin:org is only required for admin level organization stats, such as 2fa and pending members.

If you do not require these admin properties or do not have admin permission to the organization to begin with, you can use read:org instead.

Of course if won't use this tool for retrieving organization statistics, you can omit the admin all together.

Use as a module

```shell
npm install --save github-viewer-stats
```

```javascript
// print my user statistics to the console
require('github-viewer-stats').contribs().then(r => console.log(JSON.stringify(r, null, 2)));
// print cool-org-name organization statistics to the console
require('github-viewer-stats').org('cool-org-name').then(r => console.log(JSON.stringify(r, null, 2)));
// print my aioswitcher repository statistics to the console
require('github-viewer-stats').repo('aioswitcher').then(r => console.log(JSON.stringify(r, null, 2)));
```

Detailed example

```javascript
const { contribs, org, repo } = require('github-viewer-stats');

async function main() {
// collect my user statistics
let myContributions = await contribs();
console.log(JSON.stringify(myContributions, null, 2));

// collect cool-org-name organization statistics
let myOrg = await org('cool-org-name');
console.log(JSON.stringify(myOrg, null, 2));

// collect my aioswitcher repository statistics
let myRepo = await repo('aioswitcher');
console.log(JSON.stringify(myRepo, null, 2));
}

main();
```