{"id":14069066,"url":"https://github.com/r-lib/gh","last_synced_at":"2025-05-14T12:10:59.781Z","repository":{"id":33397913,"uuid":"37042992","full_name":"r-lib/gh","owner":"r-lib","description":"Minimalistic GitHub API client in R","archived":false,"fork":false,"pushed_at":"2025-04-29T13:00:50.000Z","size":9117,"stargazers_count":224,"open_issues_count":11,"forks_count":54,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-29T13:45:30.136Z","etag":null,"topics":["github","github-api","r"],"latest_commit_sha":null,"homepage":"https://gh.r-lib.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-lib.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-08T03:00:11.000Z","updated_at":"2025-04-29T12:57:53.000Z","dependencies_parsed_at":"2023-01-15T00:45:13.108Z","dependency_job_id":"a597fcb9-32cd-4ef6-9b29-965309b34138","html_url":"https://github.com/r-lib/gh","commit_stats":{"total_commits":314,"total_committers":23,"mean_commits":"13.652173913043478","dds":"0.49363057324840764","last_synced_commit":"9fb8ae3dacd998a88db6f3c96e49ee04b1cffa34"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fgh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fgh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fgh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fgh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-lib","download_url":"https://codeload.github.com/r-lib/gh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254050677,"owners_count":22006336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-api","r"],"created_at":"2024-08-13T07:06:35.068Z","updated_at":"2025-05-14T12:10:59.772Z","avatar_url":"https://github.com/r-lib.png","language":"R","readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r}\n#| label: setup\n#| include: false\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# gh\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/r-lib/gh/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/gh/actions)\n[![](https://www.r-pkg.org/badges/version/gh)](https://www.r-pkg.org/pkg/gh)\n[![CRAN Posit mirror downloads](https://cranlogs.r-pkg.org/badges/gh)](https://www.r-pkg.org/pkg/gh)\n[![R-CMD-check](https://github.com/r-lib/gh/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/gh/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/r-lib/gh/graph/badge.svg)](https://app.codecov.io/gh/r-lib/gh)\n\u003c!-- badges: end --\u003e\n\nMinimalistic client to access GitHub's\n[REST](https://docs.github.com/rest) and [GraphQL](https://docs.github.com/graphql) APIs.\n\n## Installation and setup\n\nInstall the package from CRAN as usual:\n\n```{r}\n#| eval: false\ninstall.packages(\"gh\")\n```\n\nInstall the development version from GitHub:\n\n```{r}\n#| eval: false\npak::pak(\"r-lib/gh\")\n```\n\n### Authentication\n\nThe value returned by `gh::gh_token()` is used as Personal Access Token\n(PAT). A token is needed for some requests, and to help with rate limiting.\ngh can use your regular git credentials in the git credential store, via\nthe gitcreds package. Use `gitcreds::gitcreds_set()` to put a PAT into the\ngit credential store. If you cannot use the credential store, set the\n`GITHUB_PAT` environment variable to your PAT. See the details in the\n`?gh::gh_token` manual page and the manual of the gitcreds package.\n\n### API URL\n\n* The `GITHUB_API_URL` environment variable, if set, is used for the default github api url.\n\n## Usage\n\n```{r}\nlibrary(gh)\n```\n\nUse the `gh()` function to access all API endpoints. The endpoints are\nlisted in the [documentation](https://docs.github.com/rest).\n\nThe first argument of `gh()` is the endpoint. You can just copy and paste the\nAPI endpoints from the documentation. Note that the leading slash\nmust be included as well.\n\nFrom \u003chttps://docs.github.com/rest/reference/repos#list-repositories-for-a-user\u003e you can copy and paste `GET /users/{username}/repos` into your `gh()`\ncall. E.g.\n\n```{r}\nmy_repos \u003c- gh(\"GET /users/{username}/repos\", username = \"gaborcsardi\")\nvapply(my_repos, \"[[\", \"\", \"name\")\n```\n\nThe JSON result sent by the API is converted to an R object.\n\nParameters can be passed as extra arguments. E.g.\n\n```{r}\nmy_repos \u003c- gh(\n  \"/users/{username}/repos\",\n  username = \"gaborcsardi\",\n  sort = \"created\")\nvapply(my_repos, \"[[\", \"\", \"name\")\n```\n\n### POST, PATCH, PUT and DELETE requests\n\nPOST, PATCH, PUT, and DELETE requests can be sent by including the\nHTTP verb before the endpoint, in the first argument. E.g. to\ncreate a repository:\n\n```{r}\n#| eval: false\nnew_repo \u003c- gh(\"POST /user/repos\", name = \"my-new-repo-for-gh-testing\")\n```\n\nand then delete it:\n\n```{r}\n#| eval: false\ngh(\"DELETE /repos/{owner}/{repo}\", owner = \"gaborcsardi\",\n   repo = \"my-new-repo-for-gh-testing\")\n```\n\n### Tokens\n\nBy default the `GITHUB_PAT` environment variable is used. Alternatively,\none can set the `.token` argument of `gh()`.\n\n### Pagination\n\nSupply the `page` parameter to get subsequent pages:\n\n```{r}\nmy_repos2 \u003c- gh(\"GET /orgs/{org}/repos\", org = \"r-lib\", page = 2)\nvapply(my_repos2, \"[[\", \"\", \"name\")\n```\n\n## Environment Variables\n\n* The `GITHUB_API_URL` environment variable is used for the default github\n  api url.\n* The `GITHUB_PAT` and `GITHUB_TOKEN` environment variables are used, if\n  set, in this order, as default token. Consider using the git credential\n  store instead, see `?gh::gh_token`.\n\n## Code of Conduct\n\nPlease note that the gh project is released with a\n[Contributor Code of Conduct](https://gh.r-lib.org/CODE_OF_CONDUCT.html).\nBy contributing to this project, you agree to abide by its terms.\n\n## License\n\nMIT © Gábor Csárdi, Jennifer Bryan, Hadley Wickham\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fgh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-lib%2Fgh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fgh/lists"}