18

Hi I am trying to get the number of issues of a repo using angular and Github Rest API, But the problem is that I get only 30 issues even though more issues are there in that repo. Please help me with the idea. I use the below REST Api to get the issues.

https://api.github.com/repos/vmg/redcarpet/issues?state=all
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257

1 Answers1

15

Updated response

If you just want the number of issues I think the closest you'll get is with the get repo endpoint:

GET /repos/:owner/:repo

The JSON response from this endpoint includes two relevant keys:

  • has_issues, which will be true or false, and
  • open_issues_count, which should give you the number of open issues.

I'm not sure of any way to get the number of issues including ones that aren't open.

Original response

You'll need to paginate:

Requests that return multiple items will be paginated to 30 items by default. You can specify further pages with the ?page parameter. For some resources, you can also set a custom page size up to 100 with the ?per_page parameter. Note that for technical reasons not all endpoints respect the ?per_page parameter, see events for example.

$ curl 'https://api.github.com/user/repos?page=2&per_page=100'
Community
  • 1
  • 1
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 3
    Also note that GitHub search API limits you to [1000 total results per search](https://developer.github.com/v3/search/#search-issues). Actually it gives you the final page of results so you'll get 1020 results if there are 30 results per page. You can only get around this by issuing multiple search queries. – yoyo Jun 25 '18 at 21:20
  • 9
    I'd like to add for anyone who comes across this that `open_issues_count` will give you the count of **Issues + PRs** since GitHub counts PRs as issues. – Rohan Lekhwani Mar 08 '21 at 18:52