{"id":15484761,"url":"https://github.com/sirbrillig/gitnews","last_synced_at":"2025-07-31T08:38:46.966Z","repository":{"id":57251318,"uuid":"90177719","full_name":"sirbrillig/gitnews","owner":"sirbrillig","description":"A node module to fetch GitHub notifications","archived":false,"fork":false,"pushed_at":"2022-12-20T17:06:26.000Z","size":91,"stargazers_count":6,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-26T09:59:12.455Z","etag":null,"topics":["github","github-notifications","nodejs","notifications"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sirbrillig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-03T17:55:05.000Z","updated_at":"2023-04-10T03:56:35.000Z","dependencies_parsed_at":"2023-01-30T01:15:52.884Z","dependency_job_id":null,"html_url":"https://github.com/sirbrillig/gitnews","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/sirbrillig/gitnews","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sirbrillig%2Fgitnews","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sirbrillig%2Fgitnews/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sirbrillig%2Fgitnews/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sirbrillig%2Fgitnews/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sirbrillig","download_url":"https://codeload.github.com/sirbrillig/gitnews/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sirbrillig%2Fgitnews/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268013866,"owners_count":24181287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-notifications","nodejs","notifications"],"created_at":"2024-10-02T05:41:46.146Z","updated_at":"2025-07-31T08:38:46.925Z","avatar_url":"https://github.com/sirbrillig.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gitnews\n\nA simple node module to fetch GitHub notifications.\n\nMade to be used by [gitnews-cli](https://github.com/sirbrillig/gitnews-cli) and [gitnews-menubar](https://github.com/sirbrillig/gitnews-menubar).\n\nSince this module uses a custom token, it can report on private repositories as well as public ones.\n\n## Install\n\nUsing npm:\n\n```\nnpm i --save gitnews\n```\n\nUsing yarn:\n\n```\nyarn add gitnews\n```\n\n## Usage\n\nYou must first create a GitHub token so the module has access to your notifications. To create the token, visit the [Tokens](https://github.com/settings/tokens) page and generate a new token for the app. You can call it \"gitnews\" and it needs at least `notifications` scope and the `repo` scope.\n\nThen import the `getNotifications` named function and pass it the token.\n\n```js\nconst { getNotifications } = require( 'gitnews' );\ngetNotifications( token )\n\t.then( notes =\u003e notes.filter( note =\u003e note.unread ) )\n\t.then( notes =\u003e notes.map( showNotification ) );\n\nfunction showNotification( note ) {\n\tconsole.log( note.repositoryFullName + ': ' + note.title + ' -- ' + note.subjectUrl );\n}\n```\n\nThe function will return a Promise. When the Promise resolves, it will pass the callback an array of notification objects. Each notification object has the properties listed below:\n\n- `updatedAt`: The time (in ISO 8601 format) of the notification.\n- `unread`: True if the notification has not been seen.\n- `repositoryName`: The Repository name (eg: `gitnews`).\n- `repositoryFullName`: The full Repository name (eg: `sirbrillig/gitnews`).\n- `title`: The title of the notification.\n- `type`: The type of the notification.\n- `id`: A unique ID for this notification (at its most recently updated timestamp).\n- `private`: True if the notification repo is private.\n- `commentUrl`: The URL of the notification's most recent comment.\n- `subjectUrl`: The URL of the notification's issue or PR.\n- `commentAvatar`: The URL of the image for the notification's most recent commenter.\n- `repositoryOwnerAvatar`: The URL of the image for the Repository's owner.\n\nIf you need additional data, the actual GitHub API responses are stored under the `api` property.\n\n## Advanced Usage\n\nThe `getNotifications` function is actually created by a factory function called `createNoteGetter` which is also exported by the module. `createNoteGetter` accepts an object with the following optional properties:\n\n- `log`: Defines a logging function which will be called with status messages as the fetching process proceeds. This defaults to a noop.\n- `fetch`: Defines the `fetch` function to use when making API requests. This defaults to [`node-fetch`](https://www.npmjs.com/package/node-fetch). This is mostly useful for testing.\n\nFor example:\n\n```js\nconst { createNoteGetter } = require( 'gitnews' );\nconst getNotifications = createNoteGetter( { log: message =\u003e console.log( message ) } );\ngetNotifications( token );\n```\n\n## Marking Notifications Read\n\nThe main purpose of this module is to retreieve notification URLs. Once a notification URL is visited, it typically marks the notification as read. In some cases (eg: security warnings), that does not happen. In these cases, it might be useful to manually mark a notification as read. This module exports the `markNotificationRead` function which can be used to do this.\n\nThe `markNotificationRead` function requires two arguments:\n\n- The token.\n- The notification object that resulted from calling getNotifications.\n\nThe following example marks all notifications as read.\n\n```js\nconst { getNotifications, markNotificationRead } = require( 'gitnews' );\ngetNotifications( token )\n\t.then( notes =\u003e notes.filter( note =\u003e note.unread ) )\n\t.then( notes =\u003e notes.map( note =\u003e markNotificationRead( token, note ) ) );\n```\n\nJust like `getNotifications`, `markNotificationRead` is created by a factory function called `createNoteMarkRead`. This can be used to override the `log` and `fetch` functions.\n\n```js\nconst { createNoteMarkRead } = require( 'gitnews' );\nconst markNotificationRead = createNoteMarkRead( { log: message =\u003e console.log( message ) } );\nmarkNotificationRead( token, note );\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsirbrillig%2Fgitnews","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsirbrillig%2Fgitnews","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsirbrillig%2Fgitnews/lists"}