Use the REST API to fetch the data that GitHub uses for visualizing different types of repository activity.
You can use the REST API to fetch the data that GitHub uses for visualizing different types of repository activity.
Computing repository statistics is an expensive operation, so we try to return cached
data whenever possible. If the data hasn't been cached when you query a repository's
statistics, you'll receive a 202 response; a background job is also fired to
start compiling these statistics. You should allow the job a short time to complete, and
then submit the request again. If the job has completed, that request will receive a
200 response with the statistics in the response body.
Repository statistics are cached by the SHA of the repository's default branch; pushing to the default branch resets the statistics cache.
The statistics exposed by the API match the statistics shown by different repository graphs.
To summarize this:
Note
Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.
GET /repos/{owner}/{repo}/stats/code_frequency
Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
Note
This endpoint can only be used for repositories with fewer than 10,000 commits. If the repository contains 10,000 or more commits, a 422 status code will be returned.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
200 - Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
202 - Accepted
204 - A header with no content is returned.
422 - Repository contains more than 10,000 commits
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/stats/code_frequency
Response schema (Status: 200):
Array of array
GET /repos/{owner}/{repo}/stats/commit_activity
Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
200 - OK
202 - Accepted
204 - A header with no content is returned.
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/stats/commit_activity
Response schema (Status: 200):
Array of Commit Activity:
days: required, array of integertotal: required, integerweek: required, integerGET /repos/{owner}/{repo}/stats/contributors
Returns the total number of commits authored by the contributor. In addition, the response includes a Weekly Hash (weeks array) with the following information:
w - Start of the week, given as a Unix timestamp.
a - Number of additions
d - Number of deletions
c - Number of commits
Note
This endpoint will return 0 values for all addition and deletion counts in repositories with 10,000 or more commits.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
200 - OK
202 - Accepted
204 - A header with no content is returned.
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/stats/contributors
Response schema (Status: 200):
Array of Contributor Activity:
author: required, any of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringtotal: required, integerweeks: required, array of objects:
w: integera: integerd: integerc: integerGET /repos/{owner}/{repo}/stats/participation
Returns the total commit counts for the owner and total commit counts in all. all is everyone combined, including the owner in the last 52 weeks. If you'd like to get the commit counts for non-owners, you can subtract owner from all.
The array order is oldest week (index 0) to most recent week.
The most recent week is seven days ago at UTC midnight to today at UTC midnight.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
200 - The array order is oldest week (index 0) to most recent week.
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/stats/participation
Response schema (Status: 200):
all: required, array of integerowner: required, array of integerGET /repos/{owner}/{repo}/stats/punch_card
Each array contains the day number, hour number, and number of commits:
0-6: Sunday - Saturday
0-23: Hour of day
Number of commits
For example, [2, 14, 25] indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
200 - For example, [2, 14, 25] indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits.
204 - A header with no content is returned.
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/stats/punch_card
Response schema (Status: 200):
Same response schema as Get the weekly commit activity.