···1+ISC License
2+3+Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>
4+5+Permission to use, copy, modify, and distribute this software for any
6+purpose with or without fee is hereby granted, provided that the above
7+copyright notice and this permission notice appear in all copies.
8+9+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+56-36
README.md
···1# OCaml Karakeep API Client
23-This library provides OCaml bindings to the Karakeep API for bookmark management.
0045## Features
67-- Fetch bookmarks from Karakeep instances with pagination
8-- Retrieve detailed bookmark information
9-- Create new bookmarks
10-- Access and download bookmark assets
11-- Filter bookmarks by tags
1213## Installation
14-15-To install the library, you can use opam:
1617```bash
18opam install karakeep
···21Or pin the development version:
2223```bash
24-opam pin add karakeep.dev git+https://github.com/yourusername/ocaml-karakeep.git
25```
2627## Configuration
2829-The library requires an API key for authentication. You can obtain an API key from your Karakeep instance.
3031## Usage Example
3233```ocaml
34-open Lwt.Infix
35-open Karakeep
03637-(* Setup the Karakeep client *)
38-let api_key = "your_api_key"
39-let base_url = "https://hoard.recoil.org"
0004041-(* Fetch recent bookmarks *)
42-let fetch_recent_bookmarks () =
43- fetch_bookmarks ~api_key ~limit:10 base_url >>= fun response ->
44-45- (* Process bookmarks *)
46 List.iter (fun bookmark ->
47- let title = match bookmark.title with
48- | Some t -> t
49- | None -> "(No title)"
50- in
51- Printf.printf "- %s\n URL: %s\n\n" title bookmark.url
52- ) response.data;
53-54- Lwt.return_unit
000000005556-(* Run the function *)
57-let () = Lwt_main.run (fetch_recent_bookmarks ())
0000000000000058```
5960## Documentation
6162-See the [documentation](doc/index.md) for more detailed usage instructions and API reference.
06364## License
6566-This library is licensed under the ISC license.
67-68-## Contact
69-70-For issues and questions, please create an issue on the GitHub repository.
···1# OCaml Karakeep API Client
23+An OCaml client library for the [Karakeep](https://karakeep.app) bookmark service API.
4+Built on [Eio](https://github.com/ocaml-multicore/eio) for structured concurrency with
5+a type-safe interface using [jsont](https://erratique.ch/software/jsont) for JSON encoding/decoding.
67## Features
89+- Full API coverage for bookmarks, tags, lists, highlights, and user operations
10+- Automatic pagination support
11+- Type-safe JSON encoding/decoding with jsont
12+- Built on Eio for structured concurrency
13+- Cmdliner integration for CLI tools
1415## Installation
001617```bash
18opam install karakeep
···21Or pin the development version:
2223```bash
24+opam pin add karakeep.dev git+https://tangled.org/@anil.recoil.org/ocaml-karakeep.git
25```
2627## Configuration
2829+The library requires an API key for authentication. You can obtain an API key from your Karakeep instance settings.
3031## Usage Example
3233```ocaml
34+let () =
35+ Eio_main.run @@ fun env ->
36+ Eio.Switch.run @@ fun sw ->
3738+ (* Create the client *)
39+ let client =
40+ Karakeep.create ~sw ~env
41+ ~base_url:"https://hoard.recoil.org"
42+ ~api_key:"your_api_key"
43+ in
4445+ (* Fetch recent bookmarks *)
46+ let result = Karakeep.fetch_bookmarks client ~limit:10 () in
00047 List.iter (fun bookmark ->
48+ let title = Karakeep.bookmark_title bookmark in
49+ Printf.printf "- %s\n" title
50+ ) result.bookmarks;
51+52+ (* Fetch all bookmarks (handles pagination automatically) *)
53+ let all_bookmarks = Karakeep.fetch_all_bookmarks client () in
54+ Printf.printf "Total bookmarks: %d\n" (List.length all_bookmarks);
55+56+ (* Create a new bookmark *)
57+ let _new_bookmark =
58+ Karakeep.create_bookmark client
59+ ~url:"https://ocaml.org"
60+ ~title:"OCaml Programming Language"
61+ ~tags:["programming"; "ocaml"]
62+ ()
63+ in
6465+ (* Search bookmarks *)
66+ let search_results = Karakeep.search_bookmarks client ~query:"ocaml" () in
67+ Printf.printf "Found %d results\n" (List.length search_results.bookmarks)
68+```
69+70+## Error Handling
71+72+All operations may raise `Eio.Io` exceptions with a `Karakeep.E` error payload:
73+74+```ocaml
75+try
76+ let bookmarks = Karakeep.fetch_bookmarks client () in
77+ (* ... *)
78+with
79+| Eio.Io (Karakeep.E err, _) ->
80+ Printf.eprintf "Karakeep error: %s\n" (Karakeep.error_to_string err)
81```
8283## Documentation
8485+- [API Documentation](doc/index.md)
86+- Online documentation is generated with `dune build @doc`
8788## License
8990+ISC License. See [LICENSE.md](LICENSE.md) for details.
0000
+5
dune
···00000
···1+; Root dune file
2+3+; Ignore directories that shouldn't be processed by dune
4+5+(data_only_dirs karakeep-src third_party)
···000001(** Karakeep CLI support library
23 This module provides cmdliner terms and utilities for building command-line
···1+(*---------------------------------------------------------------------------
2+ Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3+ SPDX-License-Identifier: ISC
4+ ---------------------------------------------------------------------------*)
5+6(** Karakeep CLI support library
78 This module provides cmdliner terms and utilities for building command-line
+5
lib/karakeep.ml
···000001(** Karakeep API client implementation *)
23include Karakeep_proto
···1+(*---------------------------------------------------------------------------
2+ Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3+ SPDX-License-Identifier: ISC
4+ ---------------------------------------------------------------------------*)
5+6(** Karakeep API client implementation *)
78include Karakeep_proto
+5
lib/karakeep.mli
···000001(** Karakeep API client
23 This module provides a client for interacting with the Karakeep bookmark
···1+(*---------------------------------------------------------------------------
2+ Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3+ SPDX-License-Identifier: ISC
4+ ---------------------------------------------------------------------------*)
5+6(** Karakeep API client
78 This module provides a client for interacting with the Karakeep bookmark
+5
lib/proto/karakeep_proto.ml
···000001(** Karakeep API protocol types and JSON codecs *)
23(** {1 Helper Codecs} *)
···1+(*---------------------------------------------------------------------------
2+ Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3+ SPDX-License-Identifier: ISC
4+ ---------------------------------------------------------------------------*)
5+6(** Karakeep API protocol types and JSON codecs *)
78(** {1 Helper Codecs} *)
+5
lib/proto/karakeep_proto.mli
···000001(** Karakeep API protocol types and JSON codecs
23 This module provides type definitions and jsont codecs for the Karakeep
···1+(*---------------------------------------------------------------------------
2+ Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3+ SPDX-License-Identifier: ISC
4+ ---------------------------------------------------------------------------*)
5+6(** Karakeep API protocol types and JSON codecs
78 This module provides type definitions and jsont codecs for the Karakeep