mirror of
https://github.com/mastodon/documentation
synced 2025-04-11 22:56:17 +02:00
Add notifications API
This commit is contained in:
parent
622d80f716
commit
7f4e00e44b
@ -12,4 +12,4 @@ Mastodon natively supports the [Web Push API](https://developer.mozilla.org/en-U
|
|||||||
- [toot-relay](https://github.com/DagAgren/toot-relay)
|
- [toot-relay](https://github.com/DagAgren/toot-relay)
|
||||||
- [PushToFCM](https://github.com/tateisu/PushToFCM)
|
- [PushToFCM](https://github.com/tateisu/PushToFCM)
|
||||||
|
|
||||||
Using the Web Push API requires your app to have the `push` scope.
|
Using the Web Push API requires your app to have the `push` scope. To create a new Web Push API subscription, use [POST /api/v1/push/subscription]({{< relref "notifications.md#post-api-v1-push-subscription" >}}).
|
||||||
|
@ -1,7 +1,119 @@
|
|||||||
---
|
---
|
||||||
title: Notifications API
|
title: Notifications
|
||||||
menu:
|
menu:
|
||||||
docs:
|
docs:
|
||||||
parent: api
|
parent: rest-api
|
||||||
weight: 10
|
weight: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## GET /api/v1/notifications
|
||||||
|
|
||||||
|
Notifications concerning the user.
|
||||||
|
|
||||||
|
Returns array of [Notification]({{< relref "entities.md#notification" >}})
|
||||||
|
|
||||||
|
### Resource information
|
||||||
|
|
||||||
|
{{< api_method_info auth="Yes" user="Yes" scope="read read:notifications" version="0.0.0" >}}
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
|Name|Description|Required|Default|
|
||||||
|
|----|-----------|:------:|:-----:|
|
||||||
|
| `max_id` | Return results older than ID | Optional ||
|
||||||
|
| `since_id` | Return results newer than ID | Optional ||
|
||||||
|
| `limit` | Maximum number of results | Optional | 20 |
|
||||||
|
| `exclude_types` | Array of types to exclude (e.g. `follow`, `favourite`, `reblog`, `mention`) | Optional ||
|
||||||
|
|
||||||
|
### Pagination
|
||||||
|
|
||||||
|
{{< api_dynamic_pagination >}}
|
||||||
|
|
||||||
|
## GET /api/v1/notifications/:id
|
||||||
|
|
||||||
|
Returns [Notification]({{< relref "entities.md#notification" >}})
|
||||||
|
|
||||||
|
### Resource information
|
||||||
|
|
||||||
|
{{< api_method_info auth="Yes" user="Yes" scope="read read:notifications" version="0.0.0" >}}
|
||||||
|
|
||||||
|
## POST /api/v1/notifications/clear
|
||||||
|
|
||||||
|
Delete all notifications from the server.
|
||||||
|
|
||||||
|
### Resource information
|
||||||
|
|
||||||
|
{{< api_method_info auth="Yes" user="Yes" scope="write write:notifications" version="0.0.0" >}}
|
||||||
|
|
||||||
|
## POST /api/v1/notifications/dismiss
|
||||||
|
|
||||||
|
Delete a single notification from the server.
|
||||||
|
|
||||||
|
### Resource information
|
||||||
|
|
||||||
|
{{< api_method_info auth="Yes" user="Yes" scope="write write:notifications" version="0.0.0" >}}
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
|Name|Description|Required|Default|
|
||||||
|
|----|-----------|:------:|:-----:|
|
||||||
|
| `id` | Notification ID | Required ||
|
||||||
|
|
||||||
|
## POST /api/v1/push/subscription
|
||||||
|
|
||||||
|
Add a Web Push API subscription to receive notifications. See also: [Web Push API]({{< relref "push.md" >}})
|
||||||
|
|
||||||
|
> Each access token can have one push subscription. If you create a new subscription, the old subscription is deleted.
|
||||||
|
|
||||||
|
Returns [Push Subscription]({{< relref "entities.md#push-subscription" >}})
|
||||||
|
|
||||||
|
### Resource information
|
||||||
|
|
||||||
|
{{< api_method_info auth="Yes" user="Yes" scope="push" version="0.0.0" >}}
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
|Name|Description|Required|Default|
|
||||||
|
|----|-----------|:------:|:-----:|
|
||||||
|
| `subscription[endpoint]` | Endpoint URL that called when notification is happen. | Required ||
|
||||||
|
| `subscription[keys][p256dh]` | User agent public key. Base64 encoded string of public key of ECDH key using 'prime256v1' curve. | Required ||
|
||||||
|
| `subscription[keys][auth]` | Auth secret. Base64 encoded string of 16 bytes of random data. | Required ||
|
||||||
|
| `data[alerts][follow]` | Boolean of whether you want to receive follow notification event. | Optional ||
|
||||||
|
| `data[alerts][favourite]` | Boolean of whether you want to receive favourite notification event. | Optional ||
|
||||||
|
| `data[alerts][reblog]` | Boolean of whether you want to receive reblog notification event. | Optional ||
|
||||||
|
| `data[alerts][mention]` | Boolean of whether you want to receive mention notification event. | Optional ||
|
||||||
|
|
||||||
|
## GET /api/v1/push/subscription
|
||||||
|
|
||||||
|
Returns [Push Subscription]({{< relref "entities.md#push-subscription" >}})
|
||||||
|
|
||||||
|
### Resource information
|
||||||
|
|
||||||
|
{{< api_method_info auth="Yes" user="Yes" scope="push" version="0.0.0" >}}
|
||||||
|
|
||||||
|
## PUT /api/v1/push/subscription
|
||||||
|
|
||||||
|
Update current Web Push API subscription. Only the `data` part can be updated, e.g. which types of notifications are desired. To change fundamentals, a new subscription must be created instead.
|
||||||
|
|
||||||
|
Returns [Push Subscription]({{< relref "entities.md#push-subscription" >}})
|
||||||
|
|
||||||
|
### Resource information
|
||||||
|
|
||||||
|
{{< api_method_info auth="Yes" user="Yes" scope="push" version="0.0.0" >}}
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
|Name|Description|Required|Default|
|
||||||
|
|----|-----------|:------:|:-----:|
|
||||||
|
| `data[alerts][follow]` | Boolean of whether you want to receive follow notification event. | Optional ||
|
||||||
|
| `data[alerts][favourite]` | Boolean of whether you want to receive favourite notification event. | Optional ||
|
||||||
|
| `data[alerts][reblog]` | Boolean of whether you want to receive reblog notification event. | Optional ||
|
||||||
|
| `data[alerts][mention]` | Boolean of whether you want to receive mention notification event. | Optional ||
|
||||||
|
|
||||||
|
## DELETE /api/v1/push/subscription
|
||||||
|
|
||||||
|
Remove the current Web Push API subscription.
|
||||||
|
|
||||||
|
### Resource information
|
||||||
|
|
||||||
|
{{< api_method_info auth="Yes" user="Yes" scope="push" version="0.0.0" >}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user