I'm trying to come to grips with the GitHub API. I've gotten a detailed list of issues from the API, by doing this:
function myFunction() { var url = 'https://api.github.com/repos/repo/subrepo/issues';
var response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true});
Logger.log(response);
}
but that just goes the console log - and does not seem to enable me to see how many issues there are. Is there a GitHub API method of getting the "total amount of open issues" or "closed issues"?
I'm ideally hoping to get data into a Google Sheet and feed it into Geckoboard, but first I gotta know I can actually get the required data into the log, then I can I guess start working on how to get it onto a sheet.
PS one specific detail: the repo is private - and the search-issues does not seem capable of accessing a ?access_token=mytoken
You can use the search feature of the GitHub API to get the issues you want. For example to find the issues from your "repo/subrepo" that are open you can use -
https://api.github.com/search/issues?q=repo:repo/subrepo+state:open
.NOTE If your repo is private, you will need to create an access_token and supply it in your query, like this:
https://api.github.com/search/issues?q=repo:repo/subrepo+state:open&access_token=yourToken
.In regular queries, ?access_token=yourToken will work, but in a search such as this the syntax must be &access_token=yourToken
In the JSON response the field 'total_count' gives you the number of issues found in the search. Refer: https://help.github.com/articles/searching-issues/