|
| 1 | +--- |
| 2 | +title:Notifications | GitHub API |
| 3 | +--- |
| 4 | + |
| 5 | +#Notifications API |
| 6 | + |
| 7 | +* TOC |
| 8 | +{:toc} |
| 9 | + |
| 10 | +GitHub Notifications are powered by[watched repositories](/v3/repos/watching/). |
| 11 | +Users receive notifications for discussions in repositories they watch |
| 12 | +including: |
| 13 | + |
| 14 | +* Issues and their comments |
| 15 | +* Pull Requests and their comments |
| 16 | +* Comments on any commits |
| 17 | + |
| 18 | +Notifications are also sent for discussions in unwatched repositories when the |
| 19 | +user is involved including: |
| 20 | + |
| 21 | +***@mentions** |
| 22 | +* Issue assignments |
| 23 | +* Commits the user authors or commits |
| 24 | +* Any discussion in which the user actively participates |
| 25 | + |
| 26 | +All Notification API calls require the <strong>"notifications"</strong> API |
| 27 | +scope. Doing this will give read-only access to some Issue/Commit content. |
| 28 | +You will still need the "repo" scope to access Issues and Commits from their |
| 29 | +respective endpoints. |
| 30 | + |
| 31 | +Notifications come back as "threads". A Thread contains information about the |
| 32 | +current discussion of an Issue/PullRequest/Commit. |
| 33 | + |
| 34 | +Notifications are optimized for polling with the "Last-Modified" header. If |
| 35 | +there are no new notifications, you will see a "304 Not Modified" response, |
| 36 | +leaving your current rate limit untouched. There is an "X-Poll-Interval" |
| 37 | +header that specifies how often (in seconds) you are allowed to poll. In times |
| 38 | +of high server load, the time may increase. Please obey the header. |
| 39 | + |
| 40 | +# Add authentication to your requests |
| 41 | +$ curl -I https://api.github.com/notifications |
| 42 | +HTTP/1.1 200 OK |
| 43 | +Last-Modified: Thu, 25 Oct 2012 15:16:27 GMT |
| 44 | +X-Poll-Interval: 60 |
| 45 | + |
| 46 | +# Pass the Last-Modified header exactly |
| 47 | +$ curl -I https://api.github.com/notifications |
| 48 | + -H "If-Modified-Since: Thu, 25 Oct 2012 15:16:27 GMT" |
| 49 | +HTTP/1.1 304 Not Modified |
| 50 | +X-Poll-Interval: 60 |
| 51 | + |
| 52 | +##List your notifications |
| 53 | + |
| 54 | +List all notifications for the current user, grouped by repository. |
| 55 | + |
| 56 | +GET /notifications |
| 57 | + |
| 58 | +###Parameters |
| 59 | + |
| 60 | +all |
| 61 | +:_Optional_**boolean**`true` to show notifications marked as read. |
| 62 | + |
| 63 | +participating |
| 64 | +:_Optional_**boolean**`true` to show only notifications in which the user is |
| 65 | +directly participating or mentioned. |
| 66 | + |
| 67 | +since |
| 68 | +:_Optional_**time** filters out any notifications updated before the given |
| 69 | +time. The time should be passed in as UTC in the ISO 8601 format: |
| 70 | +`YYYY-MM-DDTHH:MM:SSZ`. Example: "2012-10-09T23:39:01Z". |
| 71 | + |
| 72 | +###Response |
| 73 | + |
| 74 | +<%= headers 200 %> |
| 75 | +<%= json(:thread) { |h|[h] } %> |
| 76 | + |
| 77 | +##List your notifications in a repository |
| 78 | + |
| 79 | +List all notifications for the current user. |
| 80 | + |
| 81 | +GET /repos/:owner/:repo/notifications |
| 82 | + |
| 83 | +###Parameters |
| 84 | + |
| 85 | +all |
| 86 | +:_Optional_**boolean**`true` to show notifications marked as read. |
| 87 | + |
| 88 | +participating |
| 89 | +:_Optional_**boolean**`true` to show only notifications in which the user is |
| 90 | +directly participating or mentioned. |
| 91 | + |
| 92 | +since |
| 93 | +:_Optional_**time** filters out any notifications updated before the given |
| 94 | +time. The time should be passed in as UTC in the ISO 8601 format: |
| 95 | +`YYYY-MM-DDTHH:MM:SSZ`. Example: "2012-10-09T23:39:01Z". |
| 96 | + |
| 97 | +###Response |
| 98 | + |
| 99 | +<%= headers 200 %> |
| 100 | +<%= json(:thread) { |h|[h] } %> |
| 101 | + |
| 102 | +##Mark as read |
| 103 | + |
| 104 | +Marking a notification as "read" removes it from the[default view |
| 105 | +on GitHub.com](https://github.com/notifications). |
| 106 | + |
| 107 | +PUT /notifications |
| 108 | + |
| 109 | +###Input |
| 110 | + |
| 111 | +unread |
| 112 | +:**Boolean** Changes the unread status of the threads. |
| 113 | + |
| 114 | +read |
| 115 | +:**Boolean** Inverse of "unread". |
| 116 | + |
| 117 | +last_read_at |
| 118 | +:_Optional_**Time** Describes the last point that notifications were checked. Anything |
| 119 | +updated since this time will not be updated. Default: Now. Expected in ISO |
| 120 | +8601 format:`YYYY-MM-DDTHH:MM:SSZ`. Example: "2012-10-09T23:39:01Z". |
| 121 | + |
| 122 | +###Response |
| 123 | + |
| 124 | +<%= headers 205 %> |
| 125 | + |
| 126 | +##Mark notifications as read in a repository |
| 127 | + |
| 128 | +Marking all notifications in a repository as "read" removes them |
| 129 | +from the[default view on GitHub.com](https://github.com/notifications). |
| 130 | + |
| 131 | +PUT /repos/:owner/:repo/notifications |
| 132 | + |
| 133 | +###Input |
| 134 | + |
| 135 | +unread |
| 136 | +:**Boolean** Changes the unread status of the threads. |
| 137 | + |
| 138 | +read |
| 139 | +:**Boolean** Inverse of "unread". |
| 140 | + |
| 141 | +last_read_at |
| 142 | +:_Optional_**Time** Describes the last point that notifications were checked. Anything |
| 143 | +updated since this time will not be updated. Default: Now. Expected in ISO |
| 144 | +8601 format:`YYYY-MM-DDTHH:MM:SSZ`. Example: "2012-10-09T23:39:01Z". |
| 145 | + |
| 146 | +###Response |
| 147 | + |
| 148 | +<%= headers 205 %> |
| 149 | + |
| 150 | +##View a single thread |
| 151 | + |
| 152 | +GET /notifications/threads/:id |
| 153 | + |
| 154 | +###Response |
| 155 | + |
| 156 | +<%= headers 200 %> |
| 157 | +<%= json(:thread) { |h|[h] } %> |
| 158 | + |
| 159 | +##Mark a thread as read |
| 160 | + |
| 161 | +PATCH /notifications/threads/:id |
| 162 | + |
| 163 | +###Input |
| 164 | + |
| 165 | +unread |
| 166 | +:**Boolean** Changes the unread status of the threads. |
| 167 | + |
| 168 | +read |
| 169 | +:**Boolean** Inverse of "unread". |
| 170 | + |
| 171 | +###Response |
| 172 | + |
| 173 | +<%= headers 205 %> |
| 174 | + |
| 175 | +##Get a Thread Subscription |
| 176 | + |
| 177 | +This checks to see if the current user is subscribed to a thread. You can also |
| 178 | +[get a Repository subscription](http://localhost:3000/v3/activity/watching/#get-a-repository-subscription). |
| 179 | + |
| 180 | +GET /notifications/threads/1/subscription |
| 181 | + |
| 182 | +###Response |
| 183 | + |
| 184 | +<%= headers 200 %> |
| 185 | +<%= json:subscription %> |
| 186 | + |
| 187 | +##Set a Thread Subscription |
| 188 | + |
| 189 | +This lets you subscribe to a thread, or ignore it. Subscribing to a thread |
| 190 | +is unnecessary if the user is already subscribed to the repository. Ignoring |
| 191 | +a thread will mute all future notifications (until you comment or get |
| 192 | +@mentioned). |
| 193 | + |
| 194 | +PUT /notifications/threads/1/subscription |
| 195 | + |
| 196 | +###Input |
| 197 | + |
| 198 | +subscribed |
| 199 | +:**boolean** Determines if notifications should be received from this |
| 200 | +repository. |
| 201 | + |
| 202 | +ignored |
| 203 | +:**boolean** Deterimines if all notifications should be blocked from this |
| 204 | +repository. |
| 205 | + |
| 206 | +###Response |
| 207 | + |
| 208 | +<%= headers 200 %> |
| 209 | +<%= json:subscription %> |
| 210 | + |
| 211 | +##Delete a Thread Subscription |
| 212 | + |
| 213 | +DELETE /notifications/threads/1/subscription |
| 214 | + |
| 215 | +###Response |
| 216 | + |
| 217 | +<%= headers 204 %> |
| 218 | + |