2

So, I have created a query to retrieve some data from Github using its GraphQL API (tested with REST API; same problem). The query is partially shown below (showing just what matters):

query listRepos($queryString: String!, $numberOfRepos: Int!, $afterCursor: String!) {
    rateLimit {
        cost
        remaining
        resetAt
    }
    search(query: $queryString, type: REPOSITORY, first: $numberOfRepos, after: $afterCursor) {
        repositoryCount
        pageInfo {
            endCursor
            startCursor
        }
        <data related to the repository here>
    }
}

And I did a small piece of code which is running on a browser to retrieve the data. The code works without problems up to the moment where it is doing its 50th request. At this point, the response comes without data related to pagination; that is, without any cursors related to the pageInfo object (pagination).

Note, at this point I am still far far away from getting even close to the limits of requests I can do. In fact, I have 5000 points at the beginning and each of these calls have a cost of 1. So, at the moment I stop receiving pagination cursors, I still have 4950 points left.

Also, at this point I have collected data of almost 1000 repositories. The repositoryCount shows more than 450,000 results for my search query. Hence, this is not a result of reaching the end of the pages/list/data.

So, at this point I can't move further and retrieve the rest of the data. I even tried using Insomnia and Postman to retrieve the data using the last valid cursor I have, but I only get a response without any cursor.

Why is that happening?

UPDATE

The same thing happens while trying to use the REST API. Using the query API and analyzing the response headers, I see that I am given only 34 pages of results (around 1000 repositories) although the search count returns more than 400,000 results.

FTM
  • 1,887
  • 17
  • 34

1 Answers1

2

Both the REST API and GraphQL API cap the number of items returned from a search query at 1,000 results: https://developer.github.com/v3/search/#about-the-search-api.

Just like searching on Google, you sometimes want to see a few pages of search results so that you can find the item that best meets your needs. To satisfy that need, the GitHub Search API provides up to 1,000 results for each search.

bswinnerton
  • 4,533
  • 8
  • 41
  • 56