Files
github-readme-stats/README.md
T

440 lines
15 KiB
Markdown

# github-readme-stats
[![tests](https://github.com/ShayManor/github-readme-stats/actions/workflows/tests.yml/badge.svg)](https://github.com/ShayManor/github-readme-stats/actions/workflows/tests.yml)
[![build and deploy](https://github.com/ShayManor/github-readme-stats/actions/workflows/deploy.yml/badge.svg)](https://github.com/ShayManor/github-readme-stats/actions/workflows/deploy.yml)
A single SVG widget you drop into your GitHub profile README. It scores
your account, charts your contribution timeline, highlights your top
collaborators, breaks down your languages, tracks your commit streaks,
and earns you tags like `Backend`, `ML`, or `Founder #42`.
[![example card](https://gh-stats.com/api/shaymanor)](https://gh-stats.com)
That card is live, not a screenshot. Swap in your own username:
```md
[![my stats](https://gh-stats.com/api/YOUR_USERNAME)](https://gh-stats.com)
```
<img src="./assets/examples/composite-midnight.svg" width="420" alt="composite widget, midnight theme" />
<details>
<summary>Table of contents (click to expand)</summary>
- [Quick start](#quick-start)
- [Themes](#themes)
- [Individual widgets](#individual-widgets)
- [Migrating from github-readme-stats](#migrating-from-github-readme-stats)
- [Query parameter reference](#query-parameter-reference)
- [Auto-awarded tags](#auto-awarded-tags)
- [Refreshing your data](#refreshing-your-data)
- [FAQ](#faq)
- [Gallery](#gallery)
</details>
---
## Quick start
1. Open <https://gh-stats.com/api/>.
2. Sign in with GitHub. Signing in is how you prove ownership of the
username, and it unlocks the editor.
3. Pick a theme, reorder widgets, add any custom tags or achievements.
4. Click **Get embed code**.
5. Paste this one line into your profile README:
```md
[![my stats](https://gh-stats.com/api/YOUR_USERNAME)](https://gh-stats.com)
```
The image URL is stable. Once it's in your README you can change
themes, tags, or widget order in the editor at any time without
touching the markdown.
> [!NOTE]
> Only public GitHub activity is counted. Private repos, private
> commit counts, and contributions to org-restricted repos are never
> visible to the fetcher.
---
## Themes
Pass `?theme=<name>` on the URL, or pick one in the editor.
| Theme | Preview |
|---|---|
| `midnight` (default) | <img src="./assets/examples/composite-midnight.svg" width="280" /> |
| `onyx` | <img src="./assets/examples/composite-onyx.svg" width="280" /> |
| `nord` | <img src="./assets/examples/composite-nord.svg" width="280" /> |
| `clean` | <img src="./assets/examples/composite-clean.svg" width="280" /> |
| `paper` | <img src="./assets/examples/composite-paper.svg" width="280" /> |
```md
![stats](https://gh-stats.com/api/YOUR_USERNAME?theme=onyx)
```
### Auto-switching for dark and light mode
Add GitHub's theme suffix to serve a different image to dark vs. light
viewers:
```md
![dark](https://gh-stats.com/api/YOUR_USERNAME?theme=onyx#gh-dark-mode-only)
![light](https://gh-stats.com/api/YOUR_USERNAME?theme=clean#gh-light-mode-only)
```
Or use `<picture>` for precise `prefers-color-scheme` control:
```html
<picture>
<source srcset="https://gh-stats.com/api/YOUR_USERNAME?theme=onyx"
media="(prefers-color-scheme: dark)" />
<source srcset="https://gh-stats.com/api/YOUR_USERNAME?theme=clean"
media="(prefers-color-scheme: light)" />
<img src="https://gh-stats.com/api/YOUR_USERNAME" />
</picture>
```
---
## Individual widgets
Every widget is independently addressable at
`https://gh-stats.com/api/<username>/<widget>.svg`. Embed one, two, or all
of them.
### Grade
Overall score (0 to 100), letter grade, and your top role tags.
<img src="./assets/examples/grade.svg" width="380" alt="grade widget" />
```md
![grade](https://gh-stats.com/api/YOUR_USERNAME/grade.svg)
```
#### How the score works
The score is a weighted sum of seven public signals. Each signal earns
0 to 100 points, reaching 100 at the cap shown, and the weights add up to
100%.
| Signal | Weight | Cap |
| --- | --- | --- |
| Contributions, all time (commits, PRs, issues, reviews) | 33% | 3,000 |
| Active weeks in the last year | 22% | 40 |
| Repositories (owned and contributed to, at most 50 counted) | 15% | 40 |
| Stars across those repositories | 11% | 200 |
| Forks across those repositories | 8% | 20 |
| Recent public events | 8% | 80 |
| Followers | 3% | 100 |
Letters follow the total: S++ from 97, S+ 93, S 89, A++ 86, A+ 82, A 78,
A- 72, B++ 68, B+ 64, B 58, B- 50, C+ 42, and C below that. The score
measures the volume and regularity of public activity, not code quality.
Private work is invisible to it. To leave it off your card, turn off the
Grade widget in the editor.
### Impact
Your contribution volume over the last 6 months, drawn as a smooth area
chart.
<img src="./assets/examples/impact.svg" width="380" alt="impact widget" />
```md
![impact](https://gh-stats.com/api/YOUR_USERNAME/impact.svg)
```
### Streaks
Current and longest contribution streaks.
<img src="./assets/examples/streaks.svg" width="380" alt="streaks widget" />
```md
![streaks](https://gh-stats.com/api/YOUR_USERNAME/streaks.svg)
```
### Top collaborators
The people you actually work with, filtered down to repos of a
reasonable size so a drive-by PR to `react` does not put the React team
on your card.
<img src="./assets/examples/collaborators.svg" width="380" alt="collaborators widget" />
```md
![collaborators](https://gh-stats.com/api/YOUR_USERNAME/collaborators.svg)
```
### Recent focus
What you have actually been working on lately, grouped by topic.
<img src="./assets/examples/focus.svg" width="380" alt="focus widget" />
```md
![focus](https://gh-stats.com/api/YOUR_USERNAME/focus.svg)
```
### Languages
Your language mix, weighted by bytes in repos you authored. Forks with
no meaningful contribution are ignored.
<img src="./assets/examples/languages.svg" width="380" alt="languages widget" />
```md
![languages](https://gh-stats.com/api/YOUR_USERNAME/languages.svg)
```
### Achievements
Hand-entered lines for hackathons, talks, awards, and certifications.
<img src="./assets/examples/achievements.svg" width="380" alt="achievements widget" />
```md
![achievements](https://gh-stats.com/api/YOUR_USERNAME/achievements.svg)
```
### Side by side
GitHub strips inline CSS, so an HTML table is the simplest way to put
two widgets next to each other.
```html
<table><tr>
<td><img src="https://gh-stats.com/api/YOUR_USERNAME/grade.svg" /></td>
<td><img src="https://gh-stats.com/api/YOUR_USERNAME/languages.svg" /></td>
</tr></table>
```
---
## Migrating from github-readme-stats
[`anuraghazra/github-readme-stats`](https://github.com/anuraghazra/github-readme-stats)
is the card most profile READMEs use, and it is a good project. Its README now
carries a deprecation notice pointing at a successor, so if you are looking to
move, the common URL shapes work here with only the domain changed.
| Your current URL | Change it to |
|---|---|
| `github-readme-stats.vercel.app/api?username=U` | `gh-stats.com/api?username=U` |
| `github-readme-stats.vercel.app/api/top-langs?username=U` | `gh-stats.com/api/top-langs?username=U` |
| `github-readme-streak-stats.herokuapp.com/?user=U` | `gh-stats.com/api/streak/U` |
Nothing else in your README changes.
> [!NOTE]
> `theme=` is honoured on the composite card (`/api/<user>`). On the
> compatibility and single-widget URLs above it is currently ignored and the
> default theme is served.
If you would rather replace several badges with one image, use the composite
card instead and delete the rest:
```md
![stats](https://gh-stats.com/api/YOUR_USERNAME)
```
## Query parameter reference
Every URL accepts query parameters. They override the owner's saved
settings on a per-embed basis, so viewers can tweak the look without
changing anything the owner has stored.
Values with special characters must be URL-encoded: `#a78bfa` becomes
`%23a78bfa`, a space becomes `%20`.
### Common parameters
| Parameter | What it does | Example |
|---|---|---|
| `theme` | Built-in theme name. | `?theme=onyx` |
| `widgets` | Which widgets to show on the composite card. | `?widgets=grade,streaks,languages` |
| `order` | Render order on the composite card. | `?order=grade,streaks,languages` |
| `hide` | Languages to exclude from the languages widget. | `?hide=HTML,CSS,Makefile` |
| `tags` | Extra custom role tags on the grade widget. | `?tags=ML,Systems` |
### Per-widget parameters
Use dot notation: `<widget>.<key>=<value>`.
| Parameter | What it does | Type | Default |
|---|---|---|---|
| `grade.max_tags` | Max role tags shown (1 to 20). | int | all tags |
| `impact.line_color` | Accent color for the area curve. | hex color | theme accent |
| `streaks.color` | Accent color for the current-streak text. | hex color | theme accent |
| `collaborators.max_count` | Max collaborators shown (1 to 10). | int | 5 |
| `collaborators.bar_color` | Accent color for the commit bars. | hex color | theme accent |
| `focus.max_categories` | Max focus clusters shown (1 to 10). | int | 6 |
| `languages.max_languages` | Max languages shown (1 to 10). | int | 5 |
| `achievements.max_items` | Max achievement rows shown (1 to 10). | int | 5 |
---
## Auto-awarded tags
Some tags on the grade card are earned from real activity. No query
parameter will add them if you have not earned them:
- `Founder #N` is your enrollment number, fixed when you first sign in.
- Role tags like `Backend`, `Frontend`, `ML`, `Mobile`, `DevOps`,
`Cloud`, `Systems`, `Database`, `Security` are derived from your
language mix and repo topics.
---
## Refreshing your data
The refresh cron re-pulls GitHub data every 15 minutes, so new commits
usually appear in your widget within that window. GitHub's image CDN
may add another minute or two on top.
If you need an immediate update (for example right after merging
something big), click **Refresh now** in the editor. It is a one-shot
per account, so save it for when it matters.
---
## Self-hosting
The public instance at `gh-stats.com` is free and you do not need to run your
own. Self-host if you want your own rate limit, private repository data staying
on your hardware, or control over when cards rebuild.
You need Docker and a GitHub token. The token needs no scopes for public data;
it exists to raise your GitHub API rate limit.
```bash
git clone https://github.com/ShayManor/github-readme-stats
cd github-readme-stats
cp .env.example .env # put your token in GITHUB_PAT
docker compose up -d --build
```
Then open `http://localhost:5002` and embed from your own host:
```md
![stats](http://localhost:5002/api/YOUR_USERNAME)
```
Three services come up behind `docker compose`: `fetcher` talks to GitHub and
owns the token, `generator` renders the SVGs and serves the web UI on 5002, and
`edge` is a caching proxy on 5003 that serves cards at `/<username>`. Data lives
in `./data`. Set `GHSTATS_PORT` to move the web UI off 5002.
## FAQ
**Can I use a private GitHub account?**
No. The service only reads public activity. Private repos, private
commit counts, and contributions to org-restricted repos are not
visible to GitHub's public API, so they are never part of the widget.
**How fresh is the data?**
Every 15 minutes, automatically. You can also click **Refresh now**
once per account for an immediate update.
**How do I edit my widget?**
Sign in with GitHub at <https://gh-stats.com/api/>. Only the account whose
login matches the username can edit that widget's settings.
**Can I change the widget without re-embedding?**
Yes. The image URL is stable. Edit in the editor, click **Get embed code**,
and the next fetch serves the new version. GitHub's image cache may
delay propagation by a few minutes.
**Can I embed someone else's widget with my own theme or filters?**
Yes, use the [query parameters](#query-parameter-reference). The
owner's saved settings are not affected.
**I am getting a placeholder card. What is wrong?**
`building` means the first render is still in progress, give it a
minute. `not_found` means GitHub does not know that username.
**Why does my languages card look wrong?**
It counts bytes in repos you authored. Forks with little commit
activity are dropped. Add `?hide=HTML,CSS,Makefile` if generated files
dominate the breakdown.
**Can I reorder widgets?**
Yes, either in the editor (drag and drop) or by passing
`?widgets=...&order=...` on the URL.
---
## Gallery
### Composite themes
<table>
<tr>
<td align="center"><b>midnight</b><br/><img src="./assets/examples/composite-midnight.svg" width="260" /></td>
<td align="center"><b>onyx</b><br/><img src="./assets/examples/composite-onyx.svg" width="260" /></td>
</tr>
<tr>
<td align="center"><b>nord</b><br/><img src="./assets/examples/composite-nord.svg" width="260" /></td>
<td align="center"><b>clean</b><br/><img src="./assets/examples/composite-clean.svg" width="260" /></td>
</tr>
<tr>
<td align="center"><b>paper</b><br/><img src="./assets/examples/composite-paper.svg" width="260" /></td>
<td align="center"><b>custom (onyx, 3 widgets)</b><br/><img src="./assets/examples/composite-custom.svg" width="260" /></td>
</tr>
</table>
### Single-widget examples
<table>
<tr>
<td align="center"><b>Grade</b><br/><img src="./assets/examples/grade.svg" width="320" /></td>
<td align="center"><b>Grade (max_tags=3)</b><br/><img src="./assets/examples/grade-compact.svg" width="320" /></td>
</tr>
<tr>
<td align="center"><b>Impact</b><br/><img src="./assets/examples/impact.svg" width="320" /></td>
<td align="center"><b>Impact (purple line)</b><br/><img src="./assets/examples/impact-purple.svg" width="320" /></td>
</tr>
<tr>
<td align="center"><b>Streaks</b><br/><img src="./assets/examples/streaks.svg" width="320" /></td>
<td align="center"><b>Streaks (green)</b><br/><img src="./assets/examples/streaks-green.svg" width="320" /></td>
</tr>
<tr>
<td align="center"><b>Languages</b><br/><img src="./assets/examples/languages.svg" width="320" /></td>
<td align="center"><b>Languages (hide Shell, Dockerfile)</b><br/><img src="./assets/examples/languages-hide.svg" width="320" /></td>
</tr>
<tr>
<td align="center"><b>Collaborators</b><br/><img src="./assets/examples/collaborators.svg" width="320" /></td>
<td align="center"><b>Focus</b><br/><img src="./assets/examples/focus.svg" width="320" /></td>
</tr>
<tr>
<td align="center"><b>Achievements</b><br/><img src="./assets/examples/achievements.svg" width="320" /></td>
<td></td>
</tr>
</table>
### Mix and match
Embed two widgets side by side with an HTML table:
```html
<table><tr>
<td><img src="https://gh-stats.com/api/YOUR_USERNAME/grade.svg" /></td>
<td><img src="https://gh-stats.com/api/YOUR_USERNAME/languages.svg" /></td>
</tr></table>
```
Stack a custom composite with only three widgets:
```md
![stats](https://gh-stats.com/api/YOUR_USERNAME?theme=onyx&widgets=grade,streaks,languages&order=grade,streaks,languages)
```
Recolor the impact line:
```md
![impact](https://gh-stats.com/api/YOUR_USERNAME/impact.svg?impact.line_color=%23a78bfa)
```