Skip to main content
Die REST-API verfügt jetzt über eine Versionskontrolle. Weitere Informationen findest du unter Informationen zur API-Versionsverwaltung.

REST-API-Endpunkte für Benachrichtigungen

Verwende die REST-API, um GitHub-Benachrichtigungen zu verwalten.

Informationen zu GitHub-Benachrichtigungen

Hinweis

Diese Endpunkte unterstützen nur die Authentifizierung über ein personal access token (classic). Weitere Informationen finden Sie unter Verwalten deiner persönlichen Zugriffstoken.

Du kannst die REST-API verwenden, um GitHub-Benachrichtigungen zu verwalten. Weitere Informationen zu Benachrichtigungen findest du unter Informationen zu Benachrichtigungen.

Für alle Aufrufe dieser Endpunkte ist der Bereich notifications oder repo erforderlich. Du benötigst außerdem den Bereich repo, um von den jeweiligen Endpunkten aus auf Issues und Commits zuzugreifen.

Benachrichtigungen werden als „Threads“ zurückgegeben. Ein Thread enthält Informationen zur aktuellen Diskussion eines Issues, eines Pull Requests oder eines Commits.

Benachrichtigungen werden für den Abruf mit dem Last-Modified-Header optimiert. Wenn keine neuen Benachrichtigungen vorliegen, wird eine 304 Not Modified-Antwort angezeigt, und die aktuelle Ratenbegrenzung bleibt unberührt. Es gibt einen X-Poll-Interval-Header, der angibt, wie oft der Abruf erfolgen darf (in Sekunden). In Zeiten hoher Serverlast kann dieser Zeitraum erhöht werden. Beachte den Header.

# Add authentication to your requests
$ curl -I https://api.github.com/notifications
HTTP/2 200
Last-Modified: Thu, 25 Oct 2012 15:16:27 GMT
X-Poll-Interval: 60

# Pass the Last-Modified header exactly
$ curl -I https://api.github.com/notifications
$    -H "If-Modified-Since: Thu, 25 Oct 2012 15:16:27 GMT"
> HTTP/2 304
> X-Poll-Interval: 60

Informationen zu Benachrichtigungsgründen

Diese GET-Endpunkte geben einen reason-Schlüssel zurück. Diese reasons sind Ereignissen zugeordnet, die eine Benachrichtigung auslösen.

Für den Empfang einer Benachrichtigung sind einige reason-Angaben möglich.

Name des GrundsBeschreibung
approval_requestedSie wurden gebeten, eine Bereitstellung zu überprüfen und zu genehmigen. Weitere Informationen finden Sie unter Überprüfen von Bereitstellungen.
assignDas Issue wurde dir zugewiesen.
authorDu hast den Thread erstellt.
ci_activityEine von dir ausgelöste GitHub Actions-Workflowausführung wurde abgeschlossen.
commentDu hast den Thread kommentiert.
invitationDu hast eine Einladung zum Mitwirken am Repository angenommen.
manualDu hast den Thread abonniert (über ein Issue oder einen Pull Request).
member_feature_requestedOrganisationsmitglieder haben angefordert, ein Feature wie Copilot zu aktivieren.
mentionDu wurdest im Inhalt über @mentioned explizit erwähnt.
review_requestedDu oder ein Team, in dem du Mitglied bist, wurde aufgefordert, einen Pull Request zu überprüfen.
security_advisory_creditDir wurde die Mitwirkung an einer Sicherheitsempfehlung gutgeschrieben.
security_alertGitHub hat ein Sicherheitsrisiko in deinem Repository entdeckt.
state_changeDu hast den Threadstatus geändert (z. B. durch Schließen eines Issues oder Mergen eines Pull Requests).
subscribedDu überwachst das Repository.
team_mentionDu bist Mitglied eines Teams, das erwähnt wurde.

Beachte, dass reason auf Threadbasis geändert wird und sich ändern kann, wenn die reason-Angabe für eine spätere Benachrichtigung anders lautet.

Wenn du beispielsweise der Autor eines Issues bist, weist reason bei nachfolgenden Benachrichtigungen zu diesem Issue den Wert author auf. Wenn du dann in demselben Issue über @mentioned erwähnt wirst, verfügen danach abgerufene Benachrichtigungen über den reason-Wert mention. Diese reason-Angabe bleibt mention unabhängig davon, ob du jemals wieder erwähnt wirst.

List notifications for the authenticated user

List all notifications for the current user, sorted by most recently updated.

Differenzierte Zugriffstoken für "List notifications for the authenticated user"

Dieser Endpunkt funktioniert nicht mit GitHub-App-Benutzerzugriffstoken, GitHub-App-Installationszugriffstoken oder differenzierten persönlichen Zugriffstoken.

Parameter für „List notifications for the authenticated user“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Abfrageparameter
Name, type, BESCHREIBUNG
all boolean

If true, show notifications marked as read.

Standard: false

participating boolean

If true, only shows notifications in which the user is directly participating or mentioned.

Standard: false

since string

Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

before string

Only show notifications updated before the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Standard: 1

per_page integer

The number of results per page (max 50). For more information, see "Using pagination in the REST API."

Standard: 50

HTTP-Antwortstatuscodes für „List notifications for the authenticated user“

StatuscodeBESCHREIBUNG
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

422

Validation failed, or the endpoint has been spammed.

Codebeispiele für „List notifications for the authenticated user“

Anforderungsbeispiel

get/notifications
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/notifications

Response

Status: 200
[ { "id": "1", "repository": { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "[email protected]:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks" }, "subject": { "title": "Greetings", "url": "https://api.github.com/repos/octokit/octokit.rb/issues/123", "latest_comment_url": "https://api.github.com/repos/octokit/octokit.rb/issues/comments/123", "type": "Issue" }, "reason": "subscribed", "unread": true, "updated_at": "2014-11-07T22:01:45Z", "last_read_at": "2014-11-07T22:01:45Z", "url": "https://api.github.com/notifications/threads/1", "subscription_url": "https://api.github.com/notifications/threads/1/subscription" } ]

Mark notifications as read

Marks all notifications as "read" for the current user. If the number of notifications is too large to complete in one request, you will receive a 202 Accepted status and GitHub will run an asynchronous process to mark notifications as "read." To check whether any "unread" notifications remain, you can use the List notifications for the authenticated user endpoint and pass the query parameter all=false.

Differenzierte Zugriffstoken für "Mark notifications as read"

Dieser Endpunkt funktioniert nicht mit GitHub-App-Benutzerzugriffstoken, GitHub-App-Installationszugriffstoken oder differenzierten persönlichen Zugriffstoken.

Parameter für „Mark notifications as read“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Textparameter
Name, type, BESCHREIBUNG
last_read_at string

Describes the last point that notifications were checked. Anything updated since this time will not be marked as read. If you omit this parameter, all notifications are marked as read. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Default: The current timestamp.

read boolean

Whether the notification has been read.

HTTP-Antwortstatuscodes für „Mark notifications as read“

StatuscodeBESCHREIBUNG
202

Accepted

205

Reset Content

304

Not modified

401

Requires authentication

403

Forbidden

Codebeispiele für „Mark notifications as read“

Anforderungsbeispiel

put/notifications
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/notifications \ -d '{"last_read_at":"2022-06-10T00:00:00Z","read":true}'

Response