All Projects → inaka → erlang-github

inaka / erlang-github

Licence: Apache-2.0 license
Github API client

Programming Languages

erlang
1774 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to erlang-github

Git Point
GitHub in your pocket 📱
Stars: ✭ 4,557 (+10256.82%)
Mutual labels:  github-client
Pphub Feedback
This repository is used to collect user feedback from PPHub (GitHub third-party client) - 此仓库用于收集PPHub(GitHub第三方客户端)的用户反馈信息
Stars: ✭ 155 (+252.27%)
Mutual labels:  github-client
yoda
GitHub extension for agile project management, using the issues subsystem.
Stars: ✭ 86 (+95.45%)
Mutual labels:  github-client
Gitmug
The GitHub app for minimalists.
Stars: ✭ 34 (-22.73%)
Mutual labels:  github-client
React Graphql Github Apollo
🚀 A React + Apollo + GraphQL GitHub Client. Your opportunity to learn about these technologies in a real world application.
Stars: ✭ 1,563 (+3452.27%)
Mutual labels:  github-client
Beefun Pro
Github client for iOS in Swift.
Stars: ✭ 172 (+290.91%)
Mutual labels:  github-client
Gitter
Gitter for GitHub - 可能是目前颜值最高的GitHub微信小程序客户端
Stars: ✭ 3,498 (+7850%)
Mutual labels:  github-client
ghostly
Ghostly is a GitHub notification client for Windows 10/11
Stars: ✭ 252 (+472.73%)
Mutual labels:  github-client
Monkey
Monkey is an unofficial GitHub client for iOS,to show the rank of coders and repositories.
Stars: ✭ 1,765 (+3911.36%)
Mutual labels:  github-client
gh
Control GitHub from your Terminal
Stars: ✭ 28 (-36.36%)
Mutual labels:  github-client
Gh4a
Github client for Android
Stars: ✭ 1,159 (+2534.09%)
Mutual labels:  github-client
Flutter Gitconnect
A Github mobile app built in flutter
Stars: ✭ 87 (+97.73%)
Mutual labels:  github-client
GitHub Android
A simple client for GitHub.
Stars: ✭ 49 (+11.36%)
Mutual labels:  github-client
Fasthub
FastHub the ultimate GitHub client for Android.
Stars: ✭ 5,543 (+12497.73%)
Mutual labels:  github-client
gito-github-client
GitHub client app helps you monitor stars and traffic of your public repositories. This was the capstone project in Udacity's Android Developer Nanodegree.
Stars: ✭ 76 (+72.73%)
Mutual labels:  github-client
Openhub
An open source GitHub Android client app, faster and concise.
Stars: ✭ 4,004 (+9000%)
Mutual labels:  github-client
Awesome Github
A curated list of awesome GitHub guides, articles, sites, tools, projects and resources. 收集这个列表,只是为了更好地使用GitHub,欢迎提交pr和issue。
Stars: ✭ 1,962 (+4359.09%)
Mutual labels:  github-client
Gitter
Gitter for GitHub - 可能是目前颜值最高的GitHub微信小程序客户端
Stars: ✭ 3,555 (+7979.55%)
Mutual labels:  github-client
Moss
A GitHub client app developed with Flutter, which supports Android iOS Web. More feature: BaiduMap+Amap UI+DiDi+Weibo!
Stars: ✭ 76 (+72.73%)
Mutual labels:  github-client
Hamster
🐀 A Bot toolkit for github that supports OAuth, Events, API, Custom Commands and Check Runs.
Stars: ✭ 40 (-9.09%)
Mutual labels:  github-client

erlang-github

build

Github API v3 client for Erlang

Usage

egithub is implemented as an Erlang application. This means that in order to use it, you need to add it to your application's .app file or start it with:

application:ensure_all_started(egithub).

Once it has started you can start using any of the API calls.

Credentials

The GitHub's API offers very few endpoints that don't require any credentials and a lot that do. For providing credentials you have two options: basic authentication or OAuth. In both cases, you can just call a function from the egithub module to obtain Credentials, that you can later provide to the functions that require it.

Said functions are:

For example to get the information of the logged in user you can do the following:

Cred = egithub:basic_auth("username", "password"),
{ok, UserInfo} = egithub:user(Cred).

Webhooks

This library provides the basic functionality over which you can implement your own GitHub webhook service. The webhook events that are currently supported are only ping and pull_request. These two allow you to process the contents in a PR, write comments to it or add a PR review.

To accomplish this you need to implement the egithub_webhook behavior, which requires a single handle_pull_request/3 callback. This function receives the GitHub's credentials the PR data and the associated files.

By default, this library uses the GitHub's PR reviews feature. So, once your handle_pull_request/3 implementation is done processing the PR it will have to return the tuple {ok, pr_review()}, where pr_review() is a map with information regarding the Review (e.g. commit_id, body, event, and comments).

In case you want to use individual comments in your PR, you will have to set the review_style parameter within your application's config file to individual_comments, i.e:

{egithub, [{review_style, individual_comments}]},

And then, your handle_pull_request/3 will have to return the tuple {ok, [message()]}, where message() is a map with information regarding the comment (e.g. commit_id, path, etc).

Both, pr_review/0 and message/0 types are documented within the egithub_webhook module.

To start the whole webhook flow once you receive the request from GitHub on your endpoint you can call either egithub_webhook:event/3 or egithub_webhook:event/6. The function with arity 3 will just create the comments returned by your implementation. The second function will also make calls to the Statuses API and will report on the current status of the webhook.

GitHub's Rate Limits

If you use the GitHub API to create a lot of entities in a short interval, at a certain point you will hit a limit on the rate of requests you can do. This is sort of documented in the API's documentation, although there are no specifics on the amount of requests permitted or the interval considered.

To work around this limitation, egithub has a built-in detection mechanism that handles the case where an API call returns 403 after doing a valid requests. The request is queued and retried after a certain amount of time, based on a fibonacci backoff time series.

By default all API requests are done without this feature, which means you will get a 403 if you start doing a lot of requests one after the other. If you want to use this feature you need to provide the value queue for the option post_method. All functions in the egithub module that accept an Options argument, accept this option.

For example, if you wanted to create a large number of comments on an issue, you could use the egithub:issue_comment/5 like this:

Cred = egithub:basic_auth("username", "password"),
Repo = "username/reponame",
Issue = 1,
Comment = <<"Hello">>,
Options = #{post_method => queue},
egithub:issue_comment(Cred, Repo, Issue, Comment, Options).

This would create a comment with the text Hello for the issue username/repo#1.

API Documentation

There is an automatically generated API documentation page here.

Example

For an example on how to use this library you can check out this little Erlang application used to pull a JSON with all of Inaka's repositories in GitHub.

There is also a lot of code that calls the functions in egithub in the module egithub_webhook.

Contact Us

If you find any bugs or have a problem while using this library, please open an issue in this repo (or a pull request :)).

And you can check all of our open-source projects at inaka.github.io

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].