使用 GitHub GraphQL Api 获得按星级排名的前 10 javascript/opensource 个存储库

get the top 10 javascript/opensource repositories ranked by star using GitHub GraphQL Api

我想使用 GitHub GraphQL Api 获得按星级 排名的 前 10 javascript/opensource 个存储库(以及一些相关信息)在 python 项目中。到目前为止我有这个查询:

query{
  search(type: REPOSITORY, query: "language:javascript", first:10) {
    userCount
    edges {
      node {
        ... on Repository {
          name
          url
          stargazers {
            totalCount
          }
          owner{
            login
          }
        }
      }
    }
  }
}

问题是它并不总是 return 相同的结果:它将 return 10 个随机存储库 在每次查询时按 starcount 排序,而不是绝对前 10。

除此之外,我还想得到那些开源的。

我使用查询

query{
licenses{name}
}

获取许可证列表,但我不知道这是否是一个详尽的列表(似乎缺少 MIT 等一些许可证)。根据文档,它是

Return a list of known open source licenses.

如何获取详尽的许可证列表并将其添加到我上面的主要查询中以使我的研究更加精确?

我似乎找不到明确的答案,因为关于 GitHub 的 GraphQl api 的文档很少而且很模糊。

谢谢

关于结果不一致的原因,GitHub支持得到了部分解释:是查询运行时间过长导致超时。

Some queries are computationally expensive for our search infrastructure to execute. To keep search fast for everyone, we limit how long any individual query can run. In rare situations when a query exceeds the time limit, search returns all matches that were found prior to the timeout and informs you that a timeout occurred.

Reaching a timeout does not necessarily mean that search results are incomplete. It just means that the query was discontinued before it searched through all possible data.

Our team wrote about this here:

https://help.github.com/articles/troubleshooting-search-queries/#potential-timeouts

Given this reality, these timeouts may cause inconsistencies while paging through the results. We see how this could be improved in future iterations of search, so we've let our team know so they're aware though we can't make any promises on specific changes.

编辑:由支持人员提供,添加 query: "language:javascript stars:>1600"(1600 或多或少是前 3000 个代表的最小星数,但需要足够大以缩小搜索范围)将始终提供前 10 个按星级排序的回购。