How to: List user Repositories and respective Stargazers on GitHub

Vinicius Moura
2 min readSep 5, 2022

This script and report extract all user repositories and stargazers on GitHub in the timeline

An original script is available on my GitHub repository. See below this script:

Let’s go understand each command used.

  1. PowerShell script will receive the following parameters:
  • $PAT = Personal Access token to connect on GitHub user account;
  • $UserGitHub = GitHub user name;
  • $Connstr = connection string to Azure SQL Database stores the report information. To create this report, it’s necessary to create a Azure SQL Server and Database previously and run a script below:

2. List repositories for a user = use this REST API to list public repositories for the specified user

$headers=@{Authorization='Basic {0}' -f $base64Token;Accept='application/'}
$Repos = @()
$RepositoriesResult=Invoke-RestMethod -Headers $headers -Uri $uriRepositories
} while ($RepositoriesResult.Count -gt 0)

3. List stargazers = use this REST API to list the people that have starred the repository

$uriStargazers="$($UriRepos)/$($ page=$($pageStargazers)"
$StargazersRepoResult=Invoke-RestMethod -Headers $headers -Uri $uriStargazers
foreach ($stargazer in $StargazersRepoResult)
} while ($StargazersRepoResult.Count -gt 0)

4. After extracting all repositories, and stargazers, this information is stored in a table in Azure SQL.

5. After inserting information into a table, I connected this database on Power BI:

  • Repository Name (1) = Filter report using Repository Name field;
  • Stargazer Dates (Range) (2) = Filter report using stargazers date range;
  • Repositories, stargazer date, and avatar (3) = List all information about stargazer occurrences, respective date, and stargazer on each user repository;
  • Number of Stargazers per repository (4): a chart that shows the number of stargazers per repository;
  • Number of stargazers per Year/Month (evolution) (5): a chart that shows the evolution of stargazers in the timeline.