2020-09-27 07:34:56 +00:00
# API
The application provides a REST API that can be used by 3rd party applications to manage bookmarks.
## Authentication
All requests against the API must be authorized using an authorization token. The application automatically generates an API token for each user, which can be accessed through the *Settings* page.
The token needs to be passed as `Authorization` header in the HTTP request:
```
Authorization: Token < Token >
```
## Resources
The following resources are available:
### Bookmarks
**List**
```
GET /api/bookmarks/
```
2022-05-26 02:10:36 +00:00
List bookmarks.
2020-09-27 07:34:56 +00:00
Parameters:
- `q` - Filters results using a search phrase using the same logic as through the UI
- `limit` - Limits the max. number of results. Default is `100` .
- `offset` - Index from which to start returning results
Example response:
```json
{
"count": 123,
"next": "http://127.0.0.1:8000/api/bookmarks/?limit=100& offset=100",
"previous": null,
"results": [
{
"id": 1,
"url": "https://example.com",
"title": "Example title",
"description": "Example description",
2023-05-20 09:54:26 +00:00
"notes": "Example notes",
2020-12-31 08:47:51 +00:00
"website_title": "Website title",
"website_description": "Website description",
2024-03-17 09:04:05 +00:00
"web_archive_snapshot_url": "https://web.archive.org/web/20200926094623/https://example.com",
2022-07-23 20:17:20 +00:00
"is_archived": false,
"unread": false,
2022-08-05 07:34:03 +00:00
"shared": false,
2020-09-27 07:34:56 +00:00
"tag_names": [
"tag1",
2021-02-14 17:00:22 +00:00
"tag2"
2020-09-27 07:34:56 +00:00
],
"date_added": "2020-09-26T09:46:23.006313Z",
"date_modified": "2020-09-26T16:01:14.275335Z"
},
...
]
}
```
2021-02-16 03:24:22 +00:00
**List Archived**
2021-02-14 17:00:22 +00:00
```
GET /api/bookmarks/archived/
```
2022-05-26 02:10:36 +00:00
List archived bookmarks.
2021-02-14 17:00:22 +00:00
Parameters and response are the same as for the regular list endpoint.
2020-09-27 07:34:56 +00:00
**Retrieve**
```
GET /api/bookmarks/< id > /
```
Retrieves a single bookmark by ID.
**Create**
```
POST /api/bookmarks/
```
2022-05-26 02:10:36 +00:00
Creates a new bookmark. Tags are simply assigned using their names. Including
`is_archived: true` saves a bookmark directly to the archive.
2020-09-27 07:34:56 +00:00
Example payload:
```json
{
"url": "https://example.com",
"title": "Example title",
"description": "Example description",
2023-05-20 09:54:26 +00:00
"notes": "Example notes",
2022-05-26 02:10:36 +00:00
"is_archived": false,
2022-07-23 20:17:20 +00:00
"unread": false,
2022-08-05 07:34:03 +00:00
"shared": false,
2020-09-27 07:34:56 +00:00
"tag_names": [
"tag1",
"tag2"
]
}
```
**Update**
```
PUT /api/bookmarks/< id > /
```
2022-07-23 20:17:20 +00:00
Updates a bookmark.
This is a full update, which requires at least a URL, and fields that are not specified are cleared or reset to their defaults.
Tags are simply assigned using their names.
Example payload:
```json
{
"url": "https://example.com",
"title": "Example title",
"description": "Example description",
"tag_names": [
"tag1",
"tag2"
]
}
```
**Patch**
```
PATCH /api/bookmarks/< id > /
```
Updates a bookmark partially.
Allows to modify individual fields of a bookmark.
Tags are simply assigned using their names.
2020-09-27 07:34:56 +00:00
Example payload:
```json
{
"url": "https://example.com",
"title": "Example title",
"description": "Example description",
"tag_names": [
"tag1",
"tag2"
]
}
```
2021-02-16 03:24:22 +00:00
**Archive**
```
POST /api/bookmarks/< id > /archive/
```
Archives a bookmark.
**Unarchive**
```
POST /api/bookmarks/< id > /unarchive/
```
Unarchives a bookmark.
2020-09-27 07:34:56 +00:00
**Delete**
```
DELETE /api/bookmarks/< id > /
```
Deletes a bookmark by ID.
### Tags
**List**
```
GET /api/tags/
```
List tags.
Parameters:
- `limit` - Limits the max. number of results. Default is `100` .
- `offset` - Index from which to start returning results
Example response:
```json
{
"count": 123,
"next": "http://127.0.0.1:8000/api/tags/?limit=100& offset=100",
"previous": null,
"results": [
{
"id": 1,
"name": "example",
"date_added": "2020-09-26T09:46:23.006313Z"
},
...
]
}
```
**Retrieve**
```
GET /api/tags/< id > /
```
Retrieves a single tag by ID.
**Create**
```
POST /api/tags/
```
Creates a new tag.
Example payload:
```json
{
"name": "example"
}
```
2023-10-01 19:57:32 +00:00
### User
**Profile**
```
GET /api/user/profile/
```
User preferences.
Example response:
```json
{
"theme": "auto",
"bookmark_date_display": "relative",
"bookmark_link_target": "_blank",
"web_archive_integration": "enabled",
"tag_search": "lax",
"enable_sharing": true,
"enable_public_sharing": true,
"enable_favicons": false,
"display_url": false,
"permanent_notes": false,
"search_preferences": {
"sort": "title_asc",
"shared": "off",
"unread": "off"
}
}
```