Getting all GitHub users through github-api

前端 未结 4 1288
有刺的猬
有刺的猬 2021-02-07 20:24

The GitHub API documentation says that the url

https://api.github.com/users

will give all users in the order they signed up, but I only seem to get the first 135

相关标签:
4条回答
  • 2021-02-07 20:47

    Please use since parameter in your GET request.

    https://api.github.com/users?since=XXX
    

    Probably it's done this way to limit the resources needed to handle such request. Without such limit it's just asking for DoS attack.

    0 讨论(0)
  • 2021-02-07 20:49

    Both of the existing answers are 100% correct, but I would advise you to use a wrapper for whatever language you happen to be doing this in. There are plenty of them and there is an official one for ruby (Octokit). Here is a list of all of them.

    0 讨论(0)
  • 2021-02-07 21:04

    If you check the response headers for that request Github provides pagination links under the header Links

    Link: <https://api.github.com/users?since=135>; rel="next", <https://api.github.com/users{?since}>; rel="first"
    

    I believe since their api v3 Github has been moving towards a hypermedia api.

    Github Hypermedia API

    EDIT

    This is beyond the scope of this question but its related. To learn more about hypermedia API and REST. Take a look at these slides by Steve Klabnik

    http://steveklabnik.github.com/hypermedia-presentation/#1

    0 讨论(0)
  • 2021-02-07 21:06

    You can filter on type:user like this:

    https://api.github.com/search/users?q=type:user
    

    See Also: GitHub API get total number of users/organizations

    0 讨论(0)
提交回复
热议问题