L&D series: Get to know GitHub API v3
Learning and Development chapter 4.
Who doesn’t know about GitHub these days? I think GitHub is the most popular platform to save and integrate our code, isn’t it?
How many of you know that GitHub also has an API for a developer guide? Check it out here (https://developer.github.com/v3/). The new version already has v4 of it (https://developer.github.com/v4/), but since I don’t understand v4 yet so I’m just gonna discuss v3 in this article.
Authentication Token
Before we start to hit the endpoint, I’ll show you how to get the token because some endpoint URL requires authentication.
Issues Assignees
https://developer.github.com/v3/issues/assignees/
List assignees
GET /repos/:owner/:repo/assignees
. With this endpoint, we’ll know anyone who becomes an assignee in our repository.
Check if a user can be assigned
GET /repos/:owner/:repo/assignees/:assignee
. We can check if the users above can become our assignees in the repository. If yes, then the expected response will 204.
Add assignees to an issue
POST /repos/:owner/:repo/issues/:issue_number/assignees
. We can add an assignee up to 10 people. This endpoint needs the auth token.
Remove assignees from an issue
DELETE /repos/:owner/:repo/issues/:issue_number/assignees
. After adding an assignee, we can also delete the assignee we want to remove. This endpoint needs the auth token.
Issue Comments
https://developer.github.com/v3/issues/comments/
List issue comments
GET /repos/:owner/:repo/issues/:issue_number/comments
.
List issue comments for a repository
GET /repos/:owner/:repo/issues/comments
.
Create an issue comment
POST /repos/:owner/:repo/issues/:issue_number/comments
.
Update an issue comment
PATCH /repos/:owner/:repo/issues/comments/:comment_id
.
Delete an issue comment
DELETE /repos/:owner/:repo/issues/comments/:comment_id
.
Issue Labels
https://developer.github.com/v3/issues/labels/
List labels for a repository
GET /repos/:owner/:repo/labels
.
Create a label
POST /repos/:owner/:repo/labels
.
Add labels to an issue
POST /repos/:owner/:repo/issues/:issue_number/labels
.
Pull Requests Reviews
https://developer.github.com/v3/pulls/reviews/
List reviews for a pull request
GET /repos/:owner/:repo/pulls/:pull_number/reviews
.
Create a review for a pull request
POST /repos/:owner/:repo/pulls/:pull_number/reviews
.
Pull Request Review Requests
https://developer.github.com/v3/pulls/review_requests/
List requested reviewers for a pull request
GET /repos/:owner/:repo/pulls/:pull_number/requested_reviewers
.
Request reviewers for a pull request
POST /repos/:owner/:repo/pulls/:pull_number/requested_reviewers
.
Remove requested reviewers from a pull request
DELETE /repos/:owner/:repo/pulls/:pull_number/requested_reviewers
.
Do you know that the API above can be used for https://danger.systems/reference.html with the help of https://octokit.github.io/octokit.rb/Octokit/Client.html? It will help us to manage our GitHub repository simple and better. Worth to try. — MperMperPisang
References :