githubpaginationgithub-apihttp-getgithub-organizations

Github v3 API get all organizations more than 100


I am trying to get all organization items through http://host/api/v3/organizations?page=2&per_page=100

The default size seems like 30, and 100 seems like the max limit per request. But above link still only returns the first 100 items, i.e, not 101-200th

I also tried http:host//api/v3/organizations?page=2 No matter which page I set, it only returns the first 30 items.

How can I get the entire list of organization items please? Please help. Appreciate.


Solution

  • From Github API reference for listing organizations :

    Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of organizations.

    For instance checking the 2nd page using :

    curl -I "https://api.github.com/organizations"
    

    gives the following link header :

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

    So the next page will be https://api.github.com/organizations?since=3043

    For each request you would check this header to get the next url to hit