Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Building README star charts on GitHub's new star history endpoint

说明与用途

使用 GitHub 新的星标历史端点构建 README 星标图表,允许公共仓库在 README 中显示准确、动画化的星标历史图表。

问题

GitHub restricted the stargazers listing to repo admins and collaborators, breaking existing star history tools that relied on that endpoint.

结果

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.

工作流

  • 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/history with per_page=30 and page parameters.
  • 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.

证据

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.

来源

  • 记录日期: 2026-11-01T06:14:18.095Z