-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
127 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,142 +1,169 @@ | ||
# API DOC | ||
# API Documentation | ||
|
||
## Routes | ||
|
||
All routes are prefixed with `/api` | ||
|
||
## keys endpoint | ||
--- | ||
|
||
### get vapid keys | ||
## Notifications Endpoint | ||
|
||
**URL** : `/api/keys` | ||
### Send a Notification to All Devices | ||
|
||
**Method** : `GET` | ||
**URL**: `/api/notify` | ||
|
||
**Auth required** : No | ||
**Method**: `POST` | ||
|
||
**Description** : get the server vapid key to create a client subscription | ||
**Auth required**: Yes (only if the server password is set). Authentication | ||
header must be `Bearer <serverpassword>`. | ||
|
||
#### Success Responses | ||
**Description**: Send a notification to all devices. | ||
|
||
**Code** : `200 OK` | ||
|
||
**Content** : | ||
**Body**: | ||
|
||
```json | ||
{"successful":true,"data":"BGDRJjAeUMkFC1uFnqR0L5-VlqwV6RxhQedXid6CY95ONU3NCQI82-WvNWc2vc9HV8YOIAC9VsMrMhJhi3XS8MQ"} | ||
{ | ||
"title": "<title>", | ||
"message": "<message>", | ||
"icon": "<optional icon url>", | ||
"tags": ["<optional list of strings>"] | ||
} | ||
``` | ||
|
||
## device endpoint | ||
|
||
### create a new device | ||
|
||
**URL** : `/api/device` | ||
#### Success Response | ||
|
||
**Method** : `POST` | ||
**Code**: `200 OK` | ||
|
||
**Auth required** : no (only if the serverpassword is set) Authentication header must be `Bearer <serverpassword>` | ||
|
||
**Description** : create a new device and return the device id with a secret that can be used to delete it later | ||
|
||
**Body** : | ||
**Content**: | ||
|
||
```json | ||
{ | ||
"web_push_data":{ | ||
"endpoint":"<endpoint url>", | ||
"key":"<base64 encoded subscription p256 key>", | ||
"auth":"<base64 encoded subscription auth>" | ||
} | ||
"successful": true, | ||
"data": "notified" | ||
} | ||
``` | ||
|
||
#### Success Responses | ||
--- | ||
|
||
**Code** : `200 OK` | ||
## Keys Endpoint | ||
|
||
**Content** : | ||
### Get Vapid Keys | ||
|
||
```json | ||
{"successful":true,"data":{"id":"c968712190ec72e785160fe2a45b45a4","secret":"bd907b2a5f9e571949aa92561fcb5694"}} | ||
``` | ||
**URL**: `/api/keys` | ||
|
||
### Check if a device exists | ||
**Method**: `GET` | ||
|
||
**URL** : `/api/device/<device_id>` | ||
**Auth required**: No | ||
|
||
**Method** : `GET` | ||
**Description**: Get the server Vapid key to create a client subscription. | ||
|
||
**Auth required** : No | ||
#### Success Response | ||
|
||
**Description** : check if a device exists | ||
**Code**: `200 OK` | ||
|
||
#### Success Responses | ||
|
||
**Code** : `200 OK` | ||
|
||
**Content** : | ||
**Content**: | ||
|
||
```json | ||
{"successful":true,"data":true} | ||
{ | ||
"successful": true, | ||
"data": "BGDRJjAeUMkFC1uFnqR0L5-VlqwV6RxhQedXid6CY95ONU3NCQI82-WvNWc2vc9HV8YOIAC9VsMrMhJhi3XS8MQ" | ||
} | ||
``` | ||
|
||
### Delete a device | ||
--- | ||
|
||
**URL** : `/api/device/<device_id>` | ||
## Device Endpoint | ||
|
||
**Method** : `DELETE` | ||
### Create a New Device | ||
|
||
**Auth required** : No | ||
**URL**: `/api/device` | ||
|
||
**Description** : delete a device | ||
**Method**: `POST` | ||
|
||
**Body** : | ||
**Auth required**: No (only if the server password is set). Authentication header must be `Bearer <serverpassword>`. | ||
|
||
**Description**: Create a new device and return the device ID with a secret that | ||
can be used to delete or update it later. | ||
|
||
**Body**: | ||
|
||
```json | ||
{ | ||
"secret":"<device secret>" | ||
"web_push_data": { | ||
"endpoint": "<endpoint url>", | ||
"key": "<base64 encoded subscription p256 key>", | ||
"auth": "<base64 encoded subscription auth>" | ||
} | ||
} | ||
``` | ||
|
||
#### Success Responses | ||
#### Success Response | ||
|
||
**Code** : `200 OK` | ||
**Code**: `200 OK` | ||
|
||
**Content** : | ||
**Content**: | ||
|
||
```json | ||
{"successful":true,"data":"device deleted"} | ||
{ | ||
"successful": true, | ||
"data": { | ||
"id": "c968712190ec72e785160fe2a45b45a4", | ||
"secret": "bd907b2a5f9e571949aa92561fcb5694" | ||
} | ||
} | ||
``` | ||
|
||
## Notifications endpoint | ||
### Check If a Device Exists | ||
|
||
### Send a notification to all devices | ||
**URL**: `/api/device/<device_id>` | ||
|
||
**URL** : `/api/notify` | ||
**Method**: `GET` | ||
|
||
**Method** : `POST` | ||
**Auth required**: No | ||
|
||
**Auth required** : yes (only if the serverpassword is set) Authentication header must be `Bearer <serverpassword>` | ||
**Description**: Check if a device exists. | ||
|
||
**Description** : send a notification to all devices | ||
#### Success Response | ||
|
||
**Body** : | ||
**Code**: `200 OK` | ||
|
||
**Content**: | ||
|
||
```json | ||
{ | ||
"successful": true, | ||
"data": true | ||
} | ||
``` | ||
|
||
### Delete a Device | ||
|
||
**URL**: `/api/device/<device_id>` | ||
|
||
**Method**: `DELETE` | ||
|
||
**Auth required**: No | ||
|
||
**Description**: Delete a device. | ||
|
||
**Body**: | ||
|
||
```json | ||
{ | ||
"title":"<title>", | ||
"message":"<message>", | ||
"icon":"<optional icon url>", | ||
"tags": [<optional list of strings>] | ||
"secret": "<device secret>" | ||
} | ||
``` | ||
|
||
#### Success Responses | ||
#### Success Response | ||
|
||
**Code** : `200 OK` | ||
**Code**: `200 OK` | ||
|
||
**Content** : | ||
**Content**: | ||
|
||
```json | ||
{"successful":true,"data":"notified"} | ||
``` | ||
{ | ||
"successful": true, | ||
"data": "device deleted" | ||
} | ||
``` | ||
|
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters