Github API 按最新关注者排序
Github API sort by latest followers
我正在尝试从 Github API 获取一些数据。
我的项目快完成了,但我还需要最后 5 个用户关注我。
我怎样才能得到这个?在官方文档上也找不到任何解决方案 google.
非常感谢
如果你使用Github GraphQL API v4,你可以在viewer
中使用followers(last: 5)
,如果你想获得认证用户的最后5个关注者:
{
viewer {
followers(last: 5) {
nodes {
login
}
}
}
}
或针对特定用户:
{
user(login: "bertrandmartel") {
followers(last: 5) {
nodes {
login
}
}
}
}
您也可以将 API v3 与 /users/:user/followers 一起使用,但您需要执行 2 或 3 个请求:
- 致电https://api.github.com/users/:user/followers and extract
Link
header to get the last page, check Travesing pagination
- 调用 https://api.github.com/users/:user/followers?page=X 其中 X 是最后一页
- 如果没有足够的关注者(<最后一页上的 5 项),您将需要请求上一个(最后一页 - 1)
我正在尝试从 Github API 获取一些数据。
我的项目快完成了,但我还需要最后 5 个用户关注我。
我怎样才能得到这个?在官方文档上也找不到任何解决方案 google.
非常感谢
如果你使用Github GraphQL API v4,你可以在viewer
中使用followers(last: 5)
,如果你想获得认证用户的最后5个关注者:
{
viewer {
followers(last: 5) {
nodes {
login
}
}
}
}
或针对特定用户:
{
user(login: "bertrandmartel") {
followers(last: 5) {
nodes {
login
}
}
}
}
您也可以将 API v3 与 /users/:user/followers 一起使用,但您需要执行 2 或 3 个请求:
- 致电https://api.github.com/users/:user/followers and extract
Link
header to get the last page, check Travesing pagination - 调用 https://api.github.com/users/:user/followers?page=X 其中 X 是最后一页
- 如果没有足够的关注者(<最后一页上的 5 项),您将需要请求上一个(最后一页 - 1)