# API Layer > **HTTP Client:** Axios · **Base URL:** `/api/v1` (proxied to backend via Vite dev server) --- ## Configuration **File:** `src/lib/api.ts` Creates a shared Axios instance with: - `baseURL` derived from `VITE_API_URL` environment variable (defaults to `/api/v1`) - Image URL helpers for constructing media paths --- ## API Modules Each file in `src/api/` provides functions for one backend domain. All functions return the Axios response `.data` directly and run normalisation where applicable. ### `entries.ts` | Function | Method | Endpoint | | ------------------------------------ | -------- | ---------------------------------- | | `getAll()` | `GET` | `/entries` | | `getById(id)` | `GET` | `/entries/:id` | | `create(tmdb_id, is_tvserie)` | `POST` | `/entries` | | `update(id, data)` | `PUT` | `/entries/:id` | | `updateRatings(id, ratings)` | `PUT` | `/entries/:id/ratings` | | `updateIds(id, ids)` | `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` | | `uploadMedia(id, formData)` | `POST` | `/entries/:id/media` | | `setMediaSelected(entryId, mediaId)` | `PUT` | `/entries/:entryId/media/:mediaId` | | `deleteMedia(entryId, mediaId)` | `DELETE` | `/entries/:entryId/media/:mediaId` | ### `collections.ts` | Function | Method | 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` | | `addEntry(collectionId, entryId)` | `POST` | `/collections/:collectionId/entries/:entryId` | | `removeEntry(collectionId, entryId)` | `DELETE` | `/collections/:collectionId/entries/:entryId` | ### `entry-seen.ts` | Function | Method | Endpoint | | --------------------- | -------- | ------------------------------- | | `getAll()` | `GET` | `/entry-seen` | | `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` | Function | Method | 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` | ### `episodes.ts` | Function | Method | Endpoint | | -------------------------------- | ------ | ------------------------------------- | | `getByMonth(startDate, endDate)` | `GET` | `/episodes/month/:startDate/:endDate` | ### `seasons.ts` | Function | Method | 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` | ### `people.ts` | Function | Method | Endpoint | | ------------------------ | ------ | ------------------------------ | | `getAll()` | `GET` | `/people` | | `getById(id)` | `GET` | `/people/:id` | | `getCredits(id)` | `GET` | `/people/:id/credits` | | `getTmdbFilmography(id)` | `GET` | `/people/:id/tmdb-filmography` | | `fetchByTmdbId(tmdb_id)` | `POST` | `/people/fetch` | ### `tmdb.ts` | Function | Method | Endpoint | | --------------------------- | ------ | ------------------------------- | | `getTrendingMovies(page)` | `GET` | `/entries/tmdb/trending/movie` | | `getTrendingTv(page)` | `GET` | `/entries/tmdb/trending/tv` | | `getPopularMovies(page)` | `GET` | `/entries/tmdb/popular/movie` | | `getPopularTv(page)` | `GET` | `/entries/tmdb/popular/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` | ### `statistics.ts` | Function | Method | 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` | Function | Method | Endpoint | | -------------- | ------ | ----------- | | `get()` | `GET` | `/settings` | | `update(data)` | `PUT` | `/settings` | --- ## Normalisation **File:** `src/lib/normalizers.ts` Transforms backend responses into the frontend type contract: - Handles singular ↔ plural aliases (`entryRating` → `entryRatings`) - Maps nested includes to flat arrays - Marks entries loaded from the library as `isInLibrary: true`