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

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

Описание и применение

Создание графиков звезд GitHub в README с использованием нового эндпоинта истории звёзд, позволяющего получать данные без аутентификации и отображать их в виде SVG.

Задача

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