|
1 | 1 | # Data-API
|
2 | 2 | The DATA API in Beaver Notes enables third-party applications to interact with the platform. It provides functionalities for creating notes, deleting notes, and adding labels, allowing for efficient management and organization of information within Beaver Notes.
|
| 3 | + |
| 4 | +The Following documentation is related on how to use said API if you are looking on building a plugin for beaver notes using the Data API consider checkign out the [Beaver-API-playground](https://github.com/Beaver-Notes/Data-API). |
| 5 | + |
| 6 | +## API Documentation |
| 7 | + |
| 8 | +### Base URL |
| 9 | +`http://localhost:3000` |
| 10 | + |
| 11 | +### Authentication |
| 12 | + |
| 13 | +#### Request Authentication |
| 14 | + |
| 15 | +**Endpoint:** `POST /request-auth` |
| 16 | + |
| 17 | +**Description:** Sends an authentication request to the renderer process in Electron. |
| 18 | + |
| 19 | +**Request:** |
| 20 | +- **Headers:** `Content-Type: application/json` |
| 21 | +- **Body:** |
| 22 | + ```json |
| 23 | + { |
| 24 | + "platform": "your-platform", |
| 25 | + "id": "your-id" |
| 26 | + } |
| 27 | + ``` |
| 28 | + |
| 29 | +**Example `curl` Command:** |
| 30 | +```bash |
| 31 | +curl --location 'http://localhost:3000/request-auth' \ |
| 32 | +--header 'Content-Type: application/json' \ |
| 33 | +--data '{ |
| 34 | + "platform": "your-platform", |
| 35 | + "id": "your-id" |
| 36 | +}' |
| 37 | +``` |
| 38 | + |
| 39 | +#### Verify Authentication |
| 40 | + |
| 41 | +**Endpoint:** `GET /confirm-auth` |
| 42 | + |
| 43 | +**Description:** Verifies the authentication token. |
| 44 | + |
| 45 | +**Request:** |
| 46 | +- **Headers:** |
| 47 | + - `Authorization: Bearer your-token` |
| 48 | + - `Content-Type: application/json` |
| 49 | + |
| 50 | +**Example `curl` Command:** |
| 51 | +```bash |
| 52 | +curl --location --request GET 'http://localhost:3000/confirm-auth' \ |
| 53 | +--header 'Authorization: Bearer your-token' \ |
| 54 | +--header 'Content-Type: application/json' \ |
| 55 | +--data '{ |
| 56 | + "platform": "your-platform", |
| 57 | + "id": "your-id" |
| 58 | +}' |
| 59 | +``` |
| 60 | + |
| 61 | +### Notes Management |
| 62 | + |
| 63 | +#### Add Note |
| 64 | + |
| 65 | +**Endpoint:** `POST /add-note` |
| 66 | + |
| 67 | +**Description:** Adds a new note and broadcasts it to all connected clients. |
| 68 | + |
| 69 | +**Request:** |
| 70 | +- **Headers:** |
| 71 | + - `Authorization: Bearer your-token` |
| 72 | + - `Content-Type: application/json` |
| 73 | +- **Body:** |
| 74 | + ```json |
| 75 | + { |
| 76 | + "title": "Sample Note", |
| 77 | + "content": "This is a sample note content." |
| 78 | + } |
| 79 | + ``` |
| 80 | + |
| 81 | +**Example `curl` Command:** |
| 82 | +```bash |
| 83 | +curl --location 'http://localhost:3000/add-note' \ |
| 84 | +--header 'Authorization: Bearer your-token' \ |
| 85 | +--header 'Content-Type: application/json' \ |
| 86 | +--data '{ |
| 87 | + "title": "Sample Note", |
| 88 | + "content": "This is a sample note content." |
| 89 | +}' |
| 90 | +``` |
| 91 | + |
| 92 | +#### Delete Note |
| 93 | + |
| 94 | +**Endpoint:** `POST /delete-note` |
| 95 | + |
| 96 | +**Description:** Deletes a note and broadcasts the deletion to all connected clients. |
| 97 | + |
| 98 | +**Request:** |
| 99 | +- **Headers:** |
| 100 | + - `Authorization: Bearer your-token` |
| 101 | + - `Content-Type: application/json` |
| 102 | +- **Body:** |
| 103 | + ```json |
| 104 | + { |
| 105 | + "id": "note-id" |
| 106 | + } |
| 107 | + ``` |
| 108 | + |
| 109 | +**Example `curl` Command:** |
| 110 | +```bash |
| 111 | +curl --location 'http://localhost:3000/delete-note' \ |
| 112 | +--header 'Authorization: Bearer your-token' \ |
| 113 | +--header 'Content-Type: application/json' \ |
| 114 | +--data '{ |
| 115 | + "id": "note-id" |
| 116 | +}' |
| 117 | +``` |
| 118 | + |
| 119 | +#### Add Label to Note |
| 120 | + |
| 121 | +**Endpoint:** `POST /add-label` |
| 122 | + |
| 123 | +**Description:** Adds a label to a note and broadcasts the update to all connected clients. |
| 124 | + |
| 125 | +**Request:** |
| 126 | +- **Headers:** |
| 127 | + - `Authorization: Bearer your-token` |
| 128 | + - `Content-Type: application/json` |
| 129 | +- **Body:** |
| 130 | + ```json |
| 131 | + { |
| 132 | + "id": "note-id", |
| 133 | + "labelId": "label-id" |
| 134 | + } |
| 135 | + ``` |
| 136 | + |
| 137 | +**Example `curl` Command:** |
| 138 | +```bash |
| 139 | +curl --location 'http://localhost:3000/add-label' \ |
| 140 | +--header 'Authorization: Bearer your-token' \ |
| 141 | +--header 'Content-Type: application/json' \ |
| 142 | +--data '{ |
| 143 | + "id": "note-id", |
| 144 | + "labelId": "label-id" |
| 145 | +}' |
| 146 | +``` |
| 147 | + |
0 commit comments