GitHub contribution graph parser calculates contribution streak and commit statistics from a user's GitHub contribution graph page
The GitHub API does not provide contribution streak data; this package scrapes and parses the contribution graph from a user's GitHub contribution graph at https://github.com/users/USERNAME/contributions to provide contribution streak and commit statistics.
Install from npm with your favourite package manager:
# npm
npm install contribution
# yarn
yarn add contribution
# pnpm
pnpm add contribution
# bun
bun add contribution
Import the function and call it with a GitHub username:
import { fetchGitHubStats } from 'contribution';
const stats = await fetchGitHubStats('jamieweavis');
console.log(stats);
The returned GitHubStats
object has the following structure:
interface GitHubStats {
// Streak
bestStreak: number;
previousStreak: number;
currentStreak: number;
isStreakAtRisk: boolean;
// Contributions
mostContributions: number;
todaysContributions: number;
totalContributions: number;
contributions: Contributions;
}
interface Contributions {
[date: string]: Day; // [YYYY-MM-DD]
}
interface Day {
contributions: number;
gitHubLegendLevel: number;
}
Clone the repository and install dependencies:
git clone https://github.com/jamieweavis/contribution.git
cd contribution
pnpm install
Run all tests with Vitest:
pnpm test
Check the code for linting and formatting issues with Biome:
pnpm check
Build the package with Parcel:
pnpm build
- Streaker - Cross-platform GitHub contribution streak & statistic tracking menu bar application with reminder notification
- Streaker CLI - GitHub contribution streak & statistic tracking command line application with ASCII contribution graph