Files
Showy/backend/docs/api_reference.md
Mohammed Abad d28b4caa7e docs(react_frontend): add comprehensive documentation & AGENTS.md
- docs/README.md: overview and table of contents
- docs/tech_stack.md: full dependency inventory and design decisions
- docs/project_structure.md: directory tree with conventions
- docs/architecture.md: data flow, layer responsibilities, key patterns
- docs/routing.md: route table, code splitting, discover categories
- docs/state_management.md: Zustand stores and React Query conventions
- docs/api_layer.md: all API modules with endpoint mappings
- docs/components.md: layout, entries, collections, charts, dialogs, UI primitives
- docs/pages.md: all 16 pages with features and routes
- docs/styling.md: theming, CSS tokens, responsive breakpoints, animations
- AGENTS.md: architecture summary, code conventions, data flow, key files
2026-04-10 02:44:06 +01:00

32 KiB

API Reference

Base URL: /api/v1
Content-Type: application/json (unless multipart noted)
Server default port: 4000


Table of Contents

  1. Ping
  2. Entries
  3. Entry Seen
  4. Seasons
  5. Episodes
  6. Episode Seen
  7. Collections
  8. Media
  9. People
  10. Import
  11. Statistics
  12. Settings
  13. Maintenance
  14. Killer (Debug)
  15. TMDB Proxy — Entries
  16. TMDB Proxy — People

1. Ping

Health-check endpoint.

GET /api/v1/ping

Response 200

{ "message": "pong" }

2. Entries

GET /api/v1/entries

Retrieve all entries.

Parameter In Type Required Description
— — — — No parameters

Response 200

[
  {
    "id": 1,
    "title": "Inception",
    "original_title": "Inception",
    "release_date": "2010-07-16",
    "release_status": "Released",
    "runtime": 148,
    "tagline": "Your mind is the scene of the crime.",
    "storyline": "...",
    "country": "United States of America",
    "is_tvseries": false,
    "status": "Released",
    "poster_path": "/edv5CZvW...",
    "banner_path": "/s3TBrR...",
    "watchlist": false,
    "favorit": true,
    "hidden": false,
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-06-01T08:00:00.000Z"
  }
]

GET /api/v1/entries/:id

Retrieve a single entry by ID (triggers lazy-fetch refresh via entryManager.getUpdatedEntry).

Parameter In Type Required Description
id path integer yes Entry ID

Response 200

{
  "id": 1,
  "title": "Inception",
  "entryId": { "tmdb_id": "27205", "imdb_id": "tt1375666", "tvdb_id": null },
  "entryRating": { "user_rating": 9.0, "tmdb_rating": 8.4, "imdb_rating": 8.8, "rotten_tomatoes_rating": 87 },
  "genres": ["Action", "Sci-Fi"],
  "seasons": [],
  "medias": [],
  "entrySeen": [],
  "credits": [],
  "networks": [],
  "collections": []
}

POST /api/v1/entries

Fetch entry data from TMDB and persist it locally.

Parameter In Type Required Description
tmdb_id body string yes TMDB ID of the movie/series
is_tvserie body boolean yes true for TV series

Response 201

{
  "id": 42,
  "title": "Breaking Bad",
  "is_tvseries": true,
  "createdAt": "2024-06-01T12:00:00.000Z"
}

PUT /api/v1/entries/:id

Update entry properties.

Parameter In Type Required Description
id path integer yes Entry ID
entryData body object yes Partial entry fields to update

Response 201 — Updated entry object.


PUT /api/v1/entries/:id/ratings

Update entry ratings.

Parameter In Type Required Description
id path integer yes Entry ID
entryRatings body object yes { user_rating, tmdb_rating, imdb_rating, rotten_tomatoes_rating }

Response 200 — Updated ratings object.


PUT /api/v1/entries/:id/ids

Update external IDs for an entry.

Parameter In Type Required Description
id path integer yes Entry ID
entryIds body object yes { tmdb_id, imdb_id, tvdb_id }

Response 200 — Updated IDs object.


DELETE /api/v1/entries/:id

Delete an entry by ID.

Parameter In Type Required Description
id path integer yes Entry ID

Response 200

{ "message": "Entry with ID 42 deleted." }

GET /api/v1/entries/sync-series

Synchronise all TV series data from TMDB.

Response 201 — Array of updated entries.


GET /api/v1/entries/:id/seasons

Get all seasons for a TV series entry.

Parameter In Type Required Description
id path integer yes Entry ID

