【问题标题】:Github API - Find number of followers for all my followersGithub API - 查找我所有关注者的关注者数量
【发布时间】:2017-05-12 14:42:07
【问题描述】:

我能够找到特定用户的关注者数量,但我想知道如何最好地找到每个关注者拥有的关注者数量。我当然可以遍历每个追随者,然后将追随者总数加起来,但这将是“昂贵的”,并开始将我推向 API 速率限制。

有没有人知道更好的方法来处理这样的事情?

【问题讨论】:

标签: github github-api


【解决方案1】:

您可以使用GraphQL API v4 来执行此操作,以下将检索前 100 个关注者及其各自的关注者数量:

{
  user(login: "bertrandmartel") {
    followers(first: 100) {
      totalCount
      edges {
        node {
          login
          followers(first: 0) {
            totalCount
          }
        }
        cursor
      }
      pageInfo {
        endCursor
        hasNextPage
      }
    }
  }
}

如果hasNextPagetrue,那么您需要使用cursor 值指定after: "END_CURSOR_VALUE" 进行分页。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-17
    • 1970-01-01
    • 1970-01-01
    • 2019-03-07
    • 1970-01-01
    相关资源
    最近更新 更多