npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

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

408

Readme

GitHub's REST API

npm Support Node of LTS dependencies Status

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

MIT license.

Copyright

Copyright © 2021. S.Gupta