Response 200 — Array of season objects.
Response 204 — Entry has no seasons.


PUT /api/v1/entries/:id/refresh

Force-refresh entry data from TMDB.

Parameter In Type Required Description
id path integer yes Entry ID

Response 201 — Refreshed entry object.


PUT /api/v1/entries/:id/fetch-collection

Fetch the collection an entry belongs to (if any) from TMDB.

Parameter In Type Required Description
id path integer yes Entry ID

Response 201 — Collection object.
Response 204 — Entry has no collection.


POST /api/v1/entries/:id/media

Upload media files (poster/backdrop/logo) for an entry.

Parameter In Type Required Description
id path integer yes Entry ID
poster body (multipart) file no Poster image file
backdrop body (multipart) file no Backdrop image file
logo body (multipart) file no Logo image file

Content-Type: multipart/form-data

Response 200 — Created media record.


PUT /api/v1/entries/:entryId/media/:mediaId

Set a media asset as the selected one for its type.

Parameter In Type Required Description
entryId path integer yes Entry ID
mediaId path integer yes Media ID

Response 200 — Updated media record.


DELETE /api/v1/entries/:entryId/media/:mediaId

Delete a media asset. If the deleted asset was selected, another one is auto-promoted.

Parameter In Type Required Description
entryId path integer yes Entry ID
mediaId path integer yes Media ID

Response 200


3. Entry Seen

Watch-history records for movies/entries.

GET /api/v1/entry-seen

List all entry-seen records.

Response 200

[
  { "id": 1, "entry_id": 10, "date_seen": "2024-03-15", "seen_with": "Alice" }
]

GET /api/v1/entry-seen/:id

Get a specific entry-seen record.

Parameter In Type Required Description
id path integer yes EntrySeen ID

Response 200 — EntrySeen object.
Response 404 — Not found.


POST /api/v1/entry-seen

Create a new watch record.

Parameter In Type Required Description
entry_id body integer yes Entry FK
date_seen body date yes Watch date
seen_with body string no Companion name

Response 201

{ "id": 5, "entry_id": 10, "date_seen": "2024-06-01", "seen_with": "" }

GET /api/v1/entry-seen/by-entry/:entryId

Get all watch records for a given entry, ordered by date descending.

Parameter In Type Required Description
entryId path integer yes Entry ID

Response 200 — Array of EntrySeen objects.
Response 404 — No records found.


PUT /api/v1/entry-seen/:id

Update a watch record.

Parameter In Type Required Description
id path integer yes EntrySeen ID
date_seen body date no
seen_with body string no

Response 200 — Updated record.


DELETE /api/v1/entry-seen/:id

Delete a watch record.

Parameter In Type Required Description
id path integer yes EntrySeen ID

Response 204 — No content.


4. Seasons

GET /api/v1/seasons

List all seasons.

Response 200 — Array of season objects.


GET /api/v1/seasons/:id

Get a season with its episodes included.

Parameter In Type Required Description
id path integer yes Season ID

Response 200

{
  "id": 3,
  "name": "Season 3",
  "season_number": 3,
  "episodes": [
    { "id": 40, "episode_number": 1, "name": "Pilot", "runtime": 58 }
  ]
}

GET /api/v1/seasons/:id/episodes

Get all episodes for a season.

Parameter In Type Required Description
id path integer yes Season ID

Response 200 — Array of episode objects.


POST /api/v1/seasons

Create a season manually.

Parameter In Type Required Description
(body) body object yes Full season fields

Response 201 — Created season.


PUT /api/v1/seasons/:id

Update a season.

Parameter In Type Required Description
id path integer yes Season ID
(body) body object yes Partial season fields

Response 200 — Updated season.


DELETE /api/v1/seasons/:id

Delete a season (cascades to episodes).

Parameter In Type Required Description
id path integer yes Season ID

Response 204


5. Episodes

GET /api/v1/episodes/month/:startDate/:endDate

Get episodes airing between two dates (calendar view).

Parameter In Type Required Description
startDate path string (ISO date) yes Range start
endDate path string (ISO date) yes Range end

Response 200 — Array of episode objects.


6. Episode Seen

Watch-history for individual episodes.

GET /api/v1/episode-seen

List all episode-seen records.

Response 200 — Array of EpisodeSeen objects.


GET /api/v1/episode-seen/:id

Get a specific episode-seen record.

Parameter In Type Required Description
id path integer yes EpisodeSeen ID

Response 200 — EpisodeSeen object.


POST /api/v1/episode-seen

