···2233The Karakeep library provides functions for working with assets (images, documents, etc.) attached to bookmarks.
4455+## Types
66+77+```ocaml
88+type asset_id = string
99+1010+type asset_type =
1111+ | Screenshot (* Screenshot of a webpage *)
1212+ | AssetScreenshot (* Screenshot of an asset *)
1313+ | BannerImage (* Banner image *)
1414+ | FullPageArchive (* Archive of a full webpage *)
1515+ | Video (* Video asset *)
1616+ | BookmarkAsset (* Generic bookmark asset *)
1717+ | PrecrawledArchive (* Pre-crawled archive *)
1818+ | Unknown (* Unknown asset type *)
1919+2020+type asset = {
2121+ id : asset_id;
2222+ asset_type : asset_type;
2323+}
2424+```
2525+526## Getting Asset URL
627728### `get_asset_url`
···930Get the asset URL for a given asset ID.
10311132```ocaml
1212-val get_asset_url :
1313- string ->
1414- string ->
1515- string
3333+val get_asset_url : string -> asset_id -> string
1634```
17351836#### Parameters
···3654Fetch an asset from the Karakeep server as a binary string.
37553856```ocaml
3939-val fetch_asset :
4040- api_key:string ->
4141- string ->
4242- string ->
4343- string Lwt.t
5757+val fetch_asset : api_key:string -> string -> asset_id -> string Lwt.t
4458```
45594660#### Parameters
···6074 (* Do something with the binary data *)
6175 Lwt.return_unit
6276```
7777+7878+## Attaching Assets
7979+8080+### `attach_asset`
8181+8282+Attach an asset to a bookmark.
8383+8484+```ocaml
8585+val attach_asset :
8686+ api_key:string ->
8787+ asset_id:asset_id ->
8888+ asset_type:asset_type ->
8989+ string ->
9090+ bookmark_id ->
9191+ asset Lwt.t
9292+```
9393+9494+#### Parameters
9595+9696+- `api_key`: API key for authentication
9797+- `asset_id`: ID of the asset to attach
9898+- `asset_type`: Type of the asset
9999+- `base_url`: Base URL of the Karakeep instance
100100+- `bookmark_id`: ID of the bookmark to attach the asset to
101101+102102+#### Example
103103+104104+```ocaml
105105+let attach_screenshot =
106106+ let api_key = "your_api_key" in
107107+ let base_url = "https://hoard.recoil.org" in
108108+ let bookmark_id = "bookmark123" in
109109+ let asset_id = "asset123" in
110110+ let* attached_asset =
111111+ Karakeep.attach_asset
112112+ ~api_key
113113+ ~asset_id
114114+ ~asset_type:Karakeep.Screenshot
115115+ base_url
116116+ bookmark_id in
117117+ Printf.printf "Attached asset %s of type %s\n"
118118+ attached_asset.id
119119+ (match attached_asset.asset_type with
120120+ | Screenshot -> "screenshot"
121121+ | _ -> "other");
122122+ Lwt.return_unit
123123+```
124124+125125+## Replacing Assets
126126+127127+### `replace_asset`
128128+129129+Replace an asset on a bookmark with a new one.
130130+131131+```ocaml
132132+val replace_asset :
133133+ api_key:string ->
134134+ new_asset_id:asset_id ->
135135+ string ->
136136+ bookmark_id ->
137137+ asset_id ->
138138+ unit Lwt.t
139139+```
140140+141141+#### Parameters
142142+143143+- `api_key`: API key for authentication
144144+- `new_asset_id`: ID of the new asset
145145+- `base_url`: Base URL of the Karakeep instance
146146+- `bookmark_id`: ID of the bookmark
147147+- `asset_id`: ID of the asset to replace
148148+149149+#### Example
150150+151151+```ocaml
152152+let replace_screenshot =
153153+ let api_key = "your_api_key" in
154154+ let base_url = "https://hoard.recoil.org" in
155155+ let bookmark_id = "bookmark123" in
156156+ let old_asset_id = "old_asset123" in
157157+ let new_asset_id = "new_asset456" in
158158+ let* () =
159159+ Karakeep.replace_asset
160160+ ~api_key
161161+ ~new_asset_id
162162+ base_url
163163+ bookmark_id
164164+ old_asset_id in
165165+ Printf.printf "Replaced asset successfully\n";
166166+ Lwt.return_unit
167167+```
168168+169169+## Detaching Assets
170170+171171+### `detach_asset`
172172+173173+Detach an asset from a bookmark.
174174+175175+```ocaml
176176+val detach_asset :
177177+ api_key:string -> string -> bookmark_id -> asset_id -> unit Lwt.t
178178+```
179179+180180+#### Parameters
181181+182182+- `api_key`: API key for authentication
183183+- `base_url`: Base URL of the Karakeep instance
184184+- `bookmark_id`: ID of the bookmark
185185+- `asset_id`: ID of the asset to detach
186186+187187+#### Example
188188+189189+```ocaml
190190+let detach_screenshot =
191191+ let api_key = "your_api_key" in
192192+ let base_url = "https://hoard.recoil.org" in
193193+ let bookmark_id = "bookmark123" in
194194+ let asset_id = "asset123" in
195195+ let* () =
196196+ Karakeep.detach_asset
197197+ ~api_key
198198+ base_url
199199+ bookmark_id
200200+ asset_id in
201201+ Printf.printf "Detached asset successfully\n";
202202+ Lwt.return_unit
203203+```
+251-39
doc/bookmarks.md
···11# Bookmark Operations
2233-The Karakeep library provides several functions for working with bookmarks.
33+The Karakeep library provides comprehensive functions for working with bookmarks.
44+55+## Types
66+77+The primary types related to bookmarks are:
88+99+```ocaml
1010+type bookmark_id = string
1111+1212+type bookmark_content_type =
1313+ | Link (* A URL to a webpage *)
1414+ | Text (* Plain text content *)
1515+ | Asset (* An attached asset (image, PDF, etc.) *)
1616+ | Unknown (* Unknown content type *)
1717+1818+type tagging_status =
1919+ | Success (* Tagging was successful *)
2020+ | Failure (* Tagging failed *)
2121+ | Pending (* Tagging is pending *)
2222+2323+type bookmark = {
2424+ id : bookmark_id;
2525+ created_at : Ptime.t;
2626+ modified_at : Ptime.t option;
2727+ title : string option;
2828+ archived : bool;
2929+ favourited : bool;
3030+ tagging_status : tagging_status option;
3131+ note : string option;
3232+ summary : string option;
3333+ tags : bookmark_tag list;
3434+ content : content;
3535+ assets : asset list;
3636+}
3737+3838+type paginated_bookmarks = {
3939+ bookmarks : bookmark list;
4040+ next_cursor : string option;
4141+}
4242+```
443544## Fetching Bookmarks
645746### `fetch_bookmarks`
84799-Fetch bookmarks from a Karakeep instance with pagination support.
4848+Fetch a page of bookmarks from a Karakeep instance.
10491150```ocaml
1212-val fetch_bookmarks :
1313- api_key:string ->
1414- ?limit:int ->
1515- ?offset:int ->
5151+val fetch_bookmarks :
5252+ api_key:string ->
5353+ ?limit:int ->
1654 ?cursor:string ->
1755 ?include_content:bool ->
1818- ?filter_tags:string list ->
1919- string ->
2020- bookmark_response Lwt.t
5656+ ?archived:bool ->
5757+ ?favourited:bool ->
5858+ string ->
5959+ paginated_bookmarks Lwt.t
2160```
22612362#### Parameters
24632564- `api_key`: API key for authentication
2665- `limit`: Number of bookmarks to fetch per page (default: 50)
2727-- `offset`: Starting index for pagination (0-based) (default: 0)
2828-- `cursor`: Optional pagination cursor for cursor-based pagination (overrides offset when provided)
6666+- `cursor`: Optional pagination cursor for cursor-based pagination
2967- `include_content`: Whether to include full content (default: true)
3030-- `filter_tags`: Optional list of tags to filter by
6868+- `archived`: Whether to filter for archived bookmarks
6969+- `favourited`: Whether to filter for favourited bookmarks
3170- `base_url`: Base URL of the Karakeep instance
32713372#### Example
···3675let fetch_recent =
3776 let api_key = "your_api_key" in
3877 let base_url = "https://hoard.recoil.org" in
3939- Karakeep.fetch_bookmarks ~api_key ~limit:10 base_url
7878+ let* response = Karakeep.fetch_bookmarks ~api_key ~limit:10 base_url in
7979+ Printf.printf "Fetched %d bookmarks\n" (List.length response.bookmarks);
8080+ Lwt.return_unit
4081```
41824283### `fetch_all_bookmarks`
43844444-Fetch all bookmarks from a Karakeep instance using pagination.
8585+Fetch all bookmarks from a Karakeep instance, automatically handling pagination.
45864687```ocaml
4747-val fetch_all_bookmarks :
4848- api_key:string ->
4949- ?page_size:int ->
5050- ?max_pages:int ->
5151- ?filter_tags:string list ->
5252- string ->
8888+val fetch_all_bookmarks :
8989+ api_key:string ->
9090+ ?page_size:int ->
9191+ ?max_pages:int ->
9292+ ?archived:bool ->
9393+ ?favourited:bool ->
9494+ string ->
5395 bookmark list Lwt.t
5496```
5597···58100- `api_key`: API key for authentication
59101- `page_size`: Number of bookmarks to fetch per page (default: 50)
60102- `max_pages`: Maximum number of pages to fetch (None for all pages)
6161-- `filter_tags`: Optional list of tags to filter by
103103+- `archived`: Whether to filter for archived bookmarks
104104+- `favourited`: Whether to filter for favourited bookmarks
62105- `base_url`: Base URL of the Karakeep instance
6310664107#### Example
6510866109```ocaml
6767-let fetch_all_with_tag_ocaml =
110110+let fetch_all_favourites =
68111 let api_key = "your_api_key" in
69112 let base_url = "https://hoard.recoil.org" in
7070- Karakeep.fetch_all_bookmarks ~api_key ~filter_tags:["ocaml"] base_url
113113+ let* bookmarks =
114114+ Karakeep.fetch_all_bookmarks
115115+ ~api_key
116116+ ~favourited:true
117117+ base_url in
118118+ Printf.printf "Fetched %d favourited bookmarks\n" (List.length bookmarks);
119119+ Lwt.return_unit
120120+```
121121+122122+### `search_bookmarks`
123123+124124+Search for bookmarks matching a query.
125125+126126+```ocaml
127127+val search_bookmarks :
128128+ api_key:string ->
129129+ query:string ->
130130+ ?limit:int ->
131131+ ?cursor:string ->
132132+ ?include_content:bool ->
133133+ string ->
134134+ paginated_bookmarks Lwt.t
135135+```
136136+137137+#### Parameters
138138+139139+- `api_key`: API key for authentication
140140+- `query`: Search query
141141+- `limit`: Number of bookmarks to fetch per page (default: 50)
142142+- `cursor`: Optional pagination cursor
143143+- `include_content`: Whether to include full content (default: true)
144144+- `base_url`: Base URL of the Karakeep instance
145145+146146+#### Example
147147+148148+```ocaml
149149+let search_for_ocaml =
150150+ let api_key = "your_api_key" in
151151+ let base_url = "https://hoard.recoil.org" in
152152+ let* results =
153153+ Karakeep.search_bookmarks
154154+ ~api_key
155155+ ~query:"ocaml programming"
156156+ base_url in
157157+ Printf.printf "Found %d results\n" (List.length results.bookmarks);
158158+ Lwt.return_unit
71159```
7216073161### `fetch_bookmark_details`
···75163Fetch detailed information for a single bookmark by ID.
7616477165```ocaml
7878-val fetch_bookmark_details :
7979- api_key:string ->
8080- string ->
8181- string ->
8282- bookmark Lwt.t
166166+val fetch_bookmark_details :
167167+ api_key:string -> string -> bookmark_id -> bookmark Lwt.t
83168```
8416985170#### Parameters
···95180 let api_key = "your_api_key" in
96181 let base_url = "https://hoard.recoil.org" in
97182 let bookmark_id = "123456" in
9898- Karakeep.fetch_bookmark_details ~api_key base_url bookmark_id
183183+ let* bookmark = Karakeep.fetch_bookmark_details ~api_key base_url bookmark_id in
184184+ Printf.printf "Fetched bookmark: %s\n"
185185+ (match bookmark.title with Some t -> t | None -> "Untitled");
186186+ Lwt.return_unit
99187```
100188101101-## Creating Bookmarks
189189+## Creating and Updating Bookmarks
102190103191### `create_bookmark`
104192105105-Create a new bookmark in Karakeep with optional tags.
193193+Create a new bookmark in Karakeep.
106194107195```ocaml
108196val create_bookmark :
···110198 url:string ->
111199 ?title:string ->
112200 ?note:string ->
113113- ?tags:string list ->
201201+ ?summary:string ->
114202 ?favourited:bool ->
115203 ?archived:bool ->
204204+ ?created_at:Ptime.t ->
205205+ ?tags:string list ->
116206 string ->
117207 bookmark Lwt.t
118208```
···123213- `url`: The URL to bookmark
124214- `title`: Optional title for the bookmark
125215- `note`: Optional note to add to the bookmark
126126-- `tags`: Optional list of tag names to add to the bookmark
216216+- `summary`: Optional summary for the bookmark
127217- `favourited`: Whether the bookmark should be marked as favourite (default: false)
128218- `archived`: Whether the bookmark should be archived (default: false)
219219+- `created_at`: Optional timestamp for when the bookmark was created
220220+- `tags`: Optional list of tag names to add to the bookmark
129221- `base_url`: Base URL of the Karakeep instance
130222131223#### Example
···134226let create_new_bookmark =
135227 let api_key = "your_api_key" in
136228 let base_url = "https://hoard.recoil.org" in
137137- Karakeep.create_bookmark
138138- ~api_key
139139- ~url:"https://ocaml.org"
140140- ~title:"OCaml Programming Language"
141141- ~tags:["programming"; "ocaml"; "functional"]
142142- base_url
229229+ let* bookmark =
230230+ Karakeep.create_bookmark
231231+ ~api_key
232232+ ~url:"https://ocaml.org"
233233+ ~title:"OCaml Programming Language"
234234+ ~tags:["programming"; "ocaml"; "functional"]
235235+ base_url in
236236+ Printf.printf "Created bookmark with ID: %s\n" bookmark.id;
237237+ Lwt.return_unit
238238+```
239239+240240+### `update_bookmark`
241241+242242+Update an existing bookmark.
243243+244244+```ocaml
245245+val update_bookmark :
246246+ api_key:string ->
247247+ ?title:string ->
248248+ ?note:string ->
249249+ ?summary:string ->
250250+ ?favourited:bool ->
251251+ ?archived:bool ->
252252+ ?url:string ->
253253+ ?description:string ->
254254+ ?author:string ->
255255+ ?publisher:string ->
256256+ ?date_published:Ptime.t ->
257257+ ?date_modified:Ptime.t ->
258258+ ?text:string ->
259259+ ?asset_content:string ->
260260+ string ->
261261+ bookmark_id ->
262262+ bookmark Lwt.t
263263+```
264264+265265+#### Parameters
266266+267267+- `api_key`: API key for authentication
268268+- `title`: Optional new title for the bookmark
269269+- `note`: Optional new note for the bookmark
270270+- `summary`: Optional new summary for the bookmark
271271+- `favourited`: Whether the bookmark should be marked as favourite
272272+- `archived`: Whether the bookmark should be archived
273273+- `url`: Optional new URL for the bookmark
274274+- `description`: Optional new description for the bookmark
275275+- `author`: Optional new author for the bookmark
276276+- `publisher`: Optional new publisher for the bookmark
277277+- `date_published`: Optional new publication date for the bookmark
278278+- `date_modified`: Optional new modification date for the bookmark
279279+- `text`: Optional new text content for the bookmark
280280+- `asset_content`: Optional new asset content for the bookmark
281281+- `base_url`: Base URL of the Karakeep instance
282282+- `bookmark_id`: ID of the bookmark to update
283283+284284+#### Example
285285+286286+```ocaml
287287+let update_bookmark_title =
288288+ let api_key = "your_api_key" in
289289+ let base_url = "https://hoard.recoil.org" in
290290+ let bookmark_id = "123456" in
291291+ let* updated =
292292+ Karakeep.update_bookmark
293293+ ~api_key
294294+ ~title:"Updated OCaml Programming Language"
295295+ ~favourited:true
296296+ base_url
297297+ bookmark_id in
298298+ Printf.printf "Updated bookmark title to: %s\n"
299299+ (match updated.title with Some t -> t | None -> "Untitled");
300300+ Lwt.return_unit
143301```
302302+303303+### `delete_bookmark`
304304+305305+Delete a bookmark by its ID.
306306+307307+```ocaml
308308+val delete_bookmark : api_key:string -> string -> bookmark_id -> unit Lwt.t
309309+```
310310+311311+#### Parameters
312312+313313+- `api_key`: API key for authentication
314314+- `base_url`: Base URL of the Karakeep instance
315315+- `bookmark_id`: ID of the bookmark to delete
316316+317317+#### Example
318318+319319+```ocaml
320320+let delete_bookmark =
321321+ let api_key = "your_api_key" in
322322+ let base_url = "https://hoard.recoil.org" in
323323+ let bookmark_id = "123456" in
324324+ let* () = Karakeep.delete_bookmark ~api_key base_url bookmark_id in
325325+ Printf.printf "Deleted bookmark successfully\n";
326326+ Lwt.return_unit
327327+```
328328+329329+### `summarize_bookmark`
330330+331331+Generate a summary for a bookmark using AI.
332332+333333+```ocaml
334334+val summarize_bookmark :
335335+ api_key:string -> string -> bookmark_id -> bookmark Lwt.t
336336+```
337337+338338+#### Parameters
339339+340340+- `api_key`: API key for authentication
341341+- `base_url`: Base URL of the Karakeep instance
342342+- `bookmark_id`: ID of the bookmark to summarize
343343+344344+#### Example
345345+346346+```ocaml
347347+let summarize_bookmark =
348348+ let api_key = "your_api_key" in
349349+ let base_url = "https://hoard.recoil.org" in
350350+ let bookmark_id = "123456" in
351351+ let* bookmark = Karakeep.summarize_bookmark ~api_key base_url bookmark_id in
352352+ Printf.printf "Generated summary: %s\n"
353353+ (match bookmark.summary with Some s -> s | None -> "No summary generated");
354354+ Lwt.return_unit
355355+```
+179-24
doc/types.md
···11# Karakeep Types
2233-This document describes the main types used in the Karakeep OCaml client.
33+This document describes the main types used in the Karakeep OCL client.
4455-## Bookmark
55+## Core Types
6677-Represents a single bookmark in Karakeep.
77+### Identifiers
8899```ocaml
1010+type asset_id = string
1111+type bookmark_id = string
1212+type list_id = string
1313+type tag_id = string
1414+type highlight_id = string
1515+```
1616+1717+These types are used to represent the unique identifiers for various resources in the Karakeep API.
1818+1919+### Enumerations
2020+2121+```ocaml
2222+type bookmark_content_type =
2323+ | Link (* A URL to a webpage *)
2424+ | Text (* Plain text content *)
2525+ | Asset (* An attached asset (image, PDF, etc.) *)
2626+ | Unknown (* Unknown content type *)
2727+2828+type asset_type =
2929+ | Screenshot (* Screenshot of a webpage *)
3030+ | AssetScreenshot (* Screenshot of an asset *)
3131+ | BannerImage (* Banner image *)
3232+ | FullPageArchive (* Archive of a full webpage *)
3333+ | Video (* Video asset *)
3434+ | BookmarkAsset (* Generic bookmark asset *)
3535+ | PrecrawledArchive (* Pre-crawled archive *)
3636+ | Unknown (* Unknown asset type *)
3737+3838+type tagging_status =
3939+ | Success (* Tagging was successful *)
4040+ | Failure (* Tagging failed *)
4141+ | Pending (* Tagging is pending *)
4242+4343+type list_type =
4444+ | Manual (* List is manually managed *)
4545+ | Smart (* List is dynamically generated based on a query *)
4646+4747+type highlight_color =
4848+ | Yellow (* Yellow highlight *)
4949+ | Red (* Red highlight *)
5050+ | Green (* Green highlight *)
5151+ | Blue (* Blue highlight *)
5252+5353+type tag_attachment_type =
5454+ | AI (* Tag was attached by AI *)
5555+ | Human (* Tag was attached by a human *)
5656+```
5757+5858+### Content Types
5959+6060+```ocaml
6161+type link_content = {
6262+ url : string;
6363+ title : string option;
6464+ description : string option;
6565+ image_url : string option;
6666+ image_asset_id : asset_id option;
6767+ screenshot_asset_id : asset_id option;
6868+ full_page_archive_asset_id : asset_id option;
6969+ precrawled_archive_asset_id : asset_id option;
7070+ video_asset_id : asset_id option;
7171+ favicon : string option;
7272+ html_content : string option;
7373+ crawled_at : Ptime.t option;
7474+ author : string option;
7575+ publisher : string option;
7676+ date_published : Ptime.t option;
7777+ date_modified : Ptime.t option;
7878+}
7979+8080+type text_content = {
8181+ text : string;
8282+ source_url : string option;
8383+}
8484+8585+type asset_content = {
8686+ asset_type : [ `Image | `PDF ];
8787+ asset_id : asset_id;
8888+ file_name : string option;
8989+ source_url : string option;
9090+ size : int option;
9191+ content : string option;
9292+}
9393+9494+type content =
9595+ | Link of link_content
9696+ | Text of text_content
9797+ | Asset of asset_content
9898+ | Unknown
9999+```
100100+101101+### Resource Types
102102+103103+```ocaml
104104+type asset = {
105105+ id : asset_id;
106106+ asset_type : asset_type;
107107+}
108108+109109+type bookmark_tag = {
110110+ id : tag_id;
111111+ name : string;
112112+ attached_by : tag_attachment_type;
113113+}
114114+10115type bookmark = {
1111- id: string;
1212- title: string option;
1313- url: string;
1414- note: string option;
1515- created_at: Ptime.t;
1616- updated_at: Ptime.t option;
1717- favourited: bool;
1818- archived: bool;
1919- tags: string list;
2020- tagging_status: string option;
2121- summary: string option;
2222- content: (string * string) list;
2323- assets: (string * string) list;
116116+ id : bookmark_id;
117117+ created_at : Ptime.t;
118118+ modified_at : Ptime.t option;
119119+ title : string option;
120120+ archived : bool;
121121+ favourited : bool;
122122+ tagging_status : tagging_status option;
123123+ note : string option;
124124+ summary : string option;
125125+ tags : bookmark_tag list;
126126+ content : content;
127127+ assets : asset list;
128128+}
129129+130130+type paginated_bookmarks = {
131131+ bookmarks : bookmark list;
132132+ next_cursor : string option;
133133+}
134134+135135+type list = {
136136+ id : list_id;
137137+ name : string;
138138+ description : string option;
139139+ icon : string;
140140+ parent_id : list_id option;
141141+ list_type : list_type;
142142+ query : string option;
143143+}
144144+145145+type tag = {
146146+ id : tag_id;
147147+ name : string;
148148+ num_bookmarks : int;
149149+ num_bookmarks_by_attached_type : (tag_attachment_type * int) list;
150150+}
151151+152152+type highlight = {
153153+ bookmark_id : bookmark_id;
154154+ start_offset : int;
155155+ end_offset : int;
156156+ color : highlight_color;
157157+ text : string option;
158158+ note : string option;
159159+ id : highlight_id;
160160+ user_id : string;
161161+ created_at : Ptime.t;
162162+}
163163+164164+type paginated_highlights = {
165165+ highlights : highlight list;
166166+ next_cursor : string option;
24167}
25168```
261692727-## Bookmark Response
2828-2929-Represents a paginated response from the Karakeep API containing bookmarks.
170170+### User Information
3017131172```ocaml
3232-type bookmark_response = {
3333- total: int;
3434- data: bookmark list;
3535- next_cursor: string option;
173173+type user_info = {
174174+ id : string;
175175+ name : string option;
176176+ email : string option;
177177+}
178178+179179+type user_stats = {
180180+ num_bookmarks : int;
181181+ num_favorites : int;
182182+ num_archived : int;
183183+ num_tags : int;
184184+ num_lists : int;
185185+ num_highlights : int;
186186+}
187187+188188+type error_response = {
189189+ code : string;
190190+ message : string;
36191}
37192```
381933939-See [Bookmarks](bookmarks.md) for more information on how to use these types.
194194+For more information about how to use these types with the API functions, see the [API documentation](index.md).
+739-84
lib/karakeep.mli
···4242 All operations require an API key that can be obtained from your Karakeep
4343 instance. *)
44444545+(** {1 Core Types} *)
4646+4747+(** Asset identifier type *)
4848+type asset_id = string
4949+5050+(** Bookmark identifier type *)
5151+type bookmark_id = string
5252+5353+(** List identifier type *)
5454+type list_id = string
5555+5656+(** Tag identifier type *)
5757+type tag_id = string
5858+5959+(** Highlight identifier type *)
6060+type highlight_id = string
6161+6262+(** Type of content a bookmark can have *)
6363+type bookmark_content_type =
6464+ | Link (** A URL to a webpage *)
6565+ | Text (** Plain text content *)
6666+ | Asset (** An attached asset (image, PDF, etc.) *)
6767+ | Unknown (** Unknown content type *)
6868+6969+(** Type of asset *)
7070+type asset_type =
7171+ | Screenshot (** Screenshot of a webpage *)
7272+ | AssetScreenshot (** Screenshot of an asset *)
7373+ | BannerImage (** Banner image *)
7474+ | FullPageArchive (** Archive of a full webpage *)
7575+ | Video (** Video asset *)
7676+ | BookmarkAsset (** Generic bookmark asset *)
7777+ | PrecrawledArchive (** Pre-crawled archive *)
7878+ | Unknown (** Unknown asset type *)
7979+8080+(** Type of tagging status *)
8181+type tagging_status =
8282+ | Success (** Tagging was successful *)
8383+ | Failure (** Tagging failed *)
8484+ | Pending (** Tagging is pending *)
8585+8686+(** Type of bookmark list *)
8787+type list_type =
8888+ | Manual (** List is manually managed *)
8989+ | Smart (** List is dynamically generated based on a query *)
9090+9191+(** Highlight color *)
9292+type highlight_color =
9393+ | Yellow (** Yellow highlight *)
9494+ | Red (** Red highlight *)
9595+ | Green (** Green highlight *)
9696+ | Blue (** Blue highlight *)
9797+9898+(** Type of how a tag was attached *)
9999+type tag_attachment_type =
100100+ | AI (** Tag was attached by AI *)
101101+ | Human (** Tag was attached by a human *)
102102+103103+(** Link content for a bookmark *)
104104+type link_content = {
105105+ url : string; (** The URL of the bookmarked page *)
106106+ title : string option; (** Title from the link *)
107107+ description : string option; (** Description from the link *)
108108+ image_url : string option; (** URL of an image from the link *)
109109+ image_asset_id : asset_id option; (** ID of an image asset *)
110110+ screenshot_asset_id : asset_id option; (** ID of a screenshot asset *)
111111+ full_page_archive_asset_id : asset_id option;
112112+ (** ID of a full page archive asset *)
113113+ precrawled_archive_asset_id : asset_id option;
114114+ (** ID of a pre-crawled archive asset *)
115115+ video_asset_id : asset_id option; (** ID of a video asset *)
116116+ favicon : string option; (** URL of the favicon *)
117117+ html_content : string option; (** HTML content of the page *)
118118+ crawled_at : Ptime.t option; (** When the page was crawled *)
119119+ author : string option; (** Author of the content *)
120120+ publisher : string option; (** Publisher of the content *)
121121+ date_published : Ptime.t option; (** When the content was published *)
122122+ date_modified : Ptime.t option; (** When the content was last modified *)
123123+}
124124+125125+(** Text content for a bookmark *)
126126+type text_content = {
127127+ text : string; (** The text content *)
128128+ source_url : string option; (** Optional source URL for the text *)
129129+}
130130+131131+(** Asset content for a bookmark *)
132132+type asset_content = {
133133+ asset_type : [ `Image | `PDF ]; (** Type of the asset *)
134134+ asset_id : asset_id; (** ID of the asset *)
135135+ file_name : string option; (** Name of the file *)
136136+ source_url : string option; (** Source URL for the asset *)
137137+ size : int option; (** Size of the asset in bytes *)
138138+ content : string option; (** Extracted content from the asset *)
139139+}
140140+141141+(** Content of a bookmark *)
142142+type content =
143143+ | Link of link_content (** Link-type content *)
144144+ | Text of text_content (** Text-type content *)
145145+ | Asset of asset_content (** Asset-type content *)
146146+ | Unknown (** Unknown content type *)
147147+148148+(** Asset attached to a bookmark *)
149149+type asset = {
150150+ id : asset_id; (** ID of the asset *)
151151+ asset_type : asset_type; (** Type of the asset *)
152152+}
153153+154154+(** Tag with attachment information *)
155155+type bookmark_tag = {
156156+ id : tag_id; (** ID of the tag *)
157157+ name : string; (** Name of the tag *)
158158+ attached_by : tag_attachment_type; (** How the tag was attached *)
159159+}
160160+161161+(** A bookmark from the Karakeep service *)
45162type bookmark = {
4646- id : string; (** Unique identifier for the bookmark *)
163163+ id : bookmark_id; (** Unique identifier for the bookmark *)
164164+ created_at : Ptime.t; (** Timestamp when the bookmark was created *)
165165+ modified_at : Ptime.t option; (** Optional timestamp of the last update *)
47166 title : string option; (** Optional title of the bookmarked page *)
4848- url : string; (** URL of the bookmarked page *)
4949- note : string option; (** Optional user note associated with the bookmark *)
5050- created_at : Ptime.t; (** Timestamp when the bookmark was created *)
5151- updated_at : Ptime.t option; (** Optional timestamp of the last update *)
167167+ archived : bool; (** Whether the bookmark is archived *)
52168 favourited : bool; (** Whether the bookmark is marked as a favorite *)
5353- archived : bool; (** Whether the bookmark is archived *)
5454- tags : string list; (** List of tags associated with the bookmark *)
5555- tagging_status : string option; (** Optional status of automatic tagging *)
169169+ tagging_status : tagging_status option; (** Status of automatic tagging *)
170170+ note : string option; (** Optional user note associated with the bookmark *)
56171 summary : string option; (** Optional AI-generated summary *)
5757- content : (string * string) list;
5858- (** List of key-value pairs with content metadata *)
5959- assets : (string * string) list;
6060- (** List of (id, type) pairs for associated assets *)
172172+ tags : bookmark_tag list; (** Tags associated with the bookmark *)
173173+ content : content; (** Content of the bookmark *)
174174+ assets : asset list; (** Assets attached to the bookmark *)
61175}
6262-(** Type representing a Karakeep bookmark. Each bookmark contains metadata and
6363- content information from the Karakeep service. *)
641766565-type bookmark_response = {
6666- total : int; (** Total number of bookmarks available *)
6767- data : bookmark list; (** List of bookmarks in the current page *)
177177+(** Paginated response of bookmarks *)
178178+type paginated_bookmarks = {
179179+ bookmarks : bookmark list; (** List of bookmarks in the current page *)
68180 next_cursor : string option; (** Optional cursor for fetching the next page *)
69181}
7070-(** Type for Karakeep API response containing bookmarks. This represents a page
7171- of results from the Karakeep API. *)
721827373-val parse_bookmark : Ezjsonm.value -> bookmark
7474-(** [parse_bookmark json] parses a single bookmark from Karakeep JSON.
183183+(** List in Karakeep *)
184184+type _list = {
185185+ id : list_id; (** ID of the list *)
186186+ name : string; (** Name of the list *)
187187+ description : string option; (** Optional description of the list *)
188188+ icon : string; (** Icon for the list *)
189189+ parent_id : list_id option; (** Optional parent list ID *)
190190+ list_type : list_type; (** Type of the list *)
191191+ query : string option; (** Optional query for smart lists *)
192192+}
751937676- This is an internal function used to parse bookmark data from the Karakeep
7777- API. Most users will not need to call this directly.
194194+(** Tag in Karakeep *)
195195+type tag = {
196196+ id : tag_id; (** ID of the tag *)
197197+ name : string; (** Name of the tag *)
198198+ num_bookmarks : int; (** Number of bookmarks with this tag *)
199199+ num_bookmarks_by_attached_type : (tag_attachment_type * int) list; (** Number of bookmarks by attachment type *)
200200+}
782017979- @param json Ezjsonm value representing a bookmark
8080- @return The parsed bookmark record *)
202202+(** Highlight in Karakeep *)
203203+type highlight = {
204204+ bookmark_id : bookmark_id; (** ID of the bookmark *)
205205+ start_offset : int; (** Start position of the highlight *)
206206+ end_offset : int; (** End position of the highlight *)
207207+ color : highlight_color; (** Color of the highlight *)
208208+ text : string option; (** Text of the highlight *)
209209+ note : string option; (** Note for the highlight *)
210210+ id : highlight_id; (** ID of the highlight *)
211211+ user_id : string; (** ID of the user who created the highlight *)
212212+ created_at : Ptime.t; (** When the highlight was created *)
213213+}
812148282-val parse_bookmark_response : Ezjsonm.value -> bookmark_response
8383-(** [parse_bookmark_response json] parses a Karakeep API response containing
8484- bookmarks.
215215+(** Paginated response of highlights *)
216216+type paginated_highlights = {
217217+ highlights : highlight list; (** List of highlights in the current page *)
218218+ next_cursor : string option; (** Optional cursor for fetching the next page *)
219219+}
852208686- This is an internal function used to parse response data from the Karakeep
8787- API. Most users will not need to call this directly.
221221+(** User information *)
222222+type user_info = {
223223+ id : string; (** ID of the user *)
224224+ name : string option; (** Name of the user *)
225225+ email : string option; (** Email of the user *)
226226+}
882278989- @param json Ezjsonm value representing a bookmark response
9090- @return The parsed bookmark_response record *)
228228+(** User statistics *)
229229+type user_stats = {
230230+ num_bookmarks : int; (** Number of bookmarks *)
231231+ num_favorites : int; (** Number of favorite bookmarks *)
232232+ num_archived : int; (** Number of archived bookmarks *)
233233+ num_tags : int; (** Number of tags *)
234234+ num_lists : int; (** Number of lists *)
235235+ num_highlights : int; (** Number of highlights *)
236236+}
237237+238238+(** Error response from the API *)
239239+type error_response = {
240240+ code : string; (** Error code *)
241241+ message : string; (** Error message *)
242242+}
243243+244244+(** {1 Bookmark Operations} *)
9124592246val fetch_bookmarks :
93247 api_key:string ->
94248 ?limit:int ->
9595- ?offset:int ->
96249 ?cursor:string ->
97250 ?include_content:bool ->
9898- ?filter_tags:string list ->
251251+ ?archived:bool ->
252252+ ?favourited:bool ->
99253 string ->
100100- bookmark_response Lwt.t
101101-(** [fetch_bookmarks ~api_key ?limit ?offset ?cursor ?include_content
102102- ?filter_tags base_url] fetches a single page of bookmarks from a Karakeep
103103- instance.
104104-105105- This function provides fine-grained control over pagination with offset or
106106- cursor-based pagination. It returns a {!bookmark_response} that includes
107107- pagination information like total count and next cursor.
254254+ paginated_bookmarks Lwt.t
255255+(** [fetch_bookmarks ~api_key ?limit ?cursor ?include_content ?archived
256256+ ?favourited base_url] fetches a page of bookmarks from a Karakeep instance.
108257109109- Use this function when you need to:
110110- - Control pagination manually
111111- - Process results one page at a time
112112- - Access pagination metadata
258258+ This function provides fine-grained control over pagination with
259259+ cursor-based pagination. It returns a {!paginated_bookmarks} that includes
260260+ pagination information like the next cursor.
113261114262 @param api_key API key for authentication
115263 @param limit Number of bookmarks to fetch per page (default: 50)
116116- @param offset Starting index for pagination (0-based) (default: 0)
117117- @param cursor
118118- Optional pagination cursor for cursor-based pagination (overrides offset
119119- when provided)
264264+ @param cursor Optional pagination cursor for cursor-based pagination
120265 @param include_content Whether to include full content (default: true)
121121- @param filter_tags Optional list of tags to filter by
266266+ @param archived Whether to filter for archived bookmarks
267267+ @param favourited Whether to filter for favourited bookmarks
122268 @param base_url Base URL of the Karakeep instance
123269 @return
124270 A Lwt promise with the bookmark response containing a single page of
···128274 api_key:string ->
129275 ?page_size:int ->
130276 ?max_pages:int ->
131131- ?filter_tags:string list ->
277277+ ?archived:bool ->
278278+ ?favourited:bool ->
132279 string ->
133280 bookmark list Lwt.t
134134-(** [fetch_all_bookmarks ~api_key ?page_size ?max_pages ?filter_tags base_url]
135135- fetches all bookmarks from a Karakeep instance, automatically handling
136136- pagination.
281281+(** [fetch_all_bookmarks ~api_key ?page_size ?max_pages ?archived ?favourited
282282+ base_url] fetches all bookmarks from a Karakeep instance, automatically
283283+ handling pagination.
137284138285 This function handles pagination internally and returns a flattened list of
139286 all bookmarks. It will continue making API requests until all pages have
···147294 @param api_key API key for authentication
148295 @param page_size Number of bookmarks to fetch per page (default: 50)
149296 @param max_pages Maximum number of pages to fetch (None for all pages)
150150- @param filter_tags Optional list of tags to filter by
297297+ @param archived Whether to filter for archived bookmarks
298298+ @param favourited Whether to filter for favourited bookmarks
151299 @param base_url Base URL of the Karakeep instance
152300 @return A Lwt promise with all bookmarks combined into a single list *)
153301302302+val search_bookmarks :
303303+ api_key:string ->
304304+ query:string ->
305305+ ?limit:int ->
306306+ ?cursor:string ->
307307+ ?include_content:bool ->
308308+ string ->
309309+ paginated_bookmarks Lwt.t
310310+(** [search_bookmarks ~api_key ~query ?limit ?cursor ?include_content base_url]
311311+ searches for bookmarks matching a query.
312312+313313+ @param api_key API key for authentication
314314+ @param query Search query
315315+ @param limit Number of bookmarks to fetch per page (default: 50)
316316+ @param cursor Optional pagination cursor
317317+ @param include_content Whether to include full content (default: true)
318318+ @param base_url Base URL of the Karakeep instance
319319+ @return
320320+ A Lwt promise with the bookmark response containing search results *)
321321+154322val fetch_bookmark_details :
155155- api_key:string -> string -> string -> bookmark Lwt.t
323323+ api_key:string -> string -> bookmark_id -> bookmark Lwt.t
156324(** [fetch_bookmark_details ~api_key base_url bookmark_id] fetches detailed
157325 information for a single bookmark by ID.
158326···165333 @param bookmark_id ID of the bookmark to fetch
166334 @return A Lwt promise with the complete bookmark details *)
167335168168-val fetch_asset : api_key:string -> string -> string -> string Lwt.t
169169-(** [fetch_asset ~api_key base_url asset_id] fetches an asset from the Karakeep
170170- server as a binary string.
171171-172172- Assets can include images, PDFs, or other files attached to bookmarks. This
173173- function retrieves the binary content of an asset by its ID.
174174-175175- @param api_key API key for authentication
176176- @param base_url Base URL of the Karakeep instance
177177- @param asset_id ID of the asset to fetch
178178- @return A Lwt promise with the binary asset data *)
179179-180180-val get_asset_url : string -> string -> string
181181-(** [get_asset_url base_url asset_id] returns the full URL for a given asset ID.
182182-183183- This is a pure function that constructs the URL for an asset without making
184184- any API calls. The returned URL can be used to access the asset directly,
185185- assuming proper authentication.
186186-187187- @param base_url Base URL of the Karakeep instance
188188- @param asset_id ID of the asset
189189- @return The full URL to the asset *)
190190-191336val create_bookmark :
192337 api_key:string ->
193338 url:string ->
194339 ?title:string ->
195340 ?note:string ->
196196- ?tags:string list ->
341341+ ?summary:string ->
197342 ?favourited:bool ->
198343 ?archived:bool ->
344344+ ?created_at:Ptime.t ->
345345+ ?tags:string list ->
199346 string ->
200347 bookmark Lwt.t
201201-(** [create_bookmark ~api_key ~url ?title ?note ?tags ?favourited ?archived
202202- base_url] creates a new bookmark in Karakeep.
348348+(** [create_bookmark ~api_key ~url ?title ?note ?summary ?favourited ?archived
349349+ ?created_at ?tags base_url] creates a new bookmark in Karakeep.
203350204351 This function adds a new bookmark to the Karakeep instance for the given
205352 URL. It supports setting various bookmark attributes and adding tags.
···217364 @param url The URL to bookmark
218365 @param title Optional title for the bookmark
219366 @param note Optional note to add to the bookmark
220220- @param tags Optional list of tag names to add to the bookmark
367367+ @param summary Optional summary for the bookmark
221368 @param favourited
222369 Whether the bookmark should be marked as favourite (default: false)
223370 @param archived Whether the bookmark should be archived (default: false)
371371+ @param created_at Optional timestamp for when the bookmark was created
372372+ @param tags Optional list of tag names to add to the bookmark
224373 @param base_url Base URL of the Karakeep instance
225374 @return A Lwt promise with the created bookmark *)
375375+376376+val update_bookmark :
377377+ api_key:string ->
378378+ ?title:string ->
379379+ ?note:string ->
380380+ ?summary:string ->
381381+ ?favourited:bool ->
382382+ ?archived:bool ->
383383+ ?url:string ->
384384+ ?description:string ->
385385+ ?author:string ->
386386+ ?publisher:string ->
387387+ ?date_published:Ptime.t ->
388388+ ?date_modified:Ptime.t ->
389389+ ?text:string ->
390390+ ?asset_content:string ->
391391+ string ->
392392+ bookmark_id ->
393393+ bookmark Lwt.t
394394+(** [update_bookmark ~api_key ?title ?note ?summary ?favourited ?archived ?url
395395+ ?description ?author ?publisher ?date_published ?date_modified ?text
396396+ ?asset_content base_url bookmark_id] updates a bookmark by its ID.
397397+398398+ This function updates various attributes of an existing bookmark. Only the
399399+ fields provided will be updated.
400400+401401+ @param api_key API key for authentication
402402+ @param title Optional new title for the bookmark
403403+ @param note Optional new note for the bookmark
404404+ @param summary Optional new summary for the bookmark
405405+ @param favourited Whether the bookmark should be marked as favourite
406406+ @param archived Whether the bookmark should be archived
407407+ @param url Optional new URL for the bookmark
408408+ @param description Optional new description for the bookmark
409409+ @param author Optional new author for the bookmark
410410+ @param publisher Optional new publisher for the bookmark
411411+ @param date_published Optional new publication date for the bookmark
412412+ @param date_modified Optional new modification date for the bookmark
413413+ @param text Optional new text content for the bookmark
414414+ @param asset_content Optional new asset content for the bookmark
415415+ @param base_url Base URL of the Karakeep instance
416416+ @param bookmark_id ID of the bookmark to update
417417+ @return A Lwt promise with the updated bookmark details *)
418418+419419+val delete_bookmark : api_key:string -> string -> bookmark_id -> unit Lwt.t
420420+(** [delete_bookmark ~api_key base_url bookmark_id] deletes a bookmark by its
421421+ ID.
422422+423423+ This function permanently removes a bookmark from the Karakeep instance.
424424+425425+ @param api_key API key for authentication
426426+ @param base_url Base URL of the Karakeep instance
427427+ @param bookmark_id ID of the bookmark to delete
428428+ @return A Lwt promise that completes when the bookmark is deleted *)
429429+430430+val summarize_bookmark :
431431+ api_key:string -> string -> bookmark_id -> bookmark Lwt.t
432432+(** [summarize_bookmark ~api_key base_url bookmark_id] generates a summary for a
433433+ bookmark.
434434+435435+ This function uses AI to generate a summary of the bookmark's content. The
436436+ summary is added to the bookmark.
437437+438438+ @param api_key API key for authentication
439439+ @param base_url Base URL of the Karakeep instance
440440+ @param bookmark_id ID of the bookmark to summarize
441441+ @return A Lwt promise with the updated bookmark including the summary *)
442442+443443+(** {1 Tag Operations} *)
444444+445445+val attach_tags :
446446+ api_key:string ->
447447+ tag_refs:[ `TagId of tag_id | `TagName of string ] list ->
448448+ string ->
449449+ bookmark_id ->
450450+ tag_id list Lwt.t
451451+(** [attach_tags ~api_key ~tag_refs base_url bookmark_id] attaches tags to a
452452+ bookmark.
453453+454454+ This function adds one or more tags to a bookmark. Tags can be referred to
455455+ either by their ID or by their name. If a tag name is provided and the tag
456456+ doesn't exist, it will be created.
457457+458458+ @param api_key API key for authentication
459459+ @param tag_refs List of tag references (either by ID or name)
460460+ @param base_url Base URL of the Karakeep instance
461461+ @param bookmark_id ID of the bookmark to tag
462462+ @return A Lwt promise with the list of attached tag IDs *)
463463+464464+val detach_tags :
465465+ api_key:string ->
466466+ tag_refs:[ `TagId of tag_id | `TagName of string ] list ->
467467+ string ->
468468+ bookmark_id ->
469469+ tag_id list Lwt.t
470470+(** [detach_tags ~api_key ~tag_refs base_url bookmark_id] detaches tags from a
471471+ bookmark.
472472+473473+ This function removes one or more tags from a bookmark. Tags can be referred
474474+ to either by their ID or by their name.
475475+476476+ @param api_key API key for authentication
477477+ @param tag_refs List of tag references (either by ID or name)
478478+ @param base_url Base URL of the Karakeep instance
479479+ @param bookmark_id ID of the bookmark to remove tags from
480480+ @return A Lwt promise with the list of detached tag IDs *)
481481+482482+val fetch_all_tags : api_key:string -> string -> tag list Lwt.t
483483+(** [fetch_all_tags ~api_key base_url] fetches all tags.
484484+485485+ This function retrieves all tags from the Karakeep instance.
486486+487487+ @param api_key API key for authentication
488488+ @param base_url Base URL of the Karakeep instance
489489+ @return A Lwt promise with the list of all tags *)
490490+491491+val fetch_tag_details : api_key:string -> string -> tag_id -> tag Lwt.t
492492+(** [fetch_tag_details ~api_key base_url tag_id] fetches detailed information
493493+ for a single tag by ID.
494494+495495+ This function retrieves complete details for a specific tag identified by
496496+ its ID.
497497+498498+ @param api_key API key for authentication
499499+ @param base_url Base URL of the Karakeep instance
500500+ @param tag_id ID of the tag to fetch
501501+ @return A Lwt promise with the complete tag details *)
502502+503503+val fetch_bookmarks_with_tag :
504504+ api_key:string ->
505505+ ?limit:int ->
506506+ ?cursor:string ->
507507+ ?include_content:bool ->
508508+ string ->
509509+ tag_id ->
510510+ paginated_bookmarks Lwt.t
511511+(** [fetch_bookmarks_with_tag ~api_key ?limit ?cursor ?include_content base_url
512512+ tag_id] fetches bookmarks with a specific tag.
513513+514514+ This function retrieves bookmarks that have been tagged with a specific tag.
515515+516516+ @param api_key API key for authentication
517517+ @param limit Number of bookmarks to fetch per page (default: 50)
518518+ @param cursor Optional pagination cursor
519519+ @param include_content Whether to include full content (default: true)
520520+ @param base_url Base URL of the Karakeep instance
521521+ @param tag_id ID of the tag to filter by
522522+ @return
523523+ A Lwt promise with the bookmark response containing bookmarks with the tag *)
524524+525525+val update_tag :
526526+ api_key:string -> name:string -> string -> tag_id -> tag Lwt.t
527527+(** [update_tag ~api_key ~name base_url tag_id] updates a tag's name.
528528+529529+ This function changes the name of an existing tag.
530530+531531+ @param api_key API key for authentication
532532+ @param name New name for the tag
533533+ @param base_url Base URL of the Karakeep instance
534534+ @param tag_id ID of the tag to update
535535+ @return A Lwt promise with the updated tag details *)
536536+537537+val delete_tag : api_key:string -> string -> tag_id -> unit Lwt.t
538538+(** [delete_tag ~api_key base_url tag_id] deletes a tag by its ID.
539539+540540+ This function permanently removes a tag from the Karakeep instance and
541541+ detaches it from all bookmarks.
542542+543543+ @param api_key API key for authentication
544544+ @param base_url Base URL of the Karakeep instance
545545+ @param tag_id ID of the tag to delete
546546+ @return A Lwt promise that completes when the tag is deleted *)
547547+548548+(** {1 List Operations} *)
549549+550550+val fetch_all_lists : api_key:string -> string -> _list list Lwt.t
551551+(** [fetch_all_lists ~api_key base_url] fetches all lists.
552552+553553+ This function retrieves all lists from the Karakeep instance.
554554+555555+ @param api_key API key for authentication
556556+ @param base_url Base URL of the Karakeep instance
557557+ @return A Lwt promise with the list of all lists *)
558558+559559+val fetch_list_details : api_key:string -> string -> list_id -> _list Lwt.t
560560+(** [fetch_list_details ~api_key base_url list_id] fetches detailed information
561561+ for a single list by ID.
562562+563563+ This function retrieves complete details for a specific list identified by
564564+ its ID.
565565+566566+ @param api_key API key for authentication
567567+ @param base_url Base URL of the Karakeep instance
568568+ @param list_id ID of the list to fetch
569569+ @return A Lwt promise with the complete list details *)
570570+571571+val create_list :
572572+ api_key:string ->
573573+ name:string ->
574574+ icon:string ->
575575+ ?description:string ->
576576+ ?parent_id:list_id ->
577577+ ?list_type:list_type ->
578578+ ?query:string ->
579579+ string ->
580580+ _list Lwt.t
581581+(** [create_list ~api_key ~name ~icon ?description ?parent_id ?list_type ?query
582582+ base_url] creates a new list in Karakeep.
583583+584584+ This function adds a new list to the Karakeep instance. Lists can be
585585+ hierarchical with parent-child relationships, and can be either manual or
586586+ smart (query-based).
587587+588588+ @param api_key API key for authentication
589589+ @param name Name of the list (max 40 characters)
590590+ @param icon Icon for the list
591591+ @param description Optional description for the list (max 100 characters)
592592+ @param parent_id Optional parent list ID for hierarchical organization
593593+ @param list_type Type of the list (default: Manual)
594594+ @param query Optional query string for smart lists
595595+ @param base_url Base URL of the Karakeep instance
596596+ @return A Lwt promise with the created list *)
597597+598598+val update_list :
599599+ api_key:string ->
600600+ ?name:string ->
601601+ ?description:string ->
602602+ ?icon:string ->
603603+ ?parent_id:list_id option ->
604604+ ?query:string ->
605605+ string ->
606606+ list_id ->
607607+ _list Lwt.t
608608+(** [update_list ~api_key ?name ?description ?icon ?parent_id ?query base_url
609609+ list_id] updates a list by its ID.
610610+611611+ This function updates various attributes of an existing list. Only the
612612+ fields provided will be updated.
613613+614614+ @param api_key API key for authentication
615615+ @param name Optional new name for the list
616616+ @param description Optional new description for the list
617617+ @param icon Optional new icon for the list
618618+ @param parent_id
619619+ Optional new parent list ID (use None to remove the parent)
620620+ @param query Optional new query for smart lists
621621+ @param base_url Base URL of the Karakeep instance
622622+ @param list_id ID of the list to update
623623+ @return A Lwt promise with the updated list details *)
624624+625625+val delete_list : api_key:string -> string -> list_id -> unit Lwt.t
626626+(** [delete_list ~api_key base_url list_id] deletes a list by its ID.
627627+628628+ This function permanently removes a list from the Karakeep instance. Note
629629+ that this does not delete the bookmarks in the list.
630630+631631+ @param api_key API key for authentication
632632+ @param base_url Base URL of the Karakeep instance
633633+ @param list_id ID of the list to delete
634634+ @return A Lwt promise that completes when the list is deleted *)
635635+636636+val fetch_bookmarks_in_list :
637637+ api_key:string ->
638638+ ?limit:int ->
639639+ ?cursor:string ->
640640+ ?include_content:bool ->
641641+ string ->
642642+ list_id ->
643643+ paginated_bookmarks Lwt.t
644644+(** [fetch_bookmarks_in_list ~api_key ?limit ?cursor ?include_content base_url
645645+ list_id] fetches bookmarks in a specific list.
646646+647647+ This function retrieves bookmarks that have been added to a specific list.
648648+649649+ @param api_key API key for authentication
650650+ @param limit Number of bookmarks to fetch per page (default: 50)
651651+ @param cursor Optional pagination cursor
652652+ @param include_content Whether to include full content (default: true)
653653+ @param base_url Base URL of the Karakeep instance
654654+ @param list_id ID of the list to get bookmarks from
655655+ @return
656656+ A Lwt promise with the bookmark response containing bookmarks in the list *)
657657+658658+val add_bookmark_to_list :
659659+ api_key:string -> string -> list_id -> bookmark_id -> unit Lwt.t
660660+(** [add_bookmark_to_list ~api_key base_url list_id bookmark_id] adds a bookmark
661661+ to a list.
662662+663663+ This function adds a bookmark to a manual list. Smart lists cannot be
664664+ directly modified.
665665+666666+ @param api_key API key for authentication
667667+ @param base_url Base URL of the Karakeep instance
668668+ @param list_id ID of the list to add the bookmark to
669669+ @param bookmark_id ID of the bookmark to add
670670+ @return A Lwt promise that completes when the bookmark is added to the list *)
671671+672672+val remove_bookmark_from_list :
673673+ api_key:string -> string -> list_id -> bookmark_id -> unit Lwt.t
674674+(** [remove_bookmark_from_list ~api_key base_url list_id bookmark_id] removes a
675675+ bookmark from a list.
676676+677677+ This function removes a bookmark from a manual list. Smart lists cannot be
678678+ directly modified.
679679+680680+ @param api_key API key for authentication
681681+ @param base_url Base URL of the Karakeep instance
682682+ @param list_id ID of the list to remove the bookmark from
683683+ @param bookmark_id ID of the bookmark to remove
684684+ @return
685685+ A Lwt promise that completes when the bookmark is removed from the list *)
686686+687687+(** {1 Highlight Operations} *)
688688+689689+val fetch_all_highlights :
690690+ api_key:string -> ?limit:int -> ?cursor:string -> string -> paginated_highlights Lwt.t
691691+(** [fetch_all_highlights ~api_key ?limit ?cursor base_url] fetches all
692692+ highlights.
693693+694694+ This function retrieves highlights from the Karakeep instance with
695695+ pagination.
696696+697697+ @param api_key API key for authentication
698698+ @param limit Number of highlights to fetch per page (default: 50)
699699+ @param cursor Optional pagination cursor
700700+ @param base_url Base URL of the Karakeep instance
701701+ @return A Lwt promise with the paginated highlights response *)
702702+703703+val fetch_bookmark_highlights :
704704+ api_key:string -> string -> bookmark_id -> highlight list Lwt.t
705705+(** [fetch_bookmark_highlights ~api_key base_url bookmark_id] fetches highlights
706706+ for a specific bookmark.
707707+708708+ This function retrieves all highlights that have been created for a specific
709709+ bookmark.
710710+711711+ @param api_key API key for authentication
712712+ @param base_url Base URL of the Karakeep instance
713713+ @param bookmark_id ID of the bookmark to get highlights for
714714+ @return A Lwt promise with the list of highlights for the bookmark *)
715715+716716+val fetch_highlight_details :
717717+ api_key:string -> string -> highlight_id -> highlight Lwt.t
718718+(** [fetch_highlight_details ~api_key base_url highlight_id] fetches detailed
719719+ information for a single highlight by ID.
720720+721721+ This function retrieves complete details for a specific highlight identified
722722+ by its ID.
723723+724724+ @param api_key API key for authentication
725725+ @param base_url Base URL of the Karakeep instance
726726+ @param highlight_id ID of the highlight to fetch
727727+ @return A Lwt promise with the complete highlight details *)
728728+729729+val create_highlight :
730730+ api_key:string ->
731731+ bookmark_id:bookmark_id ->
732732+ start_offset:int ->
733733+ end_offset:int ->
734734+ text:string ->
735735+ ?note:string ->
736736+ ?color:highlight_color ->
737737+ string ->
738738+ highlight Lwt.t
739739+(** [create_highlight ~api_key ~bookmark_id ~start_offset ~end_offset ~text
740740+ ?note ?color base_url] creates a new highlight in Karakeep.
741741+742742+ This function adds a new highlight to a bookmark in the Karakeep instance.
743743+ Highlights mark specific portions of the bookmark's content.
744744+745745+ @param api_key API key for authentication
746746+ @param bookmark_id ID of the bookmark to highlight
747747+ @param start_offset Starting position of the highlight
748748+ @param end_offset Ending position of the highlight
749749+ @param text Text content of the highlight
750750+ @param note Optional note for the highlight
751751+ @param color Color of the highlight (default: Yellow)
752752+ @param base_url Base URL of the Karakeep instance
753753+ @return A Lwt promise with the created highlight *)
754754+755755+val update_highlight :
756756+ api_key:string ->
757757+ ?color:highlight_color ->
758758+ string ->
759759+ highlight_id ->
760760+ highlight Lwt.t
761761+(** [update_highlight ~api_key ?color base_url highlight_id] updates a highlight
762762+ by its ID.
763763+764764+ This function updates the color of an existing highlight.
765765+766766+ @param api_key API key for authentication
767767+ @param color New color for the highlight
768768+ @param base_url Base URL of the Karakeep instance
769769+ @param highlight_id ID of the highlight to update
770770+ @return A Lwt promise with the updated highlight details *)
771771+772772+val delete_highlight : api_key:string -> string -> highlight_id -> unit Lwt.t
773773+(** [delete_highlight ~api_key base_url highlight_id] deletes a highlight by its
774774+ ID.
775775+776776+ This function permanently removes a highlight from the Karakeep instance.
777777+778778+ @param api_key API key for authentication
779779+ @param base_url Base URL of the Karakeep instance
780780+ @param highlight_id ID of the highlight to delete
781781+ @return A Lwt promise that completes when the highlight is deleted *)
782782+783783+(** {1 Asset Operations} *)
784784+785785+val fetch_asset : api_key:string -> string -> asset_id -> string Lwt.t
786786+(** [fetch_asset ~api_key base_url asset_id] fetches an asset from the Karakeep
787787+ server as a binary string.
788788+789789+ Assets can include images, PDFs, or other files attached to bookmarks. This
790790+ function retrieves the binary content of an asset by its ID.
791791+792792+ @param api_key API key for authentication
793793+ @param base_url Base URL of the Karakeep instance
794794+ @param asset_id ID of the asset to fetch
795795+ @return A Lwt promise with the binary asset data *)
796796+797797+val get_asset_url : string -> asset_id -> string
798798+(** [get_asset_url base_url asset_id] returns the full URL for a given asset ID.
799799+800800+ This is a pure function that constructs the URL for an asset without making
801801+ any API calls. The returned URL can be used to access the asset directly,
802802+ assuming proper authentication.
803803+804804+ @param base_url Base URL of the Karakeep instance
805805+ @param asset_id ID of the asset
806806+ @return The full URL to the asset *)
807807+808808+val attach_asset :
809809+ api_key:string ->
810810+ asset_id:asset_id ->
811811+ asset_type:asset_type ->
812812+ string ->
813813+ bookmark_id ->
814814+ asset Lwt.t
815815+(** [attach_asset ~api_key ~asset_id ~asset_type base_url bookmark_id] attaches
816816+ an asset to a bookmark.
817817+818818+ This function adds an existing asset to a bookmark.
819819+820820+ @param api_key API key for authentication
821821+ @param asset_id ID of the asset to attach
822822+ @param asset_type Type of the asset
823823+ @param base_url Base URL of the Karakeep instance
824824+ @param bookmark_id ID of the bookmark to attach the asset to
825825+ @return A Lwt promise with the attached asset details *)
826826+827827+val replace_asset :
828828+ api_key:string ->
829829+ new_asset_id:asset_id ->
830830+ string ->
831831+ bookmark_id ->
832832+ asset_id ->
833833+ unit Lwt.t
834834+(** [replace_asset ~api_key ~new_asset_id base_url bookmark_id asset_id]
835835+ replaces an asset on a bookmark with a new one.
836836+837837+ This function replaces an existing asset on a bookmark with a different
838838+ asset.
839839+840840+ @param api_key API key for authentication
841841+ @param new_asset_id ID of the new asset
842842+ @param base_url Base URL of the Karakeep instance
843843+ @param bookmark_id ID of the bookmark
844844+ @param asset_id ID of the asset to replace
845845+ @return A Lwt promise that completes when the asset is replaced *)
846846+847847+val detach_asset :
848848+ api_key:string -> string -> bookmark_id -> asset_id -> unit Lwt.t
849849+(** [detach_asset ~api_key base_url bookmark_id asset_id] detaches an asset from
850850+ a bookmark.
851851+852852+ This function removes an asset from a bookmark.
853853+854854+ @param api_key API key for authentication
855855+ @param base_url Base URL of the Karakeep instance
856856+ @param bookmark_id ID of the bookmark
857857+ @param asset_id ID of the asset to detach
858858+ @return A Lwt promise that completes when the asset is detached *)
859859+860860+(** {1 User Operations} *)
861861+862862+val get_current_user : api_key:string -> string -> user_info Lwt.t
863863+(** [get_current_user ~api_key base_url] gets information about the current
864864+ user.
865865+866866+ This function retrieves details about the authenticated user.
867867+868868+ @param api_key API key for authentication
869869+ @param base_url Base URL of the Karakeep instance
870870+ @return A Lwt promise with the user information *)
871871+872872+val get_user_stats : api_key:string -> string -> user_stats Lwt.t
873873+(** [get_user_stats ~api_key base_url] gets statistics about the current user.
874874+875875+ This function retrieves statistics about the authenticated user, such as the
876876+ number of bookmarks, tags, lists, etc.
877877+878878+ @param api_key API key for authentication
879879+ @param base_url Base URL of the Karakeep instance
880880+ @return A Lwt promise with the user statistics *)