GitHub Search API only return 30 results

The Problem: Github api response doesn't contain all the relevant data.

Solution: The api from server is limiting the amount of items the user gets and splitting it into pages (pagination). You should explicitly Specify in your request how many items you'd like to receive from server pagination engine ,using formula for Github pagination api

?page=1&per_page=<numberOfItemsYouSpecify>"

For example: I'd like to get all my collaborators info in my private repo. I'm performing curl request to Github contains: username, authentication token , Organization and repository name and api call with pagination magic.

curl -u johnDoe:abc123$%^ https://api.github.com/repos/MyOrganizationName/MyAwesomeRepo/collaborators?page=1&per_page=1000"

Explanation:

What is Pagination: Pagination is the process of splitting the contents or a section of a website into discrete pages. Users tend to get lost when there's bunch of data and with pagination splitting they can concentrate on a particular amount of content. Hierarchy and paginated structure improve the readability score of the content. Loading pages is due to the less content on each item and each page has a separate URL which is easy to refer.

In this use case Github api splits the result into 30 items per resonse, depends on the request

Github reference:

Different API calls respond with different defaults. For example, a call to List public repositories provides paginated items in sets of 30, whereas a call to the GitHub Search API provides items in sets of 100


You need to use page parameter, e.g. for next 30 page = 2

https://api.github.com/search/issues?q=stress+test+label:bug+language:python+state:closed&page=2

You can also use per_page parameter to change the default size of 30. It supports max size of 100. Like this:

https://api.github.com/search/issues?q=stress+test+label:bug+language:python+state:closed&per_page=100

More detail can be found here

Tags:

Github Api