Personal GitHub contribution stats — daily, weekly, monthly, yearly — pulled from the GitHub GraphQL API.
- Go to github.com → Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click Generate new token (classic)
- Give it a name (e.g.
gh-analytics) - Select scopes:
read:user(includes private repo contributions in the calendar) - Click Generate token and copy it — you won't see it again
cp .env.example .env
# then edit .env and paste your tokennode gh_stats.tsRequires Node 23+ (native TypeScript support, no build step).
All settings go in .env:
| Variable | Default | Description |
|---|---|---|
GITHUB_TOKEN |
(required) | Your PAT |
GITHUB_USER |
matt-trem |
GitHub username to query |
GITHUB_SINCE_YEAR |
3 years ago | Earliest year to fetch |
=== DAILY (last 30 days) ===
DATE COUNT CHART
--------------------------------------------------
2026-05-10 2 ##
2026-05-11 0
...
=== WEEKLY (last 12 weeks) ===
WEEK START COUNT
------------------
2026-03-16 8
...
=== MONTHLY (last 12 months) ===
MONTH COUNT
----------------
2025-07 12
...
=== YEARLY ===
YEAR COUNT
------------
2024 134
2025 201
- Uses GitHub's
contributionsCollectionGraphQL API — same data as the green squares on your profile. - Counts commits, PRs, reviews, issues, and issue comments.
- Private repo contributions are included when your PAT has
read:userscope. - Progress lines go to stderr; data goes to stdout — safe to pipe or redirect.