GitHub Copilot has revolutionized how developers write code by leveraging AI-powered suggestions to enhance productivity. If you’re a developer or team leader using GitHub Copilot, you might want to track its usage and impact across your projects. GitHub provides APIs that allow you to extract insightful data about Copilot’s performance and usage, helping you measure its value effectively.
In this blog, we’ll explore how to generate a GitHub Copilot usage report using the GitHub API, providing step-by-step instructions to automate the process.
- Generate the Personal access token – Go to Developer Settings

Select Personal Access tokens -> Tokens(classic)
Click generate new token, Write a note, select expiration.

Now select the scope as copilot and hit generate token.

Copy the token as you will need that token for calling Github copilot API.
2. Now define your variables:
$ent = “vscopilot”
$apiUrl = "https://api.github.com/enterprises/$ent/copilot/billing/seats"
$token =”access token you got from the developer settings”
3. Utilize the function I am sharing below to call github copilot API
function Invoke-GitHubApi {
param (
[string]$url
)
$headers = @{
Authorization = “token $token”
Accept = “application/vnd.github.v3+json”
}
$allResults = @()
$page = 1
do {
$pagedUrl = $url + “?page=” + $page
$response = Invoke-RestMethod -Uri $pagedUrl -Headers $headers -Method Get
$allResults += $response.Seats
$page++
} while ($response.Seats.Count -gt 0)
return $allResults
}
4. Call the API using below command
$copilotUsers = Invoke-GitHubApi -url $apiUrl
Here is the snippet that shows what will happen in Realtime when you will combine this code:

You can further drill down each record and create a nice report, example to get the login name
$copilotUsers[0].assignee.login
By leveraging the GitHub API, you can automate the generation of insightful Copilot usage reports, empowering you to maximize the value of this AI-driven tool
Tech Wizard
https://techwizard.cloud
Pingback: Automating GitHub Copilot Metrics Reporting with PowerShell | Tech Wizard
Pingback: Automating GitHub Copilot Metrics Reporting with PowerShell - multicloud365