r-lib / gh

Minimalistic GitHub API client in R
https://gh.r-lib.org
Other
223 stars 52 forks source link

List r files of a package on Github #118

Closed lbocken closed 4 years ago

lbocken commented 4 years ago

I would like to list r files in the directory of a package on Github.

My understanding is to generate a new githubToken with the scope read:packages and try this following code:

myRepos <- gh::gh("GET /lbocken/Rpackages/tree/master/packagename/R", username = "lbocken", .token = githubToken)

Unfortunately, I get the following error:

Error in gh_process_response(raw) : GitHub API error (404): 404 Not Found Message: Not Found Read more at https://developer.github.com/v3 URL not found:

Thank you very much for your help !

gaborcsardi commented 4 years ago

Maybe see https://community.rstudio.com/ for questions about how to use gh and the GitHub API.

read:packages is for GitHub Packages (https://github.com/features/packages), that's not what you need.

You'll need to use this end point: https://developer.github.com/v3/repos/contents/#get-repository-content

E.g.

gh::gh("/repos/:owner/:repo/contents/:path", owner = "r-lib", repo = "gh", path = "R")