Search code examples
javascriptgithubgithub-api

How can I retrieve popular users from GitHub?


I am trying to get a list of popular repos and users on GitHub.

Their API has an example to find users given some criteria that must be sent under the q query param, this is a required parameter but I am not sure how to send it as 'empty'

The query should list users and sort by followers, I am close but I am not sure what to send in q

`https://api.github.com/search/users?q=${WHAT_WHOULD_GO_HERE}&sort=followers&order=desc`

Just for reference, I was also trying to get popular repos and this is possible with the following query and it works just fine:

curl https://api.github.com/search/repositories\?q\=stars:\>1+language:javascript\&sort\=stars\&order\=desc\&type\=Repositories

Solution

  • After fiddling around I got the answer:

    curl https://api.github.com/search/users\?q\=followers:\>1000\&page\=1\&per_page\=10\&sort\=followers\&order\=desc
    

    The query is based on Github's own popular list which has some clues in its own URL, the query above returns the exact same result

    https://github.com/search?o=desc&q=followers%3A%3E%3D1000&ref=searchresults&s=followers&type=Users
    

    The q query param needs only this:

    • followers: >1000,

    Plus some sorting as described in the question:

    • sort: by the followers count,
    • order: descendent