GitHub API 通过带时间戳的用户 ID 查找所有提交
GitHub API find all commits by user ID with timestamp
是否有一种有效的方法来查找特定用户在所有 public 个存储库中的所有最近提交?
我目前正在使用 /events/public
并过滤掉那些 event.type === "PushEvent"
。然而,这不是很有效,因为
PushEvent
中的提交没有 timestamp,这意味着我需要额外的请求来通过 commits[][url]
. 获取它们的时间戳
- 限制为 60 requests/hour,很快就会用完,因为我需要获取每次提交的时间戳。
有更好的方法吗?
不,不幸的是,没有更好的方法来为用户检索提交。
但是,速率限制有一个解决方法:
For requests using Basic Authentication or OAuth, you can make up to 5,000 requests per hour. For unauthenticated requests, the rate limit allows you to make up to 60 requests per hour.
您可以生成一个 access token and use it as an OAuth token。
如何使用token
如果您要使用 Basic Authentication
你需要添加新的 header
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
其中 Basic
之后的字符串是
的 Base64 encoded 字符串
your_user_name:your_token
如果您正在使用 curl
curl -u username:token https://api.github.com/user
或
curl https://username:token@api.github.com/
是否有一种有效的方法来查找特定用户在所有 public 个存储库中的所有最近提交?
我目前正在使用 /events/public
并过滤掉那些 event.type === "PushEvent"
。然而,这不是很有效,因为
PushEvent
中的提交没有 timestamp,这意味着我需要额外的请求来通过commits[][url]
. 获取它们的时间戳
- 限制为 60 requests/hour,很快就会用完,因为我需要获取每次提交的时间戳。
有更好的方法吗?
不,不幸的是,没有更好的方法来为用户检索提交。 但是,速率限制有一个解决方法:
For requests using Basic Authentication or OAuth, you can make up to 5,000 requests per hour. For unauthenticated requests, the rate limit allows you to make up to 60 requests per hour.
您可以生成一个 access token and use it as an OAuth token。
如何使用token
如果您要使用 Basic Authentication 你需要添加新的 header
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
其中 Basic
之后的字符串是
your_user_name:your_token
如果您正在使用 curl
curl -u username:token https://api.github.com/user
或
curl https://username:token@api.github.com/