我尝试在 GitHub 中获取我的组织中的所有用户。我可以获得用户,但我在分页方面遇到问题 - 我不知道需要浏览多少页。
curl -i -s -u "user:pass" 'https://api.github.com/orgs/:org/members?page=1&per_page=100'
Run Code Online (Sandbox Code Playgroud)
当然,我可以迭代所有页面,直到我的请求不会返回“0”,但我认为这不是一个好主意)
也许 GitHub 有标准方法来获取组织中的所有用户?
根据Traversing with Pagination,应该有一个Link 响应头,例如:
Link: <https://api.github.com/orgs/:org/members?page=2>; rel="next", <https://api.github.com/orgs/:org/members?page=3>; rel="last"
Run Code Online (Sandbox Code Playgroud)
这些标题应该为您提供所需的所有信息,以便您可以继续获取页面。
出于性能原因,我认为不存在任何可以绕过分页的 API。
| 归档时间: |
|
| 查看次数: |
11336 次 |
| 最近记录: |