# Adapter: TMDb

TMDb adapter lets CrossWatch sync with your TMDb account. It supports watchlist and ratings.

{% hint style="info" %}
Connect TMDb first. Use: [TMDb](/crosswatch/providers/authentication/auth-trackers/auth-tmdb.md).
{% endhint %}

### What it supports

* Direction: source or target in a pair (one-way or two-way)
* Features:
  * **Watchlist** (movies and shows)
  * **Ratings** (movies, shows, and episodes)
  * **History / Playlists** (not supported)
* Rating scale: **1–10**
* Indexing: present-state snapshot (reads “what exists now”)

### How matching works

TMDb writes need a TMDb media ID.

CrossWatch resolves IDs in this order:

1. `ids.tmdb` (best)
2. `ids.imdb` via TMDb `/find`
3. `ids.tvdb` via TMDb `/find` (TV only)

CrossWatch UI features like **Insights/Overview** depend on `ids.imdb`.

So the TMDb adapter will also do an external lookup when it has a TMDb ID.

It calls TMDb `external_ids` and attaches `ids.imdb` when available.

{% hint style="warning" %}
If an item has no `tmdb`, `imdb`, or `tvdb` ID, it can’t be written to TMDb.
{% endhint %}

### Watchlist behavior

* Read: your TMDb watchlist for movies and TV.
* Write: add/remove items from the watchlist.

CrossWatch does not sync TMDb custom lists.

### Ratings behavior

* Read: your rated movies and TV shows.
* Write: set or clear ratings.

Ratings are integers from **1** to **10**.

{% hint style="info" %}
TMDb has API support for episode ratings. CrossWatch may index them. Some UIs hide episode rating writes based on feature gates.
{% endhint %}

### Settings (advanced)

TMDb (Sync) stores credentials under `tmdb_sync`.

<details>

<summary>Important config keys</summary>

* `tmdb_sync.api_key` (TMDb v3 API key)
* `tmdb_sync.session_id` (session from the connect flow)
* `tmdb_sync.account_id` (optional, auto-discovered if missing)
* `tmdb_sync.timeout` (seconds)
* `tmdb_sync.max_retries`

</details>

<details>

<summary>Endpoints used (for debugging)</summary>

Watchlist:

* `GET /account/{account_id}/watchlist/movies`
* `GET /account/{account_id}/watchlist/tv`
* `POST /account/{account_id}/watchlist`

Ratings:

* `GET /account/{account_id}/rated/movies`
* `GET /account/{account_id}/rated/tv`
* `GET /account/{account_id}/rated/tv/episodes` (episode ratings)
* `POST /movie/{id}/rating` and `DELETE /movie/{id}/rating`
* `POST /tv/{id}/rating` and `DELETE /tv/{id}/rating`
* `POST /tv/{show}/season/{s}/episode/{e}/rating` and `DELETE .../rating`

ID resolution:

* `GET /find/{external_id}` (`imdb_id` / `tvdb_id`)

ID enrichment (adds `ids.imdb` / `ids.tvdb` when TMDb provides them):

* `GET /{media_type}/{tmdb_id}/external_ids`

</details>

### Diagnostics

* Logs include `TMDB` and the feature name (example: watchlist, ratings).
* Health check probes `GET /account`.

Common unresolved reasons:

* Missing IDs for writes.
* Invalid rating (must be `1–10`).
* Episode rating missing `season` or `episode`.

### State and caching (advanced)

TMDb sync uses local state files under `/config/.cw_state/`.

These files are typically scoped per pair run, so different pairs don’t collide.

Scope details: [Scope](/blueprint-architecture/orchestrator/scope.md).

### Notes and limitations

* TMDb has no history sync. It is watchlist + ratings only.
* For better matching, enable [Meta: TMDb](/crosswatch/providers/metadata/meta-tmdb.md).
* Start one-way + dry run. Add removals only once runs are clean.

Deep dive (module-level): [TMDb (Sync) module overview](/blueprint-architecture/sync/_mod_tmdb/overview.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.crosswatch.app/crosswatch/providers/synchronization/adapter-tmdb.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
