Skip to content

📬 Lightweight (<3KB) Wrapper around the GitHub Notifications API

License

Notifications You must be signed in to change notification settings

Intevel/gh-notifications

Repository files navigation

gh-notifications

npm version npm downloads License

📬 Lightweight (<3KB) Wrapper around the GitHub Notifications API

Install

# Using npm
npm install gh-notifications

# Using yarn
yarn add gh-notifications

Usage

Warning: Usage of gh-notifications requires a valid github api token: Documentation

const APITOKEN = "**************";

async function main() {
  // get a GitHubInbox instance and pass the api token to it
  const inbox = new GitHubInbox(APITOKEN);
  // initialize the inbox
  await inbox.initialize();

  // fetch all unread notifications
  const unreadNotifications = await inbox.fetchUnreadNotifications();
  // view src/types.ts for all fields in the notification object
  console.log(unreadNotifications);

  // mark the latest unread notification as read
  await inbox.markAsRead(unreadNotifications[0]?.id);
}

main();

License

Published under MIT - Made with ❤️ by Conner Bachmann