Fetching Stargazers

Download all the users who've starred a GitHub repository ⭐

A user reached out asking if AskGit could export the GitHub profiles of everyone who starred their repository. Absolutely it can! 🎉

This is a pretty simple query 🙂. First, you’ll need to set the GITHUB_TOKEN environment variable.

export GITHUB_TOKEN=my_token

Then, you can run the following:

askgit "SELECT * FROM github_stargazers('askgitdev/askgit')"

And that’s it! You may want to add a --format csv or --format json to get your stargazers in a more usable output format (and pipe the results to a file).1

Some useful fields include:

  • email (reach out directly to your stargazers)

  • company (what companies may be using your project?)

  • twitter (follow your stargazers on Twitter)

  • starred_at (track your repo’s popularity over time)

The folks over at Supabase maintain repository.surf, which lets you visualize stargazers over time for public repos - very cool.

How many stars did I get this week?

Adding a filter (WHERE) and an aggregation (COUNT) to the above lets you find how many people starred a repo over a particular time period. For instance2:

askgit "SELECT count(*) FROM github_stargazers('askgitdev/askgit') WHERE starred_at > date('now', '-10 days') ORDER BY starred_at DESC"

Will calculate how many people starred your repo in the past 10 days. Check out the available date and time functions to try other ranges.

If you want to dig deeper, see this post from Cockroach Labs for inspiration.

An additional “metric” that could be interesting to see is “star throughput” over time - something like stars per day (the “velocity” of stargazer growth vs the total count), which may be a better indicator for project “popularity” at a moment in time.


Also, see exporting results as a SQLite database file, here


The ORDER BY should prevent a “full table scan” of the stargazers of a repository, relying on the GitHub API to return results sorted by starred_at. See here for more context.