github-apis
v1.0.8
Published
To get GitHub repository issues, comments, assignee and repository access to perform listing, creating, updating and deleting operations.
Downloads
226
Maintainers
Readme
GitHub's REST API
To get GitHub repository issues, comments, assignee and repository access
to perform listing, creating, updating and deleting operations.
Installation
$ npm install github-apis
Usage
var { listIssues, createIssue, updateIssue } = require("github-apis");
var { listRepos, createRepo, updateRepo, deleteRepo } = require("github-apis");
var { listComments, createComment, updateComment } = require("github-apis");
var { listAssignees, addAssignees, removeAssignees } = require("github-apis");
GitHub Issue Examples
// List repository issues
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
};
(async () => {
console.log(await listIssues(options)); // returns <issues_data>
})();
// List a repository issue
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
issue_number: 23, // required
},
};
(async () => {
console.log(await listIssue(options)); // returns <issue_data>
})();
// Create issue on a repository
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
title: "title", // required
body: "body",
state: "open", // open or closed
labels: ["bug", "dev"],
},
};
(async () => {
console.log(await createIssue(options)); // returns <created_issue_data>
})();
// Update a issue on repo like title, body, status, labels
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
title: "title",
body: "body",
issue_number: 23, // required
state: "closed", // open or closed
labels: ["enhancement", "qa"],
},
};
(async () => {
console.log(await updateIssue(options)); // returns <updated_issue_data>
})();
// Lock an issue
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
issue_number: 23, // required
lock_reason: "lock_reason",
},
};
(async () => {
console.log(await lockIssue(options)); // returns <>
})();
// Unlock an issue
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
issue_number: 23, // required
},
};
(async () => {
console.log(await unlockIssue(options)); // returns <>
})();
GitHub Repository Examples
// List all repository for the authenticated user
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "",
};
(async () => {
console.log(await listRepos(options)); // returns <repos_data>
})();
// List a repository for the authenticated user
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
};
(async () => {
console.log(await listRepo(options)); // returns <repo_data>
})();
// Create a repository for the authenticated user
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
body: {
name: "name", // new repo name
description: "description",
private: false, // true or false
},
};
(async () => {
console.log(await createRepo(options)); // returns <created_repo_data>
})();
// Update a repository details and its privacy
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
name: "name",
description: "description",
private: false, // true or false
archived: false, // true or false
},
};
(async () => {
console.log(await updateRepo(options)); // returns <updated_repo_data>
})();
// Delete a repository
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
};
(async () => {
console.log(await deleteRepo(options)); // returns <>
})();
GitHub Issue Comment Examples
// List issue comments for a repository
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
};
(async () => {
console.log(await listComments(options)); // returns <issue_comments_data>
})();
// Get an issue comment
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
comment_id: "comment_id", // required
},
};
(async () => {
console.log(await listComment(options)); // returns <issue_comment_data>
})();
// Create an issue comment
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
issue_number: "issue_number", // required
body: "comment_data",
},
};
(async () => {
console.log(await createComment(options)); // returns <created_comment_data>
})();
// Update an issue comment
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
comment_id: "comment_id", // required
body: "comment_data",
},
};
(async () => {
console.log(await updateComment(options)); // returns <updated_comment_data>
})();
// Delete an issue comment
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
comment_id: "comment_id", // required
},
};
(async () => {
console.log(await deleteComment(options)); // returns <>
})();
GitHub Issue Assignees Examples
// Lists the available assignees for issues in a repository.
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
};
(async () => {
console.log(await listAssignees(options)); // returns <assignees_data>
})();
// Checks a user has permission to an issue in this repository.
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
assignee: "assignee", // required
},
};
(async () => {
console.log(await checkAssignee(options)); // returns <assignee_data>
})();
// Add assignees to an issue
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
issue_number: 42, // required
assignees: ["assignees", "assignees"], // required
},
};
(async () => {
console.log(await addAssignees(options)); // returns <added_assignees_data>
})();
// Removes one or more assignees from an issue.
const options = {
token: "1e3ed294c3f7tce7btdcdg18t88d98b743f9ac48t135656",
owner: "owner", // owner or user
repo: "repo",
body: {
issue_number: 42, // required
assignees: ["assignees", "assignees"], // required
},
};
(async () => {
console.log(await removeAssignees(options)); // returns <assignees_data>
})();
For more body options flow github docs, set the param into the body.
To authenticate with GitHub, set the token
option.
License
Copyright
Copyright © 2021. S.Gupta