This is my Mergetober hackathon entry for the Trakt connector (proposed in cognee#6488).
Trakt is the quiet layer that has tracked everything I've watched for years — scrobbled automatically from my media setup, every episode with a timestamp. It's the closest thing I have to a ground-truth viewing record, and until now it was write-only memory: tracked, stored, never used.
This connector makes it agent-readable. With cognee, "which show was I bingeing in March?", "what episode did I last watch of Severance?" and "what's rated highly on my watchlist but never watched?" become answerable from my actual history.
Connecting
Trakt's official OAuth PIN flow, walked through in the README: create a free app at trakt.tv/oauth/applications, run the built-in helper, paste the PIN once:
from cognee_community_connector_trakt import trakt_pin_flow, trakt_source
import cognee
trakt_pin_flow(client_id, client_secret) # prints a URL, asks for the PIN, saves the token
await cognee.remember(
trakt_source(client_id, access_token),
dataset_name="trakt",
primary_key="id",
write_disposition="merge",
max_rows_per_table=0,
)
answers = await cognee.recall(
"What shows was I watching recently, and where did I leave off?",
datasets=["trakt"],
)
What gets remembered — and how it stays cheap
- Movies, episodes and shows I've watched (dates, play counts, titles), my ratings, my watchlist and my lists — one document each, with
show:<slug>andlist:<slug>node sets so episodes link to their show and lists link to their members in the graph, no LLM required. -
Incremental by section, not by everything. Trakt exposes
/sync/last_activities— one timestamp per section of your history. The connector stores those and re-pulls only what moved. An idle account costs one request per sync. Within a changed section it re-lists fully and upserts viamerge, so unchanged rows keep their content hash and are never re-processed. - Ratings don't get lost. A movie you rated but never watched still becomes a document. Unwatching a rated movie converts its document rather than deleting it — the cross-section forget-on-delete only tombstones a key when no section claims it.
-
Token hygiene and limits. The client refreshes expired tokens itself, honours
Retry-After, and a rate-limit wait longer than 60 seconds stops the run cleanly with nothing confirmed — the next sync resumes. The token never appears in a repr, log or error.
Verified so far
The connector runs end-to-end today: the full suite passes (every endpoint verified against the official Trakt API contract), including a delivery test that drives a real dlt pipeline and proves an item removed from history physically disappears after the _deleted tombstone.
$ uv run pytest tests/ -q
42 passed in 3.87s
I'll add numbers from my own history here as the syncs run — including the one-request idle sync.
Honest limitations
- Watched-show payloads don't carry episode ids, so the connector resolves them per-show from the seasons endpoint once (documented fallback if a show is delisted).
- Rate limits are real (500 GETs / 5 min per app); big first syncs page through and stop cleanly rather than hammering.
- History privacy: this is your full viewing record going into your own cognee dataset — keep the dataset private.
The connector is at packages/connector/trakt/ in cognee-community PR #599, with 42 tests (every endpoint verified against the official Trakt API contract) and delivery tests proving physical deletion on unwatched items.
Top comments (0)