Create a new episode watch record.

Parameter In Type Required Description
entry_id body integer yes Parent entry FK
episode_id body integer yes Episode FK
date_seen body date yes Watch date
seen_with body string no Companion name

Response 201

{ "id": 12, "entry_id": 5, "episode_id": 40, "date_seen": "2024-06-10", "seen_with": "" }

GET /api/v1/episode-seen/by-episode/:episodeId

Get all watch records for an episode, ordered by date descending.

Parameter In Type Required Description
episodeId path integer yes Episode ID

Response 200 — Array of EpisodeSeen objects.


GET /api/v1/episode-seen/by-entry/:entryId

Get all episode-seen records for an entry, with episode & season info. Ordered by date desc, then season desc, then episode desc.

Parameter In Type Required Description
entryId path integer yes Entry ID

Response 200

[
  {
    "id": 12,
    "entry_id": 5,
    "episode_id": 40,
    "date_seen": "2024-06-10",
    "seen_with": "",
    "episode": {
      "episode_number": 1,
      "season": { "season_number": 3 }
    }
  }
]

PUT /api/v1/episode-seen/:id

Update an episode-seen record.

Parameter In Type Required Description
id path integer yes EpisodeSeen ID
date_seen body date no
seen_with body string no

Response 200 — Updated record.


DELETE /api/v1/episode-seen/:id

Delete an episode-seen record.

Parameter In Type Required Description
id path integer yes EpisodeSeen ID

Response 204


7. Collections

GET /api/v1/collections

List all collections.

Response 200 — Array of collection objects.


GET /api/v1/collections/:id

