[PR #3388] Initial proposed new routes #3956

Open
opened 2026-04-25 00:17:43 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/3388
Author: @nichwall
Created: 9/8/2024
Status: 🔄 Open

Base: masterHead: proposed_routes


📝 Commits (10+)

  • b42fcf2 Initial proposed new /libraries/{id}/items routes
  • 9cc3caa Initial: new root spec for all endpoints
  • c7db327 Add: initial podcast endpoints
  • d89c977 Add: initial library media endpoints
  • 2883863 Add: podcast-episodes, claen up parameters
  • 0795b03 Add: author endpoints
  • cb2a8b3 Add: create and delete library
  • 1f10f47 Additional library endpoints
  • 1556a04 Add: ereader endpoints
  • da6afc7 Add: RSS Feed endpoints

📊 Changes

2 files changed (+6718 additions, -0 deletions)

View changed files

📝 docs/controllers/LibraryController.yaml (+399 -0)
docs/newRoot.yaml (+6319 -0)

📄 Description

This PR is an attempt at proposing some new API endpoints to better facilitate an OpenAPI spec and allow for easier changes to the API to match more closely with the new data model.

From the perspective of the OpenAPI spec, we want each endpoint to have only one return type. While the OpenAPI specification is able to include different return schemas for a single endpoint, support for this varies by tool and language generator. Many (all?) tools do not fully implement all aspects of OpenAPI 3.0. In order to achieve this goal, I propose that new endpoints are defined for each media media type (book, podcast, and podcast episode).

For example, if we can split the /libraries/{id}/items endpoint into 3 different endpoints with distinct return types, this will make the OpenAPI spec much simpler and reduce the information loaded and sent to the client. If a client needs more information about a specific book, podcast, or episode, the relevant endpoints would be queried.

  • /libraries/{id}/books
  • /libraries/{id}/podcasts
  • /libraries/{id}/podcast-episodes

Here is a list of what I think the new routes could be. Note that all of these are new endpoints so they can be developed as their own controller without breaking existing endpoints, and then switching the web client over to using the new endpoints to ensure everything is working correctly before deprecating any other endpoints. Some of these endpoints will be a little clunky with the current database, but once migrations are set up https://github.com/advplyr/audiobookshelf/pull/3378 then we can migrate some things around (like simplifying the file endpoints).

Endpoint Method Description
/book/{id} GET This is everything needed for the edit modal or the book page
PATCH This is how the book is edited. It handles both the libraryItem and the media objects.
DELETE Delete the book and related information.
/book/{id}/download GET Download a zip of the book.
/book/{id}/cover GET POST PATCH DELETE Manage the cover image
/book/{id}/match POST Match the book against online provider
/book/{id}/play POST Play the book
/book/{id}/tracks PATCH Update the tracks for the book
/book/{id}/scan POST Scan the book again
/book/{id}/metadata-object GET Get the metadata for the files in the book
/book/{id}/chapters POST Update the chapters
/book/{id}/ebook GET Request a specific ebook file. Query includes the fileId instead of having it as part of the path, otherwise default to primary ebook if it exists.
PATCH Update the specific ebook file to be primary or supplementary. Query includes the fileId and requestBody includes whether it should be primary or not.
/podcast/{id} GET This is everything needed for the edit modal or the podcast page. The podcast episodes are returned using paging and are not all returned by default.
PATCH This is how the podcast is edited. It handles both the libraryItem and the media objects.
DELETE Delete the podcast and related information.
/podcast/{id}/download GET Download a zip of the podcast.
/podcast/{id}/cover GET POST PATCH DELETE Manage the cover image
/podcast/{id}/match POST Match the podcast against online provider
/podcast/{id}/play POST Play the most/least recent based on the podcast type and the current filter of viewable episodes.
/podcast/{id}/scan POST Scan the podcast again
/podcast/{id}/metadata-object GET Get the metadata for the files in the podcast (not sure if this is book specific yet?)
/podcast-episode/{id} GET This is everything needed for the edit modal and display on the podcast page.
PATCH This is how the podcast episode is edited.
DELETE Delete the podcast episode and related information.
/podcast-episode/{id}/download GET Download the episode. This could also be done directly by using the /file/{id}/download endpoint.
/podcast-episode/{id}/match POST Match the podcast episode against the RSS feed
/podcast-episode/{id}/play POST Play the podcast episode
/file/{id} GET Get the file
/file/{id}/ffprobe GET Get the ffprobe output of a file
/file/{id}/download GET Download the file

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/3388 **Author:** [@nichwall](https://github.com/nichwall) **Created:** 9/8/2024 **Status:** 🔄 Open **Base:** `master` ← **Head:** `proposed_routes` --- ### 📝 Commits (10+) - [`b42fcf2`](https://github.com/advplyr/audiobookshelf/commit/b42fcf26fab6c20a8bc6eb530da53f96ebd53bc8) Initial proposed new `/libraries/{id}/items` routes - [`9cc3caa`](https://github.com/advplyr/audiobookshelf/commit/9cc3caaaeda6de193eeca00039d5c81f9d048105) Initial: new root spec for all endpoints - [`c7db327`](https://github.com/advplyr/audiobookshelf/commit/c7db327aa3fe624942da07023c7b64a92358abc1) Add: initial podcast endpoints - [`d89c977`](https://github.com/advplyr/audiobookshelf/commit/d89c97742ce88357fb044852f85af57d431b0265) Add: initial library media endpoints - [`2883863`](https://github.com/advplyr/audiobookshelf/commit/288386302d80d9fbd8f8362802b643931b090579) Add: podcast-episodes, claen up parameters - [`0795b03`](https://github.com/advplyr/audiobookshelf/commit/0795b030fe4eed5a2e7c8dfb3d408c68eb127485) Add: author endpoints - [`cb2a8b3`](https://github.com/advplyr/audiobookshelf/commit/cb2a8b3abf53bb518fb2e094bc2e5f0cad51b2a0) Add: create and delete library - [`1f10f47`](https://github.com/advplyr/audiobookshelf/commit/1f10f472f7b635989ef2bcf95b9cbb21ba464b75) Additional library endpoints - [`1556a04`](https://github.com/advplyr/audiobookshelf/commit/1556a0426e15bb021dc9f68f61f095fb5499955e) Add: ereader endpoints - [`da6afc7`](https://github.com/advplyr/audiobookshelf/commit/da6afc7664ca44ccc05391e4c692a80bbfb254c5) Add: RSS Feed endpoints ### 📊 Changes **2 files changed** (+6718 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/controllers/LibraryController.yaml` (+399 -0) ➕ `docs/newRoot.yaml` (+6319 -0) </details> ### 📄 Description This PR is an attempt at proposing some new API endpoints to better facilitate an OpenAPI spec and allow for easier changes to the API to match more closely with the new data model. From the perspective of the OpenAPI spec, we want each endpoint to have only one return type. While the OpenAPI specification is able to include different return schemas for a single endpoint, support for this varies by tool and language generator. Many (all?) tools do not fully implement all aspects of OpenAPI 3.0. In order to achieve this goal, I propose that new endpoints are defined for each media media type (book, podcast, and podcast episode). For example, if we can split the `/libraries/{id}/items` endpoint into 3 different endpoints with distinct return types, this will make the OpenAPI spec much simpler and reduce the information loaded and sent to the client. If a client needs more information about a specific book, podcast, or episode, the relevant endpoints would be queried. - `/libraries/{id}/books` - `/libraries/{id}/podcasts` - `/libraries/{id}/podcast-episodes` Here is a list of what I think the new routes could be. Note that all of these are new endpoints so they can be developed as their own controller without breaking existing endpoints, and then switching the web client over to using the new endpoints to ensure everything is working correctly before deprecating any other endpoints. Some of these endpoints will be a little clunky with the current database, but once migrations are set up https://github.com/advplyr/audiobookshelf/pull/3378 then we can migrate some things around (like simplifying the file endpoints). | Endpoint | Method | Description | | --- | --- | --- | | `/book/{id}` | `GET` | This is everything needed for the edit modal or the book page | | | `PATCH` | This is how the book is edited. It handles both the `libraryItem` and the `media` objects. | | | `DELETE` | Delete the book and related information. | | `/book/{id}/download` | `GET` | Download a zip of the book. | | `/book/{id}/cover` | `GET` `POST` `PATCH` `DELETE` | Manage the cover image | | `/book/{id}/match` | `POST` | Match the book against online provider | | `/book/{id}/play` | `POST` | Play the book | | `/book/{id}/tracks` | `PATCH` | Update the tracks for the book | | `/book/{id}/scan` | `POST` | Scan the book again | | `/book/{id}/metadata-object` | `GET` | Get the metadata for the files in the book | | `/book/{id}/chapters` | `POST` | Update the chapters | | `/book/{id}/ebook` | `GET` | Request a specific ebook file. Query includes the `fileId` instead of having it as part of the path, otherwise default to primary ebook if it exists. | | | `PATCH` | Update the specific ebook file to be primary or supplementary. Query includes the `fileId` and requestBody includes whether it should be primary or not. | | `/podcast/{id}` | `GET` | This is everything needed for the edit modal or the podcast page. The podcast episodes are returned using paging and are not all returned by default. | | | `PATCH` | This is how the podcast is edited. It handles both the `libraryItem` and the `media` objects. | | | `DELETE` | Delete the podcast and related information. | | `/podcast/{id}/download` | `GET` | Download a zip of the podcast. | | `/podcast/{id}/cover` | `GET` `POST` `PATCH` `DELETE` | Manage the cover image | | `/podcast/{id}/match` | `POST` | Match the podcast against online provider | | `/podcast/{id}/play` | `POST` | Play the most/least recent based on the podcast type and the current filter of viewable episodes. | | `/podcast/{id}/scan` | `POST` | Scan the podcast again | | `/podcast/{id}/metadata-object` | `GET` | Get the metadata for the files in the podcast (not sure if this is book specific yet?) | | `/podcast-episode/{id}` | `GET` | This is everything needed for the edit modal and display on the podcast page. | | | `PATCH` | This is how the podcast episode is edited. | | | `DELETE` | Delete the podcast episode and related information. | | `/podcast-episode/{id}/download` | `GET` | Download the episode. This could also be done directly by using the `/file/{id}/download` endpoint. | | `/podcast-episode/{id}/match` | `POST` | Match the podcast episode against the RSS feed | | `/podcast-episode/{id}/play` | `POST` | Play the podcast episode | | `/file/{id}` | `GET` | Get the file | | `/file/{id}/ffprobe` | `GET` | Get the ffprobe output of a file | | `/file/{id}/download` | `GET` | Download the file | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:17:43 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3956