최근에 REST API 설명서 중 일부를 이동했습니다. 원하는 항목을 찾을 수 없는 경우 새 Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks REST API 페이지를 사용해 볼 수 있습니다.
리포지토리 통계
Use the REST API to fetch the data that GitHub AE uses for visualizing different types of repository activity.
About repository statistics
You can use the REST API to fetch the data that GitHub AE uses for visualizing different types of repository activity.
Best practices for caching
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.
Statistics exclude some types of commits
The statistics exposed by the API match the statistics shown by different repository graphs.
To summarize this:
- All statistics exclude merge commits.
- Contributor statistics also exclude empty commits.
Get the weekly commit activity
Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
"Get the weekly commit activity"에 대한 매개 변수
이름, Type, 설명 |
---|
accept string Setting to |
이름, Type, 설명 |
---|
owner string RequiredThe account owner of the repository. The name is not case sensitive. |
repo string RequiredThe name of the repository without the |
"Get the weekly commit activity"에 대한 HTTP 응답 상태 코드
상태 코드 | 설명 |
---|---|
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 the weekly commit activity"에 대한 코드 샘플
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/stats/code_frequency
Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
Get the last year of 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
.
"Get the last year of commit activity"에 대한 매개 변수
이름, Type, 설명 |
---|
accept string Setting to |
이름, Type, 설명 |
---|
owner string RequiredThe account owner of the repository. The name is not case sensitive. |
repo string RequiredThe name of the repository without the |
"Get the last year of commit activity"에 대한 HTTP 응답 상태 코드
상태 코드 | 설명 |
---|---|
200 | OK |
202 | Accepted |
204 | A header with no content is returned. |
"Get the last year of commit activity"에 대한 코드 샘플
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/stats/commit_activity
Response
Get all contributor commit activity
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 additionsd
- Number of deletionsc
- Number of commits
"Get all contributor commit activity"에 대한 매개 변수
이름, Type, 설명 |
---|
accept string Setting to |
이름, Type, 설명 |
---|
owner string RequiredThe account owner of the repository. The name is not case sensitive. |
repo string RequiredThe name of the repository without the |
"Get all contributor commit activity"에 대한 HTTP 응답 상태 코드
상태 코드 | 설명 |
---|---|
200 | OK |
202 | Accepted |
204 | A header with no content is returned. |
"Get all contributor commit activity"에 대한 코드 샘플
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/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
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.
"Get the weekly commit count"에 대한 매개 변수
이름, Type, 설명 |
---|
accept string Setting to |
이름, Type, 설명 |
---|
owner string RequiredThe account owner of the repository. The name is not case sensitive. |
repo string RequiredThe name of the repository without the |
"Get the weekly commit count"에 대한 HTTP 응답 상태 코드
상태 코드 | 설명 |
---|---|
200 | The array order is oldest week (index 0) to most recent week. |
404 | Resource not found |
"Get the weekly commit count"에 대한 코드 샘플
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/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
Each array contains the day number, hour number, and number of commits:
0-6
: Sunday - Saturday0-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.
"Get the hourly commit count for each day"에 대한 매개 변수
이름, Type, 설명 |
---|
accept string Setting to |
이름, Type, 설명 |
---|
owner string RequiredThe account owner of the repository. The name is not case sensitive. |
repo string RequiredThe name of the repository without the |
"Get the hourly commit count for each day"에 대한 HTTP 응답 상태 코드
상태 코드 | 설명 |
---|---|
200 | For example, |
204 | A header with no content is returned. |
"Get the hourly commit count for each day"에 대한 코드 샘플
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/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.