【问题标题】:github users API Paging not workgithub用户API分页不起作用
【发布时间】:2016-09-04 14:35:45
【问题描述】:

当使用github users api返回用户数据时 https://api.github.com/users?page=6&per_page=2

虽然改变了页面参数值和per_page,但每次返回相同的数据 为什么会这样以及如何解决以更改不同的数据

我尝试编辑标头请求并添加此标头

Name Link
Value <https://api.github.com/users?page=1&per_page=2>; rel="next",<https://api.github.com/users?page=50&per_page=2>; rel="last"

还是不行

【问题讨论】:

    标签: github


    【解决方案1】:

    经过我的搜索

    现在 Github 使用 API V3,如果您希望通过分页返回用户,您可以使用它 https://api.github.com/users?since=1&per_page=100

    该端点不使用“page”和“per_page”,而是使用“since”和“per_page”。

    since 参数表示 API 应该从哪个用户 ID 开始列出用户。例如:

    https://api.github.com/users?since=1&per_page=100

    将从 ID 为 1 的用户开始列出用户,并且

    https://api.github.com/users?since=10001&per_page=100

    将从 ID 为 10001 的用户开始列出用户。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      • 2018-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多