9.8 KiB
AI Query API Reference
Base URL:
/api/v1/ai-queryContent-Type:application/jsonServer default port:4000Branch:feature/ai-query-api
A set of read-only query endpoints designed for AI agents (like Hermes) to inspect the user's media library — watch history, library stats, collections, upcoming releases, and more.
All endpoints accept an optional ?limit=N query parameter where applicable. Entries with hidden: true are excluded by default.
Table of Contents
- Recently Watched Movies
- Recently Watched Episodes
- Watchlist
- Favorites
- Library Overview
- Library Search
- Upcoming Releases
- Entry Detail
- Genre Breakdown
- All Collections
- Collection Detail
- In-Progress Series
- Watch Time Stats
- Person Detail
1. Recently Watched Movies
GET /api/v1/ai-query/recently-watched/movies
Returns the last N movies the user watched, with entry details, ratings, and genres.
| Parameter | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
limit |
query | number | no | 10 |
Max records (1-50) |
Response 200
[
{
"watch_id": 1,
"date_watched": "2026-05-28T00:00:00.000Z",
"seen_with": "Alice",
"accuracy": "EXACT",
"entry": {
"id": 42,
"title": "Inception",
"poster_path": "/edv5CZvW...",
"banner_path": "/s3TBrR...",
"runtime": 148,
"release_date": "2010-07-16",
"is_favorite": true,
"rating": {
"userRating": 9.0,
"tmdbRating": 8.4,
"imdbRating": 8.8,
"rottenTomatoesRating": 87
},
"genres": [
{ "id": 28, "name": "Action" },
{ "id": 878, "name": "Sci-Fi" }
]
}
}
]
2. Recently Watched Episodes
GET /api/v1/ai-query/recently-watched/episodes
Returns the last N episodes the user watched, with episode → season → series hierarchy.
| Parameter | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
limit |
query | number | no | 10 |
Max records (1-50) |
Response 200
[
{
"watch_id": 15,
"date_watched": "2026-05-29T00:00:00.000Z",
"seen_with": null,
"episode": {
"id": 101,
"name": "Ozymandias",
"episode_number": 14,
"runtime": 47,
"still_path": "/still123.jpg",
"air_date": "2013-09-15"
},
"season": {
"id": 8,
"name": "Season 5",
"season_number": 5
},
"series": {
"id": 5,
"title": "Breaking Bad",
"poster_path": "/poster.jpg"
}
}
]
3. Watchlist
GET /api/v1/ai-query/watchlist
Returns all entries on the user's watchlist, ordered by last updated.
Response 200
[
{
"id": 42,
"title": "Dune: Part Two",
"is_tvseries": false,
"poster_path": "/poster.jpg",
"banner_path": "/banner.jpg",
"runtime": 166,
"release_date": "2024-03-01",
"is_favorite": false,
"is_on_watchlist": true,
"rating": { "userRating": null, "tmdbRating": 8.2, ... },
"genres": [ { "id": 878, "name": "Sci-Fi" } ]
}
]
4. Favorites
GET /api/v1/ai-query/favorites
Returns all entries the user has marked as favorite, ordered by last updated.
Response 200 — Same shape as watchlist but with is_favorite: true.
5. Library Overview
GET /api/v1/ai-query/library/overview
Returns high-level statistics about the user's library.
Response 200
{
"total_entries": 150,
"total_movies": 90,
"total_series": 60,
"movies_watched_count": 75,
"episodes_watched_count": 1200,
"total_genres": 27,
"total_watch_time_minutes": {
"movies": 15000,
"series": 36000
}
}
6. Library Search
GET /api/v1/ai-query/library/search
Search entries by title with optional filters.
| Parameter | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
q |
query | string | no | — | Title search (LIKE %q%) |
type |
query | string | no | — | movie or series |
genre |
query | string | no | — | Filter by genre name (case-insensitive) |
watchlist |
query | boolean | no | — | true to filter by watchlist |
favorite |
query | boolean | no | — | true to filter by favorite |
limit |
query | number | no | 20 |
Max results (1-100) |
Response 200 — Array of brief entry objects (same shape as watchlist above).
7. Upcoming Releases
GET /api/v1/ai-query/upcoming
Returns upcoming movie releases and next episode to air (within 30 days) for tracked series.
Response 200
{
"upcoming_movies": [
{
"id": 99,
"title": "Avatar 3",
"release_date": "2026-12-18",
"poster_path": "/poster.jpg",
"banner_path": "/banner.jpg",
"runtime": 190
}
],
"upcoming_episodes": [
{
"id": 500,
"name": "The Final Episode",
"episode_number": 10,
"air_date": "2026-06-05",
"still_path": "/still.jpg",
"series_title": "Severance",
"series_id": 30,
"season_number": 2,
"season_name": "Season 2"
}
]
}
8. Entry Detail
GET /api/v1/ai-query/entry/:id
Returns a single entry with full detail — ratings, external IDs, genres, networks, collections, credits (with people), seasons (with episodes), selected media, and watch history.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id |
path | integer | yes | Entry ID |
Response 200 — Full entry object with all associations + watch_history array at the top level.
Response 404
{ "error": "Entry not found" }
9. Genre Breakdown
GET /api/v1/ai-query/genres/breakdown
Returns all genres with entry counts, sorted by popularity (most entries first).
Response 200
[
{ "id": 28, "name": "Action", "entry_count": 25, "movie_count": 20, "series_count": 5 },
{ "id": 18, "name": "Drama", "entry_count": 18, "movie_count": 10, "series_count": 8 }
]
10. All Collections
GET /api/v1/ai-query/collections
Returns all collections (user and official) with entry counts.
Response 200
[
{
"id": 3,
"name": "Marvel Cinematic Universe",
"description": "All MCU films in order",
"is_user_collection": false,
"poster_path": "/poster.jpg",
"backdrop_path": "/backdrop.jpg",
"entry_count": 33
}
]
11. Collection Detail
GET /api/v1/ai-query/collections/:id
Returns a single collection with all entries inside it.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id |
path | integer | yes | Collection ID |
Response 200 — Collection object with entries array (each entry includes rating and genres).
Response 404
{ "error": "Collection not found" }
12. In-Progress Series
GET /api/v1/ai-query/tv-series/in-progress
Returns TV series that the user has started but not finished, sorted by progress percentage descending (most watched first).
Response 200
[
{
"id": 8,
"title": "Game of Thrones",
"poster_path": "/poster.jpg",
"banner_path": "/banner.jpg",
"user_rating": 8.5,
"total_episodes": 73,
"seen_episodes": 60,
"progress_pct": 82,
"is_complete": false
}
]
13. Watch Time Stats
GET /api/v1/ai-query/stats/watching-time
Returns watch time statistics — total minutes/hours watched, broken down by movies vs episodes, with monthly breakdown for the requested year.
| Parameter | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
year |
query | number | no | Current year | Year for breakdown |
Response 200
{
"year": 2026,
"total_watch_time_minutes": 51000,
"total_watch_time_hours": 850,
"movies_minutes": 15000,
"episodes_minutes": 36000,
"monthly": [
{ "month": "Jan", "movies": 1200, "episodes": 3200, "total": 4400 },
{ "month": "Feb", "movies": 900, "episodes": 2800, "total": 3700 }
]
}
14. Person Detail
GET /api/v1/ai-query/person/:id
Returns a person (actor/director) with their biography, profile, and all credited entries.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id |
path | integer | yes | People ID |
Response 200 — Full people object with roles array (each role includes the linked entry).
Response 404
{ "error": "Person not found" }
Example: Hermes Agent Queries
# "What movies did I watch last week?"
curl http://localhost:4000/api/v1/ai-query/recently-watched/movies?limit=10
# "What's on my watchlist?"
curl http://localhost:4000/api/v1/ai-query/watchlist
# "How many movies do I have?"
curl http://localhost:4000/api/v1/ai-query/library/overview
# "What shows am I watching right now?"
curl http://localhost:4000/api/v1/ai-query/tv-series/in-progress
# "What's coming out soon?"
curl http://localhost:4000/api/v1/ai-query/upcoming
# "Tell me about Inception"
curl http://localhost:4000/api/v1/ai-query/library/search?q=Inception