Get a collection with its entries (including each entry's IDs, ratings, seasons, media, genres). Entries ordered by pivot order.

Parameter In Type Required Description
id path integer yes Collection ID

Response 200

{
  "id": 1,
  "name": "The Dark Knight Trilogy",
  "description": "...",
  "is_user_collection": true,
  "entries": [
    {
      "id": 10,
      "title": "Batman Begins",
      "UserCollectionEntry": { "order": 1 },
      "entryId": { "tmdb_id": "272" },
      "entryRating": { "user_rating": 8.5 },
      "genres": ["Action", "Crime"],
      "medias": []
    }
  ],
  "medias": []
}

POST /api/v1/collections

Create a new user collection.

Parameter In Type Required Description
name body string yes
description body string no
userRating body float no
posterPath body string no

Response 201 — Created collection.


PUT /api/v1/collections/:id

Update a collection (supports multipart poster/backdrop upload).

Parameter In Type Required Description
id path integer yes Collection ID
name body string no
description body string no
userRating body float no
poster body (multipart) file no Poster image
backdrop body (multipart) file no Backdrop image

Content-Type: multipart/form-data

Response 200 — Updated collection.


PUT /api/v1/collections/:id/refresh

Refresh collection metadata from TMDB.

Parameter In Type Required Description
id path integer yes Collection ID

Response 200 — Refreshed collection.


PUT /api/v1/collections/:id/parts

Fetch missing collection parts (entries) from TMDB and link them.

Parameter In Type Required Description
id path integer yes Collection ID

Response 200 — Collection with updated entries.


DELETE /api/v1/collections/:id

Delete a collection.

Parameter In Type Required Description
id path integer yes Collection ID

Response 204


POST /api/v1/collections/:collectionId/entries/:entryId

Add an entry to a collection.

Parameter In Type Required Description
collectionId path integer yes Collection ID
entryId path integer yes Entry ID

Response 201 — Created pivot record.


PATCH /api/v1/collections/:collectionId/entries/:entryId

Update entry order within a collection.

Parameter In Type Required Description
collectionId path integer yes Collection ID
entryId path integer yes Entry ID
newOrder body integer yes New sort position

Response 200

{ "message": "UserCollectionEntry order updated successfully." }

DELETE /api/v1/collections/:collectionId/entries/:entryId

Remove an entry from a collection.

Parameter In Type Required Description
collectionId path integer yes Collection ID
entryId path integer yes Entry ID

Response 204


POST /api/v1/collections/collection-with-entry

Atomically create a collection and add an entry to it (transaction).

Parameter In Type Required Description
listDetails body object yes Collection creation fields
entryId body integer yes Entry to add
entryOrder body integer no Initial order

Response 201

{
  "newUserCollection": { "id": 5, "name": "My List" },
  "newUserCollectionEntry": { "user_collection_id": 5, "entry_id": 10 }
}

8. Media

GET /api/v1/media

List all custom (user-uploaded) media records, with associated entry/collection.

Response 200

[
  {
    "id": 1,
    "mediaable": "entry",
    "mediaableId": 10,
    "type": "poster",
    "path": "abc123.jpg",
    "isLocal": true,
    "isSelected": true,
    "isCustom": true,
    "entry": { "id": 10, "title": "Inception" },
    "collection": null
  }
]

GET /api/v1/media/:category/:type/:size/:fileName

Serve a media file from disk. Generates preview on-the-fly if missing.

Parameter In Type Required Description
category path string yes One of: entries, collections, franchises, seasons, episodes, peoples
type path string yes One of: backdrops, posters, logos, stills, profiles, others
size path string yes original or preview
fileName path string yes Image filename

Response 200 — Binary image stream.


9. People

GET /api/v1/people

List all people.

Response 200 — Array of people objects.


GET /api/v1/people/popular

Get popular people.

Parameter In Type Required Description
limit query integer no Number of results (default: 10)

Response 200 — Array of people objects ordered by popularity.


GET /api/v1/people/search

Search people by name.

Parameter In Type Required Description
query query string yes Search term

Response 200 — Array of matching people.


GET /api/v1/people/:id

Get a person by ID (triggers lazy-fetch from TMDB if not fully fetched).

Parameter In Type Required Description
id path integer yes Person ID

Response 200

{
  "id": 1,
  "tmdb_id": "6193",
  "name": "Leonardo DiCaprio",
  "birthday": "1974-11-11",
  "biography": "...",
  "known_for_department": "Acting",
  "fully_fetched": true,
  "medias": []
}

POST /api/v1/people

Create a person manually.

Parameter In Type Required Description
(body) body object yes Person fields

Response 201 — Created person.


POST /api/v1/people/fetch

Fetch and save a person from TMDB.

Parameter In Type Required Description
tmdb_id body string yes TMDB person ID

Response 201 — Created/updated person.


PUT /api/v1/people/:id

Update a person.

Parameter In Type Required Description
id path integer yes Person ID
(body) body object yes Partial person fields

Response 200 — Updated person.


PUT /api/v1/people/:id/refresh

Refresh person data from TMDB.

Parameter In Type Required Description
id path integer yes Person ID

Response 200 — Refreshed person.


DELETE /api/v1/people/:id

Delete a person.

Parameter In Type Required Description
id path integer yes Person ID

Response 200


GET /api/v1/people/:id/credits

Get all credits (roles) for a person.

Parameter In Type Required Description
id path integer yes Person ID

Response 200 — Array of credit objects.


GET /api/v1/people/:id/tmdb-filmography

Get the full combined filmography for a person directly from TMDB (includes entries not in the local library).

Parameter In Type Required Description
id path integer yes Person ID

Response 200 — TMDB combined credits object ({ cast: [...], crew: [...] }).
Response 404 — Person not found or missing TMDB ID.


POST /api/v1/people/:id/media

Upload a profile picture for a person.

Parameter In Type Required Description
id path integer yes Person ID
profile body (multipart) file yes Profile image

Content-Type: multipart/form-data

Response 200

{ "success": true, "files": [{ "type": "profile", "original": "abc.jpg", "preview": "abc_preview.jpg" }] }

10. Import

Bulk-import endpoints for bootstrapping the library.

POST /api/v1/import/movies

Bulk-import movies from a structured list.

Parameter In Type Required Description
movies body array yes Array of { tmdbId, dateSeen, userRating }

Response 201 — Array of created entries.

Rate-limited: max 35 TMDB fetches per 10-second window with 500ms intervals.


POST /api/v1/import/tmdb

Bulk-import TV series by TMDB IDs.

Parameter In Type Required Description
values body array yes Array of TMDB IDs (strings/numbers)

Response 201 — Array of created entries.


POST /api/v1/import/episodes-watch-history

Bulk-import episode watch history.

Parameter In Type Required Description
values body array yes Array of episode-seen data objects

Response 201 — Array of created EpisodeSeen records.

Warning: This endpoint clears existing episode-seen records before import.


11. Statistics

GET /api/v1/statistics/watch-time

Get all-time total watch time (minutes), split by series and movies.

Response 200

{ "series": 45600, "movies": 12300 }

GET /api/v1/statistics/watch-time/year/:year

Get monthly watch time for a given year.

Parameter In Type Required Description
year path integer yes Calendar year

Response 200

{
  "series": [{ "month": 1, "watchTime": 1200 }, { "month": 2, "watchTime": 980 }],
  "movies": [{ "month": 1, "watchTime": 300 }]
}

GET /api/v1/statistics/watch-count/year/:year

Get monthly watch count (number of items watched) for a given year.

Parameter In Type Required Description
year path integer yes Calendar year

Response 200

{
  "series": [{ "month": 1, "count": 45 }],
  "movies": [{ "month": 1, "count": 5 }]
}

GET /api/v1/statistics/watch-weekday

Get watch count grouped by day of the week (1 = Sunday … 7 = Saturday).

Response 200

{
  "episodes": [{ "day": 2, "count": 120 }, { "day": 7, "count": 45 }],
  "movies": [{ "day": 6, "count": 15 }]
}

12. Settings

GET /api/v1/settings

Retrieve application settings.

Response 200

{
  "userDataPath": "/app/data",
  "tmdbApiUrl": "https://api.themoviedb.org/3/",
  "tmdbApiKey": "***",
  "frontPort": "4200",
  "backPort": "4000",
  "libraryViewMode": "grid",
  "favoritViewMode": "grid",
  "watchlistViewMode": "grid",
  "CollectionsViewMode": "grid",
  "CollectionItemsViewMode": "grid",
  "episodesViewMode": "grid"
}

PUT /api/v1/settings

Update application settings. Merges provided fields with existing settings and writes to settings.json.

Parameter In Type Required Description
(body) body object yes Partial settings object

Response 200 — Full updated settings object.


13. Maintenance

GET /api/v1/maintenance/orphan-files

Dry-run: list orphan files on disk that have no matching media record.

Response 200 — Array of orphan file paths.


DELETE /api/v1/maintenance/orphan-files

Delete orphan files on disk.

Response 200 — Array of deleted file paths.


GET /api/v1/maintenance/orphan-media-records

Dry-run: list media DB records whose files are missing on disk.

Response 200 — Array of orphan media records.


DELETE /api/v1/maintenance/orphan-media-records

Delete orphan media DB records.

Response 200 — Array of deleted records.


14. Killer (Debug)

Registered outside the /api/v1 prefix at /killer.

GET /killer · POST /killer

Intentionally crashes the backend process (used by Electron to manage the backend lifecycle).

Response 200

{ "message": "Backend killed." }

15. TMDB Proxy — Entries

These endpoints proxy requests to the TMDB API through the backend, enabling discovery features in the frontend without exposing the TMDB API key to the client.

GET /api/v1/entries/tmdb/trending/:type

Get trending entries from TMDB.

Parameter In Type Required Description
type path string yes movie or tv
page query integer no Page number (default: 1)

Response 200 — TMDB paginated response ({ page, results, total_pages, total_results }).


GET /api/v1/entries/tmdb/popular/:type

Get popular entries from TMDB.

Parameter In Type Required Description
type path string yes movie or tv
page query integer no Page number (default: 1)

Response 200 — TMDB paginated response.


GET /api/v1/entries/tmdb/top-rated/:type

Get top-rated entries from TMDB.

Parameter In Type Required Description
type path string yes movie or tv
page query integer no Page number (default: 1)

Response 200 — TMDB paginated response.


GET /api/v1/entries/tmdb/upcoming/movie

Get upcoming movies from TMDB.

Parameter In Type Required Description
page query integer no Page number (default: 1)

Response 200 — TMDB paginated response.


GET /api/v1/entries/tmdb/search

Search TMDB for movies and TV series (multi-search).

Parameter In Type Required Description
query query string yes Search term
page query integer no Page number (default: 1)

Response 200 — TMDB paginated response.
Response 400 — Missing query parameter.


16. TMDB Proxy — People

GET /api/v1/people/tmdb/popular

Get popular people from TMDB.

Parameter In Type Required Description
page query integer no Page number (default: 1)

Response 200 — TMDB paginated response of person objects.


GET /api/v1/people/tmdb/search

Search TMDB for people by name.

Parameter In Type Required Description
query query string yes Search term
page query integer no Page number (default: 1)

Response 200 — TMDB paginated response of person objects.
Response 400 — Missing query parameter.


Error Responses

All endpoints use a global error-handling middleware. Common shapes:

Status Body
400 { "error": "..." } or { "message": "..." }
404 { "message": "... not found" }
500 { "error": "..." }

Custom error classes in errors/: BadRequestError, NotFoundError, ConflictError, ValidationError, ForbiddenError, UnauthorizedError, InternalServerError.