Files
Showy/docs-vault/API Clients.md
T

144 lines
4.7 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.
---
## 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` |
| `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` |
## 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()` | GET | `/people/tmdb/popular` |
| `searchPeople(query)` | GET | `/people/tmdb/search` |
## collections.ts
| 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/:id/entries/:entryId` |
| `removeEntry(collectionId, entryId)` | DELETE | `/collections/:id/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
| 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
| Method | HTTP | Endpoint |
|---|---|---|
| `getAll()` | GET | `/episode-seen` |
| `getById(id)` | GET | `/episode-seen/:id` |
| `getByEpisode(episodeId)` | GET | `/episode-seen/by-episode/:episodeId` |
| `create(data)` | POST | `/episode-seen` |
| `update(id, data)` | PUT | `/episode-seen/:id` |
| `delete(id)` | DELETE | `/episode-seen/:id` |
## people.ts
| Method | HTTP | Endpoint |
|---|---|---|
| `getAll()` | GET | `/people` |
| `getById(id)` | GET | `/people/:id` |
| `getCredits(id)` | GET | `/people/:id/credits` |
| `getTmdbFilmography(id)` | GET | `/people/:id/tmdb-filmography` |
| `fetchByTmdbId(tmdbId)` | POST | `/people/fetch` |
## 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
| 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` |
Response type: `{ posters: number, logos: number, backdrops: number, stills: number }`