···1# hermes
23-is a type-safe XRPC client for atproto.
45Hermes provides three components:
67- **hermes** - Core library for making XRPC calls
8- **hermes-cli** - Code generator for atproto lexicons
9-- **hermes_ppx** - PPX extension for ergonomic API calls
1011### table of contents
1213- [Quick Start](#quick-start)
14- [Complete Example](#complete-example)
15-- [Installation](#installation)
16- [hermes](#hermes-lib)
17 - [Session Management](#session-management)
18 - [Making XRPC Calls](#making-xrpc-calls)
···3031## quick start
32000000000033```ocaml
34-open Hermes_lexicons (* generate lexicons using hermes-cli! *)
35open Lwt.Syntax
3637let () = Lwt_main.run begin
···4748## complete example
490050```ocaml
51-open Hermes_lexicons (* generate lexicons using hermes-cli! *)
52open Lwt.Syntax
5354let main () =
55 (* Set up credential manager with persistence *)
56- let manager = Hermes.make_credential_manager ~service:"https://pegasus.example" () in
5758 Hermes.on_session_update manager (fun session ->
59 let json = Hermes.session_to_yojson session in
···102let () = Lwt_main.run (main ())
103```
104105-## installation
106-107-Add to your `dune-project`:
108-109-```lisp
110-(depends
111- hermes
112- hermes_ppx)
113-```
114-115<h2 id="hermes-lib">hermes</h2>
116117### session management
···232lib/generated/
233├── dune
234├── lexicons.ml # Re-exports all modules
235-└── app/
236- └── bsky/
237- └── actor/
238- └── getProfile.ml
239```
240241Each endpoint module contains:
242243```ocaml
244-module GetProfile = struct
245 type params = {
246 actor: string;
247 } [@@deriving yojson]
···278279### bytes encoding
280281-Endpoints with non-JSON encoding are automatically detected and handled:
282283-- **Queries with bytes output** (e.g., `com.atproto.sync.getBlob` with `encoding: "*/*"`):
284- - Output type is `bytes * string` (data, content_type)
285- - Generated code uses `Hermes.query_bytes`
286-287-- **Procedures with bytes input**:
288- - Input is `?input:string` (optional raw bytes)
289- - Generated code uses `Hermes.procedure_bytes`
290291### union types
292···301302<h2 id="hermes-ppx">hermes_ppx (PPX extension)</h2>
303304-Transforms `[%xrpc ...]` into generated module calls.
305306### setup
307
···1# hermes
23+is a set of libraries that work together to provide a type-safe XRPC client for atproto.
45Hermes provides three components:
67- **hermes** - Core library for making XRPC calls
8- **hermes-cli** - Code generator for atproto lexicons
9+- **hermes_ppx** (optional) - PPX extension for ergonomic API calls
1011### table of contents
1213- [Quick Start](#quick-start)
14- [Complete Example](#complete-example)
015- [hermes](#hermes-lib)
16 - [Session Management](#session-management)
17 - [Making XRPC Calls](#making-xrpc-calls)
···2930## quick start
3132+You'll need your lexicon `.json` files in a directory somewhere. Start by running `hermes-cli` to generate modules from your lexicons.
33+34+```bash
35+hermes-cli generate ./lexicons/ --output=./hermes_lexicons
36+```
37+38+You can find the full set of options for `hermes-cli` [here](#options).
39+40+A `hermes_lexicons` directory will be created with generated modules for each lexicon found in `./lexicons`. You can now use these modules in your code.
41+42```ocaml
43+open Hermes_lexicons (* generated using hermes-cli *)
44open Lwt.Syntax
4546let () = Lwt_main.run begin
···5657## complete example
5859+You can add the `hermes_ppx` extension ([here's how!](#setup)) for more ergonomic API calls.
60+61```ocaml
62+open Hermes_lexicons (* generated using hermes-cli *)
63open Lwt.Syntax
6465let main () =
66 (* Set up credential manager with persistence *)
67+ let manager = Hermes.make_credential_manager ~service:"https://pds.example" () in
6869 Hermes.on_session_update manager (fun session ->
70 let json = Hermes.session_to_yojson session in
···113let () = Lwt_main.run (main ())
114```
1150000000000116<h2 id="hermes-lib">hermes</h2>
117118### session management
···233lib/generated/
234├── dune
235├── lexicons.ml # Re-exports all modules
236+└── app_bsky_actor_getProfile.ml
000237```
238239Each endpoint module contains:
240241```ocaml
242+module Main = struct
243 type params = {
244 actor: string;
245 } [@@deriving yojson]
···276277### bytes encoding
278279+Endpoints with non-JSON encoding are automatically detected and handled by `hermes-cli`:
280281+- Queries with bytes output (e.g., `com.atproto.sync.getBlob`): output is `bytes * string` (data, content_type)
282+- Procedures with bytes input: input is `?input:bytes`
00000283284### union types
285···294295<h2 id="hermes-ppx">hermes_ppx (PPX extension)</h2>
296297+transforms `[%xrpc ...]` into generated module calls.
298299### setup
300