存储库流量的 REST API 终结点
使用 REST 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 repository clones”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌必须具有以下权限集:
- "Administration" repository permissions (read)
“Get repository clones”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
owner string 必须The account owner of the repository. The name is not case sensitive. |
repo string 必须The name of the repository without the |
名称, 类型, 说明 |
---|
per string The time frame to display results for. 默认: 可以是以下选项之一: |
“Get repository clones”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
403 | Forbidden |
“Get repository clones”的示例代码
如果你通过 GHE.com 访问 GitHub,请将 api.github.com
替换为你的企业在 api.SUBDOMAIN.ghe.com
上的专用子域。
请求示例
curl -L \
-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/traffic/clones
Response
Status: 200
{
"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
}
]
}
Get top referral paths
Get the top 10 popular contents over the last 14 days.
“Get top referral paths”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌必须具有以下权限集:
- "Administration" repository permissions (read)
“Get top referral paths”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
owner string 必须The account owner of the repository. The name is not case sensitive. |
repo string 必须The name of the repository without the |
“Get top referral paths”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
403 | Forbidden |
“Get top referral paths”的示例代码
如果你通过 GHE.com 访问 GitHub,请将 api.github.com
替换为你的企业在 api.SUBDOMAIN.ghe.com
上的专用子域。
请求示例
curl -L \
-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/traffic/popular/paths
Response
Status: 200
[
{
"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
}
]
Get top referral sources
Get the top 10 referrers over the last 14 days.
“Get top referral sources”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌必须具有以下权限集:
- "Administration" repository permissions (read)
“Get top referral sources”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
owner string 必须The account owner of the repository. The name is not case sensitive. |
repo string 必须The name of the repository without the |
“Get top referral sources”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
403 | Forbidden |
“Get top referral sources”的示例代码
如果你通过 GHE.com 访问 GitHub,请将 api.github.com
替换为你的企业在 api.SUBDOMAIN.ghe.com
上的专用子域。
请求示例
curl -L \
-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/traffic/popular/referrers
Response
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 page views”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌必须具有以下权限集:
- "Administration" repository permissions (read)
“Get page views”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
owner string 必须The account owner of the repository. The name is not case sensitive. |
repo string 必须The name of the repository without the |
名称, 类型, 说明 |
---|
per string The time frame to display results for. 默认: 可以是以下选项之一: |
“Get page views”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
403 | Forbidden |
“Get page views”的示例代码
如果你通过 GHE.com 访问 GitHub,请将 api.github.com
替换为你的企业在 api.SUBDOMAIN.ghe.com
上的专用子域。
请求示例
curl -L \
-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/traffic/views
Response
Status: 200
{
"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
}
]
}