Best way to gather all stars a user has received


I’m trying to sum all the stars a given user has received in his repos.
What’s the fastest way to query this?

Right now I’m querying all the users repos, to access that repos stars so I can add them up.

Is there a way to:

  • Accessing the stars without fetching every repo
  • Sorting repos by their star count so I can get just fetch, say, the top 6 repos.

Cheers :).


I’m afraid not. We must fetch the repo to know if it’s been starred or not.

Yes! We just have to get a little crafty. :grin:

Our early access GraphQL system supports our search syntaxes. You can craft a query that looks like this:

  search(type: REPOSITORY, query: "user:gjtorikian sort:stars-desc", first: 6) {
    edges {
      node {
        ... on Repository {
          stargazers {

That says: given a user, get me their first six repositories sorted by stars descending; on each ... on Repository fragment, I want the name of the repo, and the total count of stargazers.

Hope this helps!