npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lekoarts/trakt-loader

v1.0.1

Published

Astro content loader for Trakt.tv

Readme

Astro Trakt.tv loader

This package provides a Trakt.tv content loader for Astro's content layer. The content loaders correspond to specific Trakt API endpoints.

Want to see an overview of all my loaders? Visit astro-loaders.lekoarts.de

npm version npm downloads license

Prerequisites

  • Astro 5 or later installed
  • A Trakt.tv API key
    • Go to your Trakt Applications page and create a new application. The Client ID is your API key.

Installation

# npm
npm install @lekoarts/trakt-loader
# yarn
yarn add @lekoarts/trakt-loader
# pnpm
pnpm install @lekoarts/trakt-loader

Usage

Import @lekoarts/trakt-loader into src/content.config.ts and define your collections. You can import various loaders that correspond to their respective Trakt API endpoints.

Important: You need to either define the Trakt API key as an environment variable (TRAKT_API_KEY) or pass it as the api_key option.

traktUsersListsLoader

Returns all personal lists for a user.

Required options

  • id (string): The Trakt username or slug.

Usage

import { traktUsersListsLoader } from '@lekoarts/trakt-loader'

const usersLists = defineCollection({
  loader: traktUsersListsLoader({
    id: 'trakt-username',
  }),
})

traktUsersRatingsLoader

Get a user's ratings filtered by type. You can optionally filter for a specific rating between 1 and 10. Send a comma separated string for rating if you need multiple ratings.

Required options

  • id (string): The Trakt username or slug.
  • type (string): One of movies, shows, seasons, episodes, or all.

Optional options

  • rating (string): Filter for a specific rating (1-10 or comma-separated).
  • extended (string | string[]): Request additional fields.

Usage

Fetching all movie ratings for a user:

import { traktUsersRatingsLoader } from '@lekoarts/trakt-loader'

const usersRatings = defineCollection({
  loader: traktUsersRatingsLoader({
    id: 'trakt-username',
    type: 'movies',
  }),
})

Fetching only 10-star show ratings with extended info:

import { traktUsersRatingsLoader } from '@lekoarts/trakt-loader'

const usersRatings = defineCollection({
  loader: traktUsersRatingsLoader({
    id: 'trakt-username',
    type: 'shows',
    rating: 10,
    extended: ['full'],
  }),
})

traktUsersStatsLoader

Returns stats about the movies, shows, and episodes a user has watched, collected, and rated.

Required options

  • id (string): The Trakt username or slug.

Usage

import { traktUsersStatsLoader } from '@lekoarts/trakt-loader'

const usersStats = defineCollection({
  loader: traktUsersStatsLoader({
    id: 'trakt-username',
  }),
})

traktUsersWatchedLoader

Returns all movies or shows a user has watched sorted by most plays.

Required options

  • id (string): The Trakt username or slug.
  • type (string): Either movies or shows.

Optional options

  • extended (string | string[]): Request additional fields.

Usage

Fetching all watched movies:

import { traktUsersWatchedLoader } from '@lekoarts/trakt-loader'

const usersWatched = defineCollection({
  loader: traktUsersWatchedLoader({
    id: 'trakt-username',
    type: 'movies',
  }),
})

Fetching all watched shows with extended info:

import { traktUsersWatchedLoader } from '@lekoarts/trakt-loader'

const usersWatched = defineCollection({
  loader: traktUsersWatchedLoader({
    id: 'trakt-username',
    type: 'shows',
    extended: ['full'],
  }),
})

traktUsersHistoryLoader

Returns movies and episodes that a user has watched, sorted by most recent. You can optionally limit the type to movies or episodes.

Required options

  • id (string): The Trakt username or slug.
  • type (string): One of movies, shows, seasons, or episodes.

Optional options

  • item_id (number): Trakt ID for a specific item to limit the history.
  • start_at (string): Starting date for the history.
  • end_at (string): Ending date for the history.
  • extended (string | string[]): Request additional fields.

Usage

Fetching all watched episodes:

import { traktUsersHistoryLoader } from '@lekoarts/trakt-loader'

const usersHistory = defineCollection({
  loader: traktUsersHistoryLoader({
    id: 'trakt-username',
    type: 'episodes',
  }),
})

Fetching movie history for a specific date range:

import { traktUsersHistoryLoader } from '@lekoarts/trakt-loader'

const usersHistory = defineCollection({
  loader: traktUsersHistoryLoader({
    id: 'trakt-username',
    type: 'movies',
    start_at: '2024-01-01T00:00:00.000Z',
    end_at: '2024-12-31T23:59:59.999Z',
  }),
})