Files
X4Lo 229ecef902 Update docs vault and README for recent features
- New notes: History, Artwork
- Rewrite TMDB Integration: single detail request, entry mapper, rate
  limiter, refresh sync, stale-entry refresh, recommendations
- Update pages, routing, API reference, models, database migrations,
  services, components, hooks, API clients, settings, media system,
  library, Electron (Tauri in progress) and known issues
- Rewrite README for the current React/Express stack and setup
2026-11-05 19:55:04 +00:00

214 lines
7.2 KiB
Markdown

---
title: API Clients
tags:
- frontend
- api
- axios
---
# API Clients
All in `react_frontend/src/api/`. Each module exports an object with methods that call the [[Backend]] REST API via Axios.
Base Axios instance in `lib/api.ts` — configured with base URL and interceptors.
---
## auth.ts
Authentication.
| Method | HTTP | Endpoint |
|---|---|---|
| `login(password, remember)` | POST | `/auth/login` |
| `verify(token)` | GET | `/auth/verify` |
---
## watchBuddy.ts
Watch buddy management.
| Method | HTTP | Endpoint |
|---|---|---|
| `search(q?)` | GET | `/watch-buddies/search` |
| `create(data)` | POST | `/watch-buddies` |
| `update(id, data)` | PUT | `/watch-buddies/:id` |
| `remove(id)` | DELETE | `/watch-buddies/:id` |
---
## entries.ts
Entry CRUD and management.
| Method | HTTP | Endpoint |
|---|---|---|
| `getAll()` | GET | `/entries` |
| `getById(id)` | GET | `/entries/:id` |
| `create(data)` | POST | `/entries` |
| `update(id, data)` | PUT | `/entries/:id` |
| `updateRatings(id, data)` | PUT | `/entries/:id/ratings` |
| `updateIds(id, data)` | PUT | `/entries/:id/ids` |
| `delete(id)` | DELETE | `/entries/:id` |
| `refresh(id)` | PUT | `/entries/:id/refresh` |
| `fetchCollection(id)` | PUT | `/entries/:id/fetch-collection` |
| `getSeasons(id)` | GET | `/entries/:id/seasons` |
| `getCredits(id)` | GET | `/entries/:id/credits` |
| `syncSeries()` | GET | `/entries/sync-series` |
| `uploadMedia(id, formData)` | POST | `/entries/:id/media` |
| `setMediaSelected(entryId, mediaId)` | PUT | `/entries/:entryId/media/:mediaId` |
| `deleteMedia(entryId, mediaId)` | DELETE | `/entries/:entryId/media/:mediaId` |
| `previewTmdb(tmdbId, type)` | GET | `/entries/tmdb/preview/:type/:tmdbId` |
## tmdb.ts
TMDB proxy endpoints (via backend).
| Method | HTTP | Endpoint |
|---|---|---|
| `getPopularMovies(page)` | GET | `/entries/tmdb/popular/movie` |
| `getPopularTv(page)` | GET | `/entries/tmdb/popular/tv` |
| `getTrendingMovies(page)` | GET | `/entries/tmdb/trending/movie` |
| `getTrendingTv(page)` | GET | `/entries/tmdb/trending/tv` |
| `getTopRatedMovies(page)` | GET | `/entries/tmdb/top-rated/movie` |
| `getTopRatedTv(page)` | GET | `/entries/tmdb/top-rated/tv` |
| `getUpcomingMovies(page)` | GET | `/entries/tmdb/upcoming/movie` |
| `search(query, page)` | GET | `/entries/tmdb/search` |
| `getPopularPeople(page)` | GET | `/people/tmdb/popular` |
| `searchPeople(query, page)` | GET | `/people/tmdb/search` |
---
## collections.ts
Collection CRUD and entry management.
| Method | HTTP | Endpoint |
|---|---|---|
| `getAll()` | GET | `/collections` |
| `getById(id)` | GET | `/collections/:id` |
| `create(data)` | POST | `/collections` |
| `update(id, data)` | PUT | `/collections/:id` |
| `updateWithMedia(id, formData)` | PUT | `/collections/:id` (multipart) |
| `delete(id)` | DELETE | `/collections/:id` |
| `getCollectionParts(id)` | PUT | `/collections/:id/parts` |
| `addEntry(collectionId, entryId)` | POST | `/collections/:collectionId/entries/:entryId` |
| `removeEntry(collectionId, entryId)` | DELETE | `/collections/:collectionId/entries/:entryId` |
## seasons.ts
| Method | HTTP | Endpoint |
|---|---|---|
| `getAll()` | GET | `/seasons` |
| `getById(id)` | GET | `/seasons/:id` |
| `getEpisodes(id)` | GET | `/seasons/:id/episodes` |
| `create(data)` | POST | `/seasons` |
| `update(id, data)` | PUT | `/seasons/:id` |
| `delete(id)` | DELETE | `/seasons/:id` |
## episodes.ts
| Method | HTTP | Endpoint |
|---|---|---|
| `getByMonth(start, end)` | GET | `/episodes/month/:start/:end` |
## entry-seen.ts
Movie watch records.
| Method | HTTP | Endpoint |
|---|---|---|
| `getAll()` | GET | `/entry-seen` |
| `getById(id)` | GET | `/entry-seen/:id` |
| `getByEntry(entryId)` | GET | `/entry-seen/by-entry/:entryId` |
| `create(data)` | POST | `/entry-seen` |
| `update(id, data)` | PUT | `/entry-seen/:id` |
| `delete(id)` | DELETE | `/entry-seen/:id` |
## episode-seen.ts
Episode watch records.
| Method | HTTP | Endpoint |
|---|---|---|
| `getAll()` | GET | `/episode-seen` |
| `getById(id)` | GET | `/episode-seen/:id` |
| `getByEpisode(episodeId)` | GET | `/episode-seen/by-episode/:episodeId` |
| `getByEntry(entryId)` | GET | `/episode-seen/by-entry/:entryId` |
| `create(data)` | POST | `/episode-seen` |
| `update(id, data)` | PUT | `/episode-seen/:id` |
| `delete(id)` | DELETE | `/episode-seen/:id` |
## people.ts
People CRUD and TMDB integration.
| Method | HTTP | Endpoint |
|---|---|---|
| `getAll()` | GET | `/people` |
| `getAllPaginated(page, limit, search?)` | GET | `/people` |
| `getById(id)` | GET | `/people/:id` |
| `getCredits(id)` | GET | `/people/:id/credits` |
| `getTmdbFilmography(id)` | GET | `/people/:id/tmdb-filmography` |
| `previewTmdb(tmdbId)` | GET | `/people/tmdb/preview/:tmdbId` |
| `fetchByTmdbId(tmdbId, pinned?)` | POST | `/people/fetch` |
| `update(id, data)` | PUT | `/people/:id` |
| `search(query)` | GET | `/people/search` |
## statistics.ts
| Method | HTTP | Endpoint |
|---|---|---|
| `getAllTimeWatchTime()` | GET | `/statistics/watch-time` |
| `getYearlyWatchTime(year)` | GET | `/statistics/watch-time/year/:year` |
| `getYearlyWatchCount(year)` | GET | `/statistics/watch-count/year/:year` |
| `getWatchdayDistribution()` | GET | `/statistics/watch-weekday` |
## settings.ts
| Method | HTTP | Endpoint |
|---|---|---|
| `get()` | GET | `/settings` |
| `update(data)` | PUT | `/settings` |
## maintenance.ts
Maintenance and cleanup utilities.
| Method | HTTP | Endpoint |
|---|---|---|
| `scanOrphanFiles()` | GET | `/maintenance/orphan-files` |
| `deleteOrphanFiles()` | DELETE | `/maintenance/orphan-files` |
| `scanOrphanMediaRecords()` | GET | `/maintenance/orphan-media-records` |
| `deleteOrphanMediaRecords()` | DELETE | `/maintenance/orphan-media-records` |
| `scanOrphanPeople()` | GET | `/maintenance/orphan-people` |
| `deleteOrphanPeople()` | DELETE | `/maintenance/orphan-people` |
| `scanMissingDirectors()` | GET | `/maintenance/missing-directors` |
| `fixMissingDirectors()` | POST | `/maintenance/missing-directors` |
| `scanDuplicateCredits()` | GET | `/maintenance/duplicate-credits` |
| `cleanDuplicateCredits()` | DELETE | `/maintenance/duplicate-credits` |
| `autoFixWatchStatuses()` | POST | `/maintenance/auto-fix-watch-statuses` |
| `scanImpossibleSeenDates()` | GET | `/maintenance/impossible-seen-dates` |
| `fixImpossibleSeenDates()` | POST | `/maintenance/impossible-seen-dates` |
Response types:
- **Orphan files/media:** `{ posters: number, logos: number, backdrops: number, stills: number }`
- **Orphan people:** `{ count: number }`
- **Missing directors:** `{ count: number, fixed: number }`
- **Duplicate credits:** `{ groups: number, duplicates: number, deleted: number }`
- **Auto-fix watch statuses:** `{ completed: number, watching: number, planToWatch: number }`
- **Impossible seen dates:** Scan → `{ count: number }`, Fix → `{ count: number, added: number }`
## entries.ts — additions
`getRecommendations(id)`, `getTmdbRecommendations(type, tmdbId)`, `getArtwork(id)`, `getTmdbArtwork(type, tmdbId)`, `addArtwork(id, { type, file_path })`
## maintenance.ts — additions
`getStaleEntries(hours)`, `startStaleRefresh(hours)` (202 or 409), `cancelStaleRefresh()`
## history.ts
`historyApi.getYears()`, `historyApi.getYear(year)` — types `HistoryYear`, `HistoryEntry`, `HistoryEpisode`, `HistoryEvent`, `HistoryYearData`