{"id":28355229,"url":"https://github.com/inaka/erlang-github","last_synced_at":"2025-06-28T07:32:46.415Z","repository":{"id":19592767,"uuid":"22843216","full_name":"inaka/erlang-github","owner":"inaka","description":"Github API client","archived":false,"fork":false,"pushed_at":"2022-01-15T15:32:14.000Z","size":417,"stargazers_count":46,"open_issues_count":5,"forks_count":23,"subscribers_count":49,"default_branch":"master","last_synced_at":"2025-06-04T10:03:10.732Z","etag":null,"topics":["erlang","erlang-github","github","github-client","hacktoberfest"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/egithub","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inaka.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-11T15:05:15.000Z","updated_at":"2023-09-08T16:49:43.000Z","dependencies_parsed_at":"2022-07-23T13:02:15.270Z","dependency_job_id":null,"html_url":"https://github.com/inaka/erlang-github","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/inaka/erlang-github","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inaka%2Ferlang-github","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inaka%2Ferlang-github/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inaka%2Ferlang-github/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inaka%2Ferlang-github/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inaka","download_url":"https://codeload.github.com/inaka/erlang-github/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inaka%2Ferlang-github/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260927083,"owners_count":23083955,"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":["erlang","erlang-github","github","github-client","hacktoberfest"],"created_at":"2025-05-28T04:08:51.281Z","updated_at":"2025-06-28T07:32:46.408Z","avatar_url":"https://github.com/inaka.png","language":"Erlang","readme":"erlang-github\n=============\n\n![build](https://github.com/inaka/erlang-github/workflows/build/badge.svg)\n\n[Github API v3][1] client for Erlang\n\nUsage\n=====\n\n`egithub` is implemented as an Erlang application. This means that in order to use it, you\nneed to add it to your application's `.app` file or start it with:\n\n```erlang\napplication:ensure_all_started(egithub).\n```\n\nOnce it has started you can start using any of the API calls.\n\n## Credentials\n\nThe GitHub's API offers very few endpoints that don't require any credentials and a lot\nthat do. For providing credentials you have two options: basic authentication or OAuth.\nIn both cases, you can just call a function from the `egithub` module to obtain\n`Credentials`, that you can later provide to the functions that require it.\n\nSaid functions are:\n\n- [`egithub:basic_auth/2`]\n  (http://inaka.github.io/erlang-github/src/egithub.html?i=0\u0026search=egithub:basic#basic_auth/1)\n- [`egithub:oauth/1`]\n  (http://inaka.github.io/erlang-github/src/egithub.html?i=0\u0026search=oauth#oauth/1)\n\nFor example to get the information of the logged in user you can do the following:\n\n```erlang\nCred = egithub:basic_auth(\"username\", \"password\"),\n{ok, UserInfo} = egithub:user(Cred).\n```\n\n## Webhooks\n\nThis library provides the basic functionality over which you can implement your own GitHub\nwebhook service. The webhook events that are currently supported are only `ping` and\n`pull_request`. These two allow you to process the contents in a PR, write comments to\nit or add a PR review.\n\nTo accomplish this you need to implement the `egithub_webhook` behavior, which requires a\nsingle `handle_pull_request/3` callback. This function receives the GitHub's credentials\nthe PR data and the associated files.\n\nBy default, this library uses the GitHub's [PR reviews][pr_review] feature. So, once your\n`handle_pull_request/3` implementation is done processing the PR it will have to return the\ntuple `{ok, pr_review()}`, where `pr_review()` is a map with information regarding the\nReview (e.g. *commit_id*, *body*, *event*, and *comments*).\n\nIn case you want to use individual comments in your PR, you will have to set the `review_style`\nparameter within your application's config file to `individual_comments`, i.e:\n```erlang\n{egithub, [{review_style, individual_comments}]},\n```\n\nAnd then, your `handle_pull_request/3` will have to return the tuple `{ok, [message()]}`,\nwhere `message()` is a map with information regarding the comment (e.g. *commit_id*, *path*, etc).\n\n*Both, `pr_review/0` and `message/0` types are documented within the `egithub_webhook` module.*\n\nTo start the whole webhook flow once you receive the request from GitHub on your endpoint\nyou can call either `egithub_webhook:event/3` or `egithub_webhook:event/6`. The function\nwith arity 3 will just create the comments returned by your implementation. The second\nfunction will also make calls to the [Statuses\nAPI](https://developer.github.com/v3/repos/statuses/) and will report on the current\nstatus of the webhook.\n\n## GitHub's Rate Limits\n\nIf you use the GitHub API to create a lot of entities in a short interval, at a certain\npoint you will hit a limit on the rate of requests you can do. This is [sort of\ndocumented](https://developer.github.com/v3/#abuse-rate-limits) in the API's\ndocumentation, although there are no specifics on the amount of requests permitted or the\ninterval considered.\n\nTo work around this limitation, `egithub` has a built-in detection mechanism that handles\nthe case where an API call returns `403` after doing a valid requests. The request is\nqueued and retried after a certain amount of time, based on a fibonacci backoff time\nseries.\n\nBy default all API requests are done without this feature, which means you will get a\n`403` if you start doing a lot of requests one after the other. If you want to use this\nfeature you need to provide the value `queue` for the option `post_method`. All functions\nin the `egithub` module that accept an `Options` argument, accept this option.\n\nFor example, if you wanted to create a large number of comments on an issue, you could use\nthe `egithub:issue_comment/5` like this:\n\n```erlang\nCred = egithub:basic_auth(\"username\", \"password\"),\nRepo = \"username/reponame\",\nIssue = 1,\nComment = \u003c\u003c\"Hello\"\u003e\u003e,\nOptions = #{post_method =\u003e queue},\negithub:issue_comment(Cred, Repo, Issue, Comment, Options).\n```\n\nThis would create a comment with the text `Hello` for the issue `username/repo#1`.\n\nAPI Documentation\n=====\n\nThere is an automatically generated API documentation page [here][api_doc].\n\nExample\n=====\n\nFor an example on how to use this library you can check out\n[this](https://github.com/inaka/inaka.github.io/tree/dev/script) little Erlang application\nused to pull a JSON with all of Inaka's repositories in GitHub.\n\nThere is also a lot of code that calls the functions in `egithub` in the module\n[`egithub_webhook`](https://github.com/inaka/erlang-github/blob/master/src/egithub_webhook.erl).\n\nContact Us\n==========\nIf you find any **bugs** or have a **problem** while using this library, please [open an\nissue](https://github.com/inaka/erlang-github/issues/new) in this repo (or a pull request\n:)).\n\nAnd you can check all of our open-source projects at [inaka.github.io](http://inaka.github.io)\n\n[1]: https://developer.github.com/v3/\n[pr_review]: https://developer.github.com/v3/pulls/reviews/\n[api_doc]: https://hexdocs.pm/egithub/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finaka%2Ferlang-github","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finaka%2Ferlang-github","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finaka%2Ferlang-github/lists"}