What you’ll see
Audiobookshelf
- Health: in Details. Once the server stops answering, or answers that the key isn’t allowed, the health card turns red, and Legato sends a notification. Nothing else counts as a problem.
- Listening: the last seven days in hours, for everyone on the server, with today in bold. A session counts on the day it started.
- Server: this week’s hours and how many people listened, when the last backup was made ("No backups" if there are none), how much space the libraries take, and the server’s version.
- Now listening: each book or episode someone is playing, with its cover (or a headphones or podcast icon when it has none), the author or the podcast, who’s listening on what, and a bar with "4.2 of 9.5 h" (episodes and anything under an hour in minutes). A player that hasn’t reported for two minutes says Paused. After 16 minutes of silence the row goes, even though Audiobookshelf keeps the session open for a day and a half.
- Recently added: a shelf of the four newest books and podcast episodes across your libraries, with their covers. Each opens in Audiobookshelf.
- Libraries: each library with what it holds ("412 books · 3,870 h", "9 podcasts · 1,204 episodes"). Each row opens that library’s page.
- Recent listening: the last four sessions that aren’t on Now listening, each with who, how long and when.
Library
One page for every library, titled with its name. A book library shows how many books, hours and authors it has and its size, then the fifteen newest books. A podcast library shows its podcasts, episodes, hours and size, then the fifteen newest episodes. Each opens in Audiobookshelf.
Status
- Watches whether the server answers and takes the key, not who’s listening.
- Red once the server stops answering or refuses the key.
- Someone listening, a pause or an old backup never counts as a problem.
- Notifies you when it turns orange or red.
How it connects
The pages read your server’s own API with your API key, sent as Authorization: Bearer. Sessions, backups and the server’s totals answer only admin and root users, so the key has to be one of theirs.
Requests it makes on its own 11
- GET
/api/sessions/openWho’s playing what, how far along, and when their player last reported.
AudiobookshelfOnce a minute, and every 15 minutes
- GET
/statusThat the server answers, and its version.
AudiobookshelfEvery 5 and 15 minutes
- GET
/api/backupsThe backups and when each was made. Checks the key too, since
/statusanswers without one.AudiobookshelfEvery 5 and 15 minutes
- GET
/api/sessions?itemsPerPage=100 &sort=updatedAt &desc=1 The newest 100 listening sessions, for the week and Recent listening.
AudiobookshelfEvery 15 minutes
- GET
/api/stats/serverHow much space the libraries take.
AudiobookshelfEvery 15 minutes
- GET
/api/librariesThe libraries, their names and kinds.
Audiobookshelf, LibraryEvery 15 minutes
- GET
/api/libraries/{param.id}The library’s folders, so its episodes are asked for once.
LibraryEvery 15 minutes
- GET
/api/libraries/{id}/statsHow many items, hours, episodes and authors each holds.
Audiobookshelf, LibraryEvery 15 minutes, for each library
- GET
/api/libraries/{id}/items?sort=addedAt &desc=1 &limit=8 &minified=1 The newest books in it (15 on the library’s page).
Audiobookshelf, LibraryEvery 15 minutes, for each library
- GET
/api/libraries/{id}/recent-episodes?limit=8 The newest episodes of a podcast library (15 on its page). A book library answers that it has none, and is left out. If a podcast library’s episodes don’t come, its page says so rather than showing it empty.
Audiobookshelf, LibraryEvery 15 minutes, for each library
- GET
/api/items/{id}/cover?width=144 &format=jpeg Covers, kept on this Mac.
Audiobookshelf, LibraryWhile the panel shows the row
With the overview open and two libraries, that’s about 130 requests an hour, plus a cover the first time each one shows. Up to 10 libraries get their totals and newest items. Covers come only from your server, never from another site, and Load icons from the web in Settings doesn’t affect them. The pages have no buttons: Audiobookshelf can’t stop or message someone else’s player, and the pages never change your library.
Sources and buttons explains each part of a page.
Set it up
- Make an API key. Sign in to Audiobookshelf as an admin or root user, open Settings → API Keys, and add a key for that user. Audiobookshelf 2.26 added API keys. Leave the expiry off, or note when it runs out. Audiobookshelf’s docs cover the rest of the server.
- Save it in Legato. In Settings → Secrets, save the key under
audiobookshelf, bound to your server’s address. You can also link a 1Password reference. - Add the pages. Paste the prompt into your agent, or download the two pages and run
/Applications/Legato.app/Contents/Helpers/legato set audiobookshelf-library audiobookshelf-library.json, thenlegato set audiobookshelf audiobookshelf.json. Keep the IDaudiobookshelf-library: every library row opens it with that library’s id. - Point them at your server. Change
http://audiobookshelf.local:13378to your server’s address on every source and link of both pages. Docker’s usual port is 13378. A server behind a reverse proxy works at its own address (https://books.example.com). The installer doesn’t take an address with a path, such as/audiobookshelf; edit the downloaded pages for one, putting the path in each source’sbase.
The cards fill within a minute. A key of a user who isn’t an admin is the usual reason they don’t: the server answers that it isn’t allowed, and Details turns red.
Prompt for your agent
Add 2 Legato pages for Audiobookshelf, starting from https://legatobar.com/examples/audiobookshelf.json, https://legatobar.com/examples/audiobookshelf-library.json. Use the page IDs audiobookshelf, audiobookshelf-library if they’re free: the pages link to each other by those IDs, so with any other ID, change the matching legato://page/ links.
Add the pages as they are, keeping their page IDs, and change http://audiobookshelf.local:13378 on every source and link of both pages to my server’s address. I’ll save my Audiobookshelf API key as audiobookshelf in Settings → Secrets myself.
Use the local Legato MCP tools or /Applications/Legato.app/Contents/Helpers/legato.
Use list_pages first and choose an unused page ID. Do not overwrite an existing page. If I explicitly ask to update one, read its full body with get_page, preserve unrelated cards and settings, and use if_match with that version. On version_mismatch, read again before merging.
Ask me only for non-secret setup details that are missing. Never ask me to paste a password, token or API key into chat, page JSON or command arguments. Tell me to save it in Settings → Secrets for the service host, or link it from 1Password there.
Use the downloadable page, not the illustration’s sample data. Never invent readings. Fix any invalid_page paths and verify that the page loads. Do not press buttons that change the service or real devices to test it.Download the pages
Questions
When does a row say Paused, and when does it go?
Audiobookshelf keeps a session open until the app closes it, or for 36 hours. The page goes by when the player last reported instead: Paused after two minutes of silence, and gone after 16.
Why does the week say "newest 100 sessions"?
The page reads the newest 100 sessions. On a busy server, a week can have more than that, so its first days would look short. When that happens the chart says so, and This week says "At least". Audiobookshelf’s own stats have the whole history.
Why doesn’t an old backup count as a problem?
Automatic backups are off unless you turn them on, and the API doesn’t say whether they are. A month-old backup might be a problem or might be how you run it, so the page only says when the last one was made.
What happens to the covers?
Legato fetches each cover from your server, only while it’s on screen, and keeps up to 50 MB of them on this Mac, the oldest going first. They never go anywhere else.