Skip to main content
설명서에 자주 업데이트를 게시하며 이 페이지의 번역이 계속 진행 중일 수 있습니다. 최신 정보는 영어 설명서를 참조하세요.
이제 REST API의 버전이 지정됩니다. 자세한 내용은 "API 버전 관리 정보"를 참조하세요.

리포지토리 통계

REST API를 사용하여 GitHub Enterprise Cloud이 다양한 유형의 리포지토리 활동을 시각화하는 데 사용하는 데이터를 가져옵니다.

리포지토리 통계 정보

REST API를 사용하여 GitHub Enterprise Cloud이 다양한 유형의 리포지토리 활동을 시각화하는 데 사용하는 데이터를 가져올 수 있습니다.

캐싱 모범 사례

리포지토리 통계 컴퓨팅은 비용이 많이 드는 작업이므로 가능하면 캐시된 데이터를 반환하려고 합니다. 리포지토리의 통계를 쿼리할 때 데이터가 캐시되지 않은 경우 202 응답을 받게 됩니다. 해당 통계를 컴파일하기 위한 백그라운드 작업도 발생합니다. 작업을 잠시 완료하도록 허용한 다음 요청을 다시 제출해야 합니다. 작업이 완료되면 해당 요청은 응답 본문에 통계가 포함된 200 응답을 받게 됩니다.

리포지토리 통계는 리포지토리의 기본 분기의 SHA에 의해 캐시됩니다. 기본 분기로 푸시하면 통계 캐시가 다시 설정됩니다.

통계는 일부 유형의 커밋을 제외합니다.

API에서 노출하는 통계는 다른 리포지토리 그래프에 표시된 통계와 일치합니다.

요약하려면 다음을 수행합니다.

  • 모든 통계는 병합 커밋을 제외합니다.
  • 기여자 통계는 빈 커밋도 제외합니다.

Get the weekly commit activity

에서 작동 GitHub Apps

Returns a weekly aggregate of the number of additions and deletions pushed to a repository.

매개 변수

헤더
이름, Type, 설명
acceptstring

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, Type, 설명
ownerstring필수

The account owner of the repository. The name is not case sensitive.

repostring필수

The name of the repository. The name is not case sensitive.

HTTP 응답 상태 코드

상태 코드Description
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.

코드 샘플

get/repos/{owner}/{repo}/stats/code_frequency
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/stats/code_frequency

Returns a weekly aggregate of the number of additions and deletions pushed to a repository.

Status: 200
[ [ 1302998400, 1124, -435 ] ]

Get the last year of commit activity

에서 작동 GitHub Apps

Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday.

매개 변수

헤더
이름, Type, 설명
acceptstring

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, Type, 설명
ownerstring필수

The account owner of the repository. The name is not case sensitive.

repostring필수

The name of the repository. The name is not case sensitive.

HTTP 응답 상태 코드

상태 코드Description
200

OK

202

Accepted

204

A header with no content is returned.

코드 샘플

get/repos/{owner}/{repo}/stats/commit_activity
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/stats/commit_activity

Response

Status: 200
[ { "days": [ 0, 3, 26, 20, 39, 1, 0 ], "total": 89, "week": 1336280400 } ]

Get all contributor commit activity

에서 작동 GitHub Apps

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

매개 변수

헤더
이름, Type, 설명
acceptstring

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, Type, 설명
ownerstring필수

The account owner of the repository. The name is not case sensitive.

repostring필수

The name of the repository. The name is not case sensitive.

HTTP 응답 상태 코드

상태 코드Description
200

OK

202

Accepted

204

A header with no content is returned.

코드 샘플

get/repos/{owner}/{repo}/stats/contributors
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/stats/contributors

Response

Status: 200
[ { "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "total": 135, "weeks": [ { "w": 1367712000, "a": 6898, "d": 77, "c": 10 } ] } ]

Get the weekly commit count

에서 작동 GitHub Apps

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.

매개 변수

헤더
이름, Type, 설명
acceptstring

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, Type, 설명
ownerstring필수

The account owner of the repository. The name is not case sensitive.

repostring필수

The name of the repository. The name is not case sensitive.

HTTP 응답 상태 코드

상태 코드Description
200

The array order is oldest week (index 0) to most recent week.

404

Resource not found

코드 샘플

get/repos/{owner}/{repo}/stats/participation
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/stats/participation

The array order is oldest week (index 0) to most recent week.

Status: 200
{ "all": [ 11, 21, 15, 2, 8, 1, 8, 23, 17, 21, 11, 10, 33, 91, 38, 34, 22, 23, 32, 3, 43, 87, 71, 18, 13, 5, 13, 16, 66, 27, 12, 45, 110, 117, 13, 8, 18, 9, 19, 26, 39, 12, 20, 31, 46, 91, 45, 10, 24, 9, 29, 7 ], "owner": [ 3, 2, 3, 0, 2, 0, 5, 14, 7, 9, 1, 5, 0, 48, 19, 2, 0, 1, 10, 2, 23, 40, 35, 8, 8, 2, 10, 6, 30, 0, 2, 9, 53, 104, 3, 3, 10, 4, 7, 11, 21, 4, 4, 22, 26, 63, 11, 2, 14, 1, 10, 3 ] }

Get the hourly commit count for each day

에서 작동 GitHub Apps

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.

매개 변수

헤더
이름, Type, 설명
acceptstring

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, Type, 설명
ownerstring필수

The account owner of the repository. The name is not case sensitive.

repostring필수

The name of the repository. The name is not case sensitive.

HTTP 응답 상태 코드

상태 코드Description
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.

코드 샘플

get/repos/{owner}/{repo}/stats/punch_card
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/stats/punch_card

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.

Status: 200
[ [ 0, 0, 5 ], [ 0, 1, 43 ], [ 0, 2, 21 ] ]