Fedir RYKHTIK
Fedir RYKHTIK

Reputation: 9974

How to find number of closed issues for a repository?

You can find the number of open issues for a project via the Repositories > Get method in GitHub's API.

But is there any way to find the number of closed issues or the total number of issues, without iterating over all issues? Such information is available on the issues page of each project, but it doesn't seem to be present in the API.

For example, on https://github.com/nodejs/node/issues:

Issue count for Node repository

Upvotes: 4

Views: 3894

Answers (2)

jonrsharpe
jonrsharpe

Reputation: 122027

Per this issue comment, you can use the search API, rather than the issues API, to get an issue count. The relevant API docs cover the use of a state filter in the search term.

GET https://api.github.com/search/issues?q=repo:nodejs/node+type:issue+state:closed

{
    "total_count": 6595,
    "incomplete_results": false,
    "items": [...]
}

As noted in the comments, as you only care about the count of the issues you can add per_page=1 to the query parameters to minimise the data fetched, which might speed things up a bit.

Upvotes: 14

Harry Adel
Harry Adel

Reputation: 1436

Append issues to your URL and it should return all the issues, you can then calculate the number of objects and deduce which are open and which aren't.

An example call:

https://api.github.com/repos/anandkgpt03/test/issues

Upvotes: 0

Related Questions