|
| 1 | +--- |
| 2 | +title:Notifications | GitHub API |
| 3 | +--- |
| 4 | + |
| 5 | +#Notifications |
| 6 | + |
| 7 | +* TOC |
| 8 | +{:toc} |
| 9 | + |
| 10 | +GitHub Notifications are powered by[watched repositories](/v3/activity/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`notifications` or |
| 27 | +`repo` API scopes. Doing this will give read-only access to |
| 28 | +some Issue/Commit content. You will still need the "repo" scope to access |
| 29 | +Issues and Commits from their 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 | +Name | Type | Description |
| 61 | +-----|------|-------------- |
| 62 | +`all`|`boolean` | If`true`, show notifications marked as read. Default:`false` |
| 63 | +`participating`|`boolean` | If`true`, only shows notifications in which the user is directly participating or mentioned. Default:`false` |
| 64 | +`since`|`string` | Filters out any notifications updated before the given time. This is a timestamp in ISO 8601 format:`YYYY-MM-DDTHH:MM:SSZ`. Default:`Time.now` |
| 65 | + |
| 66 | + |
| 67 | +###Response |
| 68 | + |
| 69 | +<%= headers 200 %> |
| 70 | +<%= json(:thread) { |h|[h] } %> |
| 71 | + |
| 72 | +##List your notifications in a repository |
| 73 | + |
| 74 | +List all notifications for the current user. |
| 75 | + |
| 76 | +GET /repos/:owner/:repo/notifications |
| 77 | + |
| 78 | +###Parameters |
| 79 | + |
| 80 | +Name | Type | Description |
| 81 | +-----|------|-------------- |
| 82 | +`all`|`boolean` | If`true`, show notifications marked as read. Default:`false` |
| 83 | +`participating`|`boolean` | If`true`, only shows notifications in which the user is directly participating or mentioned. Default:`false` |
| 84 | +`since`|`string` | Filters out any notifications updated before the given time. This is a timestamp in ISO 8601 format:`YYYY-MM-DDTHH:MM:SSZ`. Default:`Time.now` |
| 85 | + |
| 86 | + |
| 87 | +###Response |
| 88 | + |
| 89 | +<%= headers 200 %> |
| 90 | +<%= json(:thread) { |h|[h] } %> |
| 91 | + |
| 92 | +##Mark as read |
| 93 | + |
| 94 | +Marking a notification as "read" removes it from the[default view |
| 95 | +on GitHub.com](https://github.com/notifications). |
| 96 | + |
| 97 | +PUT /notifications |
| 98 | + |
| 99 | +###Parameters |
| 100 | + |
| 101 | +Name | Type | Description |
| 102 | +-----|------|-------------- |
| 103 | +`last_read_at`|`string` | Describes the last point that notifications were checked. Anything updated since this time will not be updated. This is a timestamp in ISO 8601 format:`YYYY-MM-DDTHH:MM:SSZ`. Default:`Time.now` |
| 104 | + |
| 105 | + |
| 106 | +###Response |
| 107 | + |
| 108 | +<%= headers 205 %> |
| 109 | + |
| 110 | +##Mark notifications as read in a repository |
| 111 | + |
| 112 | +Marking all notifications in a repository as "read" removes them |
| 113 | +from the[default view on GitHub.com](https://github.com/notifications). |
| 114 | + |
| 115 | +PUT /repos/:owner/:repo/notifications |
| 116 | + |
| 117 | +###Parameters |
| 118 | + |
| 119 | +Name | Type | Description |
| 120 | +-----|------|-------------- |
| 121 | +`last_read_at`|`string` | Describes the last point that notifications were checked. Anything updated since this time will not be updated. This is a timestamp in ISO 8601 format:`YYYY-MM-DDTHH:MM:SSZ`. Default:`Time.now` |
| 122 | + |
| 123 | + |
| 124 | +###Response |
| 125 | + |
| 126 | +<%= headers 205 %> |
| 127 | + |
| 128 | +##View a single thread |
| 129 | + |
| 130 | +GET /notifications/threads/:id |
| 131 | + |
| 132 | +###Response |
| 133 | + |
| 134 | +<%= headers 200 %> |
| 135 | +<%= json(:thread) %> |
| 136 | + |
| 137 | +##Mark a thread as read |
| 138 | + |
| 139 | +PATCH /notifications/threads/:id |
| 140 | + |
| 141 | +###Response |
| 142 | + |
| 143 | +<%= headers 205 %> |
| 144 | + |
| 145 | +##Get a Thread Subscription |
| 146 | + |
| 147 | +This checks to see if the current user is subscribed to a thread. You can also |
| 148 | +[get a Repository subscription](/v3/activity/watching/#get-a-repository-subscription). |
| 149 | + |
| 150 | +GET /notifications/threads/:id/subscription |
| 151 | + |
| 152 | +###Response |
| 153 | + |
| 154 | +<%= headers 200 %> |
| 155 | +<%= json:subscription %> |
| 156 | + |
| 157 | +##Set a Thread Subscription |
| 158 | + |
| 159 | +This lets you subscribe to a thread, or ignore it. Subscribing to a thread |
| 160 | +is unnecessary if the user is already subscribed to the repository. Ignoring |
| 161 | +a thread will mute all future notifications (until you comment or get |
| 162 | +@mentioned). |
| 163 | + |
| 164 | +PUT /notifications/threads/:id/subscription |
| 165 | + |
| 166 | +###Parameters |
| 167 | + |
| 168 | +Name | Type | Description |
| 169 | +-----|------|-------------- |
| 170 | +`subscribed`|`boolean`| Determines if notifications should be received from this thread |
| 171 | +`ignored`|`boolean`| Determines if all notifications should be blocked from this thread |
| 172 | + |
| 173 | + |
| 174 | +###Response |
| 175 | + |
| 176 | +<%= headers 200 %> |
| 177 | +<%= json:subscription %> |
| 178 | + |
| 179 | +##Delete a Thread Subscription |
| 180 | + |
| 181 | +DELETE /notifications/threads/:id/subscription |
| 182 | + |
| 183 | +###Response |
| 184 | + |
| 185 | +<%= headers 204 %> |
| 186 | + |