ruby Github API按最新关注者排序

ctrmrzij  于 2023-06-22  发布在  Ruby
关注(0)|答案(1)|浏览(118)

我正在尝试从Github API获取一些数据。
我几乎完成了项目,但我还需要最后5个用户跟我走。
我怎么能得到这个?在官方文档上也找不到任何解决方案。
多谢了

yhxst69z

yhxst69z1#

如果你使用Github GraphQL API v4,你可以在viewer中使用followers(last: 5),如果你想获得认证用户的最后5个关注者:

{
  viewer {
    followers(last: 5) {
      nodes {
        login
      }
    }
  }
}

Try it in the explorer
或者对于特定用户:

{
  user(login: "bertrandmartel") {
    followers(last: 5) {
      nodes {
        login
      }
    }
  }
}

Try it in the explorer
您也可以使用API v3与/users/:user/followers,但您需要执行2或3个请求:

相关问题