API 调用以获取作者的提交次数 GitHub API
API Call(s) To get Number Of Commits by Author GitHub API
我正在尝试创建一个 WordPress 小部件来显示用户的存储库信息和提交次数(限于最近 30 天)。我很容易获得存储库信息,但在第二部分中苦苦挣扎。我在这种情况下使用 PHP,并在 WordPress 小部件中显示信息。
基本上我需要 API 到 return 一个用户在给定月份在所有 (public) 个存储库中进行的提交次数。是否有任何简单的端点可以访问它,或者我是否必须遍历上个月活跃的每个用户存储库并从那里提取提交数量?
另一种方法是list events for a given user
GET /users/:username/events
示例:https://api.github.com/users/VonC/events
{
"id": "3406063602",
"type": "PushEvent",
"actor": {
"id": 79478,
"login": "VonC",
"gravatar_id": "",
"url": "https://api.github.com/users/VonC",
"avatar_url": "https://avatars.githubusercontent.com/u/79478?"
},
"repo": {
"id": 47265668,
"name": "VonC/hello-world-go",
"url": "https://api.github.com/repos/VonC/hello-world-go"
},
"payload": {
"push_id": 889397803,
"size": 2,
"distinct_size": 2,
"ref": "refs/heads/master",
"head": "54dd9bd15fea2476bd76c7bf88bcec370d9dfc61",
"before": "64d3b59911fef0b0c2423c105c38aabf99332e28",
"commits": [
{
"sha": "ee856fa87073cf92e11baa4d36f61394de937085",
...
您必须针对 PushEvent
和 iterate over the pages of events 进行筛选,直到获得早于一个月前的事件。
我正在尝试创建一个 WordPress 小部件来显示用户的存储库信息和提交次数(限于最近 30 天)。我很容易获得存储库信息,但在第二部分中苦苦挣扎。我在这种情况下使用 PHP,并在 WordPress 小部件中显示信息。
基本上我需要 API 到 return 一个用户在给定月份在所有 (public) 个存储库中进行的提交次数。是否有任何简单的端点可以访问它,或者我是否必须遍历上个月活跃的每个用户存储库并从那里提取提交数量?
另一种方法是list events for a given user
GET /users/:username/events
示例:https://api.github.com/users/VonC/events
{
"id": "3406063602",
"type": "PushEvent",
"actor": {
"id": 79478,
"login": "VonC",
"gravatar_id": "",
"url": "https://api.github.com/users/VonC",
"avatar_url": "https://avatars.githubusercontent.com/u/79478?"
},
"repo": {
"id": 47265668,
"name": "VonC/hello-world-go",
"url": "https://api.github.com/repos/VonC/hello-world-go"
},
"payload": {
"push_id": 889397803,
"size": 2,
"distinct_size": 2,
"ref": "refs/heads/master",
"head": "54dd9bd15fea2476bd76c7bf88bcec370d9dfc61",
"before": "64d3b59911fef0b0c2423c105c38aabf99332e28",
"commits": [
{
"sha": "ee856fa87073cf92e11baa4d36f61394de937085",
...
您必须针对 PushEvent
和 iterate over the pages of events 进行筛选,直到获得早于一个月前的事件。