Skip to content

nichtlegacy/trakt-graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

355 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Ί Trakt Contribution Graph

GitHub Workflow Status GitHub Release Made with Node.js JavaScript License

Transform your Trakt watch history into a beautiful GitHub-style contribution graph

Trakt contribution graph


✨ Features

Feature Description
🎨 Light & Dark Themes Automatically adapts to GitHub's theme preference
πŸ“Š Activity Heatmap GitHub-style contribution graph showing movie & episode activity
πŸ‘€ Profile Integration Shows profile picture, display name, and all-time stats
🎬 Content Filtering Display movies only, shows only, or everything together
πŸ“… Multi-Year Support Generate vertical graphs spanning multiple years
🎯 Streak Highlighting Hover over stats to highlight your longest activity streak
πŸ’¬ Interactive Tooltips Hover over cells to see specific titles watched that day
🏎️ Fast & Efficient Uses the Trakt API with intelligent pagination and caching
πŸ”„ Daily Updates Automated updates via GitHub Actions

πŸ“Έ Examples

Movies Only

Trakt movies only graph

Episodes Only

Trakt episodes only graph


πŸš€ Quick Start

1. Fork this Repository

Click the Fork button at the top-right of this page.

2. Configure Trakt API

  1. Go to Trakt API App Setup and create a new application.
  2. For Redirect URI, use urn:ietf:wg:oauth:2.0:oob.
  3. Copy your Client ID.
  4. In your GitHub repository, go to Settings β†’ Secrets and variables β†’ Actions.
  5. Add a new Repository secret:
    • Name: TRAKT_API_KEY
    • Value: (Your Trakt Client ID)

3. Update Your Username

Edit .github/workflows/update-trakt-graph.yml:

env:
  TRAKT_USERNAME: "YOUR_TRAKT_USERNAME"

4. Enable GitHub Actions

Go to Actions tab β†’ Enable workflows if prompted.

5. Run the Workflow

The graph updates daily at midnight UTC, or trigger manually via the Actions tab.


πŸ“– CLI Usage

# Install dependencies
npm install

# Set your API Key (Client ID)
$env:TRAKT_API_KEY = "your_client_id" # Windows PowerShell
# export TRAKT_API_KEY="your_client_id" # Linux/macOS

# Basic usage
node src/cli.js <username>

# With options
node src/cli.js <username> [options]

Arguments

Flag Description Default
-y <years> Year(s) to generate, comma-separated (e.g. 2025,2024) Current year
-t <type> Content type: movies, shows, or all all
-w <day> Week start: sunday or monday sunday
-o <path> Output path (without extension) images/github-trakt
-g <bool> Enable username gradient: true or false true
-p Export PNG files in addition to SVG Disabled

πŸ”§ GitHub Actions Setup

1. Repository Secret

To use the automated workflow, you must provide your Trakt API Key as a GitHub Secret:

  1. Go to your repository on GitHub.
  2. Navigate to Settings β†’ Secrets and variables β†’ Actions.
  3. Create a New repository secret.
  4. Set the name to TRAKT_API_KEY and the value to your Trakt Client ID.

2. Workflow File

Full configuration is available in the workflow file header:

env:
  TRAKT_USERNAME: "TheLagacyMiner"
  YEARS: ""              # e.g. "2025,2024" or empty for current
  CONTENT_TYPE: "all"    # "movies", "shows", or "all"
  WEEK_START: "sunday"
  GRADIENT: "true"

πŸ“‚ Project Structure

trakt-graph/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── update-trakt-graph.yml
β”œβ”€β”€ fonts/               # Required for SVG text measurement
β”œβ”€β”€ images/              # Target directory for generated graphs
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ cli.js           # CLI entry point
β”‚   β”œβ”€β”€ fetcher.js       # Trakt API interaction
β”‚   β”œβ”€β”€ generator.js     # SVG layout and rendering
β”‚   β”œβ”€β”€ stats.js         # Activity calculations
β”‚   └── exporter.js      # PNG export (Sharp)
β”œβ”€β”€ package.json
└── README.md

πŸ–ΌοΈ Embed in Your README

<p align="center">
  <a href="https://trakt.tv/users/YOUR_TRAKT_USERNAME/" target="_blank">
    <picture>
      <source
        media="(prefers-color-scheme: dark)"
        srcset="https://github.com/YOUR_GITHUB_USERNAME/trakt-graph/blob/main/images/github-trakt-dark.svg"
      />
      <source
        media="(prefers-color-scheme: light)"
        srcset="https://github.com/YOUR_GITHUB_USERNAME/trakt-graph/blob/main/images/github-trakt-light.svg"
      />
      <img
        alt="Trakt contribution graph"
        src="https://github.com/YOUR_GITHUB_USERNAME/trakt-graph/blob/main/images/github-trakt-light.svg"
      />
    </picture>
  </a>
</p>

πŸ› οΈ Requirements

  • Node.js v18 or higher
  • Trakt API Key (Client ID)
  • GitHub Actions enabled for automation

🀝 Contributing & License

MIT License. Contributions are welcome!

About

Generates a GitHub-style contribution graph based on your Trakt watch history. Uses Node.js to fetch API data, process entries, and create daily updated SVG visuals via GitHub Actions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors