3

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

2 Answers 2

3

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/

Sign up to request clarification or add additional context in comments.

7 Comments

Poonacha, I'm now receiving this: The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them - could you use something other than : to separate stuff? is repo:repo like name_of_repo:name_of_repo or..?
The thing is that the repo is private - a public repo will work perfectly fine at least on the browser-level, but not necessarily on Google Apps Script Editor.
Oh.. then, do you want to find out a way to authenticate your URL request? i.e pass your authentication details (login and password) to UrlFetchApp.
yeah feels weird that ?access_token that works for other GETs from the api, does not function for this search thing :/
oh sorry.. i use python to access GitHub API and it has quite straight forward authentication. i.e. 'GitHubAPI_Results = requests.get(url, auth=('USERNAME', 'PASSWORD'))'. The only problem i face is that search requests have have a low rate limit (only 30 per hr), so I can not run too many searches at a time.
|
1

just for people like me landed here from Google trying to get Issues amount for public repository:

For PUBLIC repositories or when you configured access token, you can get amount of issues using formulas:

Open issues:

=IMPORTXML($F2, "//span[text()='Issues']/following-sibling::span[@class='Counter']/text()")

Closed solved issues:

=VALUE(REGEXEXTRACT(SUBSTITUTE( INDEX(IMPORTXML($F2&"/issues", "//a[contains(@href, 'is%3Aclosed')]/text()"), 2, 1)  , ",", ""), "\d+"))

where F2 consists URL like: https://github.com/pimcore/pimcore or https://github.com/sulu/sulu

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.