Get community profile metrics
This endpoint will return all community profile metrics, including an overall health score, repository description, the presence of documentation, detected code of conduct, detected license, and the presence of ISSUE_TEMPLATE, PULL_REQUEST_TEMPLATE, README, and CONTRIBUTING files.
The health_percentage score is defined as a percentage of how many of
these four documents are present: README, CONTRIBUTING, LICENSE, and
CODE_OF_CONDUCT. For example, if all four documents are present, then
the health_percentage is 100. If only one is present, then the
health_percentage is 25.
content_reports_enabled is only returned for organization-owned repositories.
get /repos/{owner}/{repo}/community/profileパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/community/profile await octokit.request('GET /repos/{owner}/{repo}/community/profile', {
owner: 'octocat',
repo: 'hello-world'
})Response
Status: 200 OK {
"health_percentage": 100,
"description": "My first repository on GitHub!",
"documentation": null,
"files": {
"code_of_conduct": {
"name": "Contributor Covenant",
"key": "contributor_covenant",
"url": "https://api.github.com/codes_of_conduct/contributor_covenant",
"html_url": "https://github.com/octocat/Hello-World/blob/master/CODE_OF_CONDUCT.md"
},
"code_of_conduct_file": {
"url": "https://api.github.com/repos/octocat/Hello-World/contents/CODE_OF_CONDUCT.md",
"html_url": "https://github.com/octocat/Hello-World/blob/master/CODE_OF_CONDUCT.md"
},
"contributing": {
"url": "https://api.github.com/repos/octocat/Hello-World/contents/CONTRIBUTING",
"html_url": "https://github.com/octocat/Hello-World/blob/master/CONTRIBUTING"
},
"issue_template": {
"url": "https://api.github.com/repos/octocat/Hello-World/contents/ISSUE_TEMPLATE",
"html_url": "https://github.com/octocat/Hello-World/blob/master/ISSUE_TEMPLATE"
},
"pull_request_template": {
"url": "https://api.github.com/repos/octocat/Hello-World/contents/PULL_REQUEST_TEMPLATE",
"html_url": "https://github.com/octocat/Hello-World/blob/master/PULL_REQUEST_TEMPLATE"
},
"license": {
"name": "MIT License",
"key": "mit",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"html_url": "https://github.com/octocat/Hello-World/blob/master/LICENSE",
"node_id": "MDc6TGljZW5zZW1pdA=="
},
"readme": {
"url": "https://api.github.com/repos/octocat/Hello-World/contents/README.md",
"html_url": "https://github.com/octocat/Hello-World/blob/master/README.md"
}
},
"updated_at": "2017-02-28T19:09:29Z",
"content_reports_enabled": true
}注釈
統計
Repository Statistics API を使用すると、GitHub がさまざまなタイプのリポジトリのアクティビティを視覚化するために用いるデータをフェッチできます。
キャッシングについて
リポジトリの統計情報を計算するのは負荷が高い操作なので、可能な限りキャッシュされたデータを返すようにしています。 リポジトリの統計をクエリした際にデータがキャッシュされていなかった場合は、202 レスポンスを受け取ります。また、この統計をまとめるため、バックグラウンドでジョブが開始します。 このジョブが完了するまで少し待ってから、リクエストを再度サブミットしてください。 ジョブが完了していた場合、リクエストは 200 レスポンスを受けとり、レスポンスの本文には統計情報が含まれています。
リポジトリの統計情報は、リポジトリのデフォルトブランチに SHA でキャッシュされ、デフォルトのブランチにプッシュすると統計情報のキャッシュがリセットされます。
統計で除外されるコミットのタイプ
API によって公開される統計は、別のリポジトリグラフで表示される統計と同じものです。
要約すると、
- すべての統計は、マージコミットが除外されます。
- コントリビューター統計では、空のコミットも除外されます。
Get the weekly commit activity
Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
get /repos/{owner}/{repo}/stats/code_frequencyパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/stats/code_frequency await octokit.request('GET /repos/{owner}/{repo}/stats/code_frequency', {
owner: 'octocat',
repo: 'hello-world'
})Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
Status: 200 OK [
[
1302998400,
1124,
-435
]
]Accepted
Status: 202 AcceptedA header with no content is returned.
Status: 204 No Content注釈
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 /repos/{owner}/{repo}/stats/commit_activityパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/stats/commit_activity await octokit.request('GET /repos/{owner}/{repo}/stats/commit_activity', {
owner: 'octocat',
repo: 'hello-world'
})Response
Status: 200 OK [
{
"days": [
0,
3,
26,
20,
39,
1,
0
],
"total": 89,
"week": 1336280400
}
]Accepted
Status: 202 AcceptedA header with no content is returned.
Status: 204 No Content注釈
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 /repos/{owner}/{repo}/stats/contributorsパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/stats/contributors await octokit.request('GET /repos/{owner}/{repo}/stats/contributors', {
owner: 'octocat',
repo: 'hello-world'
})
w - Start of the week, given as a Unix timestamp.
a - Number of additions
d - Number of deletions
c - Number of commits
w - Start of the week, given as a Unix timestamp.a - Number of additionsd - Number of deletionsc - Number of commits Status: 200 OK [
{
"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
}
]
}
]Accepted
Status: 202 AcceptedA header with no content is returned.
Status: 204 No Content注釈
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.
get /repos/{owner}/{repo}/stats/participationパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/stats/participation await octokit.request('GET /repos/{owner}/{repo}/stats/participation', {
owner: 'octocat',
repo: 'hello-world'
})The array order is oldest week (index 0) to most recent week.
Status: 200 OK {
"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
]
}Resource not found
Status: 404 Not Found注釈
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 /repos/{owner}/{repo}/stats/punch_cardパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/stats/punch_card await octokit.request('GET /repos/{owner}/{repo}/stats/punch_card', {
owner: 'octocat',
repo: 'hello-world'
})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 OK [
[
0,
0,
5
],
[
0,
1,
43
],
[
0,
2,
21
]
]A header with no content is returned.
Status: 204 No Content注釈
トラフィック
プッシュアクセスを持つリポジトリに対し、トラフィック API はリポジトリグラフが提供する情報へのアクセスを提供します。 詳細は「リポジトリへのトラフィックを表示する」を参照してください。
Get repository clones
Get the total number of clones and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.
get /repos/{owner}/{repo}/traffic/clonesパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
per | string | query | Must be one of: デフォルト: |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/traffic/clones await octokit.request('GET /repos/{owner}/{repo}/traffic/clones', {
owner: 'octocat',
repo: 'hello-world'
})Response
Status: 200 OK {
"count": 173,
"uniques": 128,
"clones": [
{
"timestamp": "2016-10-10T00:00:00Z",
"count": 2,
"uniques": 1
},
{
"timestamp": "2016-10-11T00:00:00Z",
"count": 17,
"uniques": 16
},
{
"timestamp": "2016-10-12T00:00:00Z",
"count": 21,
"uniques": 15
},
{
"timestamp": "2016-10-13T00:00:00Z",
"count": 8,
"uniques": 7
},
{
"timestamp": "2016-10-14T00:00:00Z",
"count": 5,
"uniques": 5
},
{
"timestamp": "2016-10-15T00:00:00Z",
"count": 2,
"uniques": 2
},
{
"timestamp": "2016-10-16T00:00:00Z",
"count": 8,
"uniques": 7
},
{
"timestamp": "2016-10-17T00:00:00Z",
"count": 26,
"uniques": 15
},
{
"timestamp": "2016-10-18T00:00:00Z",
"count": 19,
"uniques": 17
},
{
"timestamp": "2016-10-19T00:00:00Z",
"count": 19,
"uniques": 14
},
{
"timestamp": "2016-10-20T00:00:00Z",
"count": 19,
"uniques": 15
},
{
"timestamp": "2016-10-21T00:00:00Z",
"count": 9,
"uniques": 7
},
{
"timestamp": "2016-10-22T00:00:00Z",
"count": 5,
"uniques": 5
},
{
"timestamp": "2016-10-23T00:00:00Z",
"count": 6,
"uniques": 5
},
{
"timestamp": "2016-10-24T00:00:00Z",
"count": 7,
"uniques": 5
}
]
}Forbidden
Status: 403 Forbidden注釈
Get top referral paths
Get the top 10 popular contents over the last 14 days.
get /repos/{owner}/{repo}/traffic/popular/pathsパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/traffic/popular/paths await octokit.request('GET /repos/{owner}/{repo}/traffic/popular/paths', {
owner: 'octocat',
repo: 'hello-world'
})Response
Status: 200 OK [
{
"path": "/github/hubot",
"title": "github/hubot: A customizable life embetterment robot.",
"count": 3542,
"uniques": 2225
},
{
"path": "/github/hubot/blob/master/docs/scripting.md",
"title": "hubot/scripting.md at master · github/hubot · GitHub",
"count": 1707,
"uniques": 804
},
{
"path": "/github/hubot/tree/master/docs",
"title": "hubot/docs at master · github/hubot · GitHub",
"count": 685,
"uniques": 435
},
{
"path": "/github/hubot/tree/master/src",
"title": "hubot/src at master · github/hubot · GitHub",
"count": 577,
"uniques": 347
},
{
"path": "/github/hubot/blob/master/docs/index.md",
"title": "hubot/index.md at master · github/hubot · GitHub",
"count": 379,
"uniques": 259
},
{
"path": "/github/hubot/blob/master/docs/adapters.md",
"title": "hubot/adapters.md at master · github/hubot · GitHub",
"count": 354,
"uniques": 201
},
{
"path": "/github/hubot/tree/master/examples",
"title": "hubot/examples at master · github/hubot · GitHub",
"count": 340,
"uniques": 260
},
{
"path": "/github/hubot/blob/master/docs/deploying/heroku.md",
"title": "hubot/heroku.md at master · github/hubot · GitHub",
"count": 324,
"uniques": 217
},
{
"path": "/github/hubot/blob/master/src/robot.coffee",
"title": "hubot/robot.coffee at master · github/hubot · GitHub",
"count": 293,
"uniques": 191
},
{
"path": "/github/hubot/blob/master/LICENSE.md",
"title": "hubot/LICENSE.md at master · github/hubot · GitHub",
"count": 281,
"uniques": 222
}
]Forbidden
Status: 403 Forbidden注釈
Get top referral sources
Get the top 10 referrers over the last 14 days.
get /repos/{owner}/{repo}/traffic/popular/referrersパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/traffic/popular/referrers await octokit.request('GET /repos/{owner}/{repo}/traffic/popular/referrers', {
owner: 'octocat',
repo: 'hello-world'
})Response
Status: 200 OK [
{
"referrer": "Google",
"count": 4,
"uniques": 3
},
{
"referrer": "stackoverflow.com",
"count": 2,
"uniques": 2
},
{
"referrer": "eggsonbread.com",
"count": 1,
"uniques": 1
},
{
"referrer": "yandex.ru",
"count": 1,
"uniques": 1
}
]Forbidden
Status: 403 Forbidden注釈
Get page views
Get the total number of views and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.
get /repos/{owner}/{repo}/traffic/viewsパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
per | string | query | Must be one of: デフォルト: |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/traffic/views await octokit.request('GET /repos/{owner}/{repo}/traffic/views', {
owner: 'octocat',
repo: 'hello-world'
})Response
Status: 200 OK {
"count": 14850,
"uniques": 3782,
"views": [
{
"timestamp": "2016-10-10T00:00:00Z",
"count": 440,
"uniques": 143
},
{
"timestamp": "2016-10-11T00:00:00Z",
"count": 1308,
"uniques": 414
},
{
"timestamp": "2016-10-12T00:00:00Z",
"count": 1486,
"uniques": 452
},
{
"timestamp": "2016-10-13T00:00:00Z",
"count": 1170,
"uniques": 401
},
{
"timestamp": "2016-10-14T00:00:00Z",
"count": 868,
"uniques": 266
},
{
"timestamp": "2016-10-15T00:00:00Z",
"count": 495,
"uniques": 157
},
{
"timestamp": "2016-10-16T00:00:00Z",
"count": 524,
"uniques": 175
},
{
"timestamp": "2016-10-17T00:00:00Z",
"count": 1263,
"uniques": 412
},
{
"timestamp": "2016-10-18T00:00:00Z",
"count": 1402,
"uniques": 417
},
{
"timestamp": "2016-10-19T00:00:00Z",
"count": 1394,
"uniques": 424
},
{
"timestamp": "2016-10-20T00:00:00Z",
"count": 1492,
"uniques": 448
},
{
"timestamp": "2016-10-21T00:00:00Z",
"count": 1153,
"uniques": 332
},
{
"timestamp": "2016-10-22T00:00:00Z",
"count": 566,
"uniques": 168
},
{
"timestamp": "2016-10-23T00:00:00Z",
"count": 675,
"uniques": 184
},
{
"timestamp": "2016-10-24T00:00:00Z",
"count": 614,
"uniques": 237
}
]
}Forbidden
Status: 403 Forbidden