Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 3

GraphQL API - Search results end after 10 pages

I'm trying to get Python repos with over 1000 stars using this query:

query OpenGraph($after: String) {
  search(type:REPOSITORY, query:"language:Python stars:>1000 sort:stars-desc", first:100, after:$after) {
    pageInfo {
      endCursor,
      hasNextPage
    }
    ... on SearchResultItemConnection {
      nodes {
        ... on Repository {
          url,
          usesCustomOpenGraphImage
        }
      }
    }
  }
}

And it seems that the API doesn't allow to go after 10th page (I'm using endCursor from last query as after parameter to search query), even though there's like 2k Python repos (which should mean at least another 10 pages)

Is this a limitation of GraphQL API or do I need to do this differently?

2 Replies
Highlighted
Community Manager
Message 2 of 3

Re: GraphQL API - Search results end after 10 pages

Hi @jack1142,

 

Thanks for being here! The behavior you observed is expected -- it's not possible to fetch more than 1000 results for a specific search query. This is true for the web UI, REST API and GraphQL API. There's no way around this restriction.

 

However, there might be a different approach you might use. You could slice your query, e.g. based on the date the repository was created (for example, repositories created in first week of 2017, then second week, and so on). You'd then run multiple searches to collect the results for each slice (and the number of results would be less than 1000 since you're limiting the query to a small period), then combine results for all slices, and finally sort the whole list as you like.

 

See:

https://help.github.com/articles/searching-repositories/#search-by-when-a-repository-was-created-or-...

https://help.github.com/articles/understanding-the-search-syntax/#query-for-dates

 

Hope this helps.


My very best,
Andrea

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Highlighted
Ground Controller Lvl 1
Message 3 of 3

Re: GraphQL API - Search results end after 10 pages

Hello,

 

Is it normal that the following sort options for a search query don't work?

  • sort:author-date
  • sort:author-date-asc
  • sort:author-date-desc
  • sort:created
  • sort:created-asc
  • sort:created-desc
  • sort:created-at-asc
  • sort:created-ar-desc

Basically what I'm trying to do it sort the search results of my query by the repository's creation date. According to this Sorting search results  , the first 3 should work...

 

Thanks,

Riad