Reputation: 269
through the GitHub API, is it possible to get the number of open pull requests for a repository without downloading all the extra data related to the pull requests themselves?
For example, when you get the list of your repositories, for each of the repo you can see the number of open issues. Is there a similar property for open pull requests?
Upvotes: 22
Views: 13548
Reputation: 2453
I used the Pulls Request API in combination with jq ability to count objects (see How to count items in JSON object using command line?)
With cURL:
curl https://api.github.com/repos/OWNER/REPO/pulls | jq length
With Github CLI
gh api \
-H "Accept: application/vnd.github+json" \
/repos/OWNER/REPO/pulls | jq length
Note:
The results are paginated. If you need more than 30 use the per_page
query-parameter to increase the limit to 100. If you need more than 100 you need to implement paging, eg use the page query-parameter.
Upvotes: 1
Reputation: 10305
You might also take a look at the search api https://developer.github.com/v3/search/#search-issues. Looks like you can filter on type and probably also on closed or not :)
As suggested by codea in the comments:
https://api.github.com/search/issues?q=+type:pr+user:StackExchange&sort=created&order=asc
Upvotes: 8