Building README star charts on GitHub's new star history endpoint
Description and use
Building README star charts using GitHub’s new star history endpoint, enabling public repositories to display accurate, animated star history charts in their README files.
Problem
GitHub restricted the stargazers listing to repo admins and collaborators, breaking existing star history tools that relied on that endpoint.
Outcome
The implementation allows any public repository to display an accurate, animated star history chart in its README, overcoming the previous limitation of the stargazers endpoint.
Workflow
- 1. Calculate the number of weeks since repo creation.
- 2. Determine required pages (max 100, 30 weeks per page).
- 3. Fetch all pages in parallel using the endpoint
GET /repos/{owner}/{repo}/stargazers/historywithper_page=30andpageparameters. - 4. Flatten, sort ascending by week, and accumulate weekly totals to produce a running sum.
- 5. Cache the aggregated data for an hour.
- 6. Render the chart as an SVG using a Svelte component served at
/owner/repo.svg. - 7. For social cards, render a plain SVG and convert to PNG with
@resvg/resvg-js. - 8. Embed the SVG in the README to display the star history chart.
Evidence
GitHub limited the stargazers listing to repo admins and collaborators. Star history tools had relied on that endpoint, so they had to find another way to get their data.
In September GitHub added a replacement built for exactly this: a star history endpoint.
It works for any public repo, without authentication.
I checked it against live star counts on seven repos, including vercel/next.js and torvalds/linux. The weekly totals matched the star count exactly in every case.
The chart has to render inside a GitHub README, where scripts do not run. So the chart is a Svelte component, and the /owner/repo.svg route renders it on the server.
- Record date: 2026-11-01T06:14:18.095Z