Github API由最新关注者排序

时间:2018-03-25 13:13:38

标签: ruby github-api

我正在尝试从Github API获取一些数据。

我几乎完成了项目,但我还需要最后5名用户关注我。

我怎么能得到这个?在官方文档上也找不到谷歌的任何解决方案。

非常感谢

1 个答案:

答案 0 :(得分:0)

If you use Github GraphQL API v4, you can use followers(last: 5) in viewer if you want to get the last 5 followers of the authenticated user :

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

Try it in the explorer

Or for a specific user :

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

Try it in the explorer

You can also use API v3 with /users/:user/followers but you would need to perform 2 or 3 requests :