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

@api-wrappers/trakt-wrapper

v0.1.0

Published

Type-safe TypeScript client for the Trakt API with OAuth helpers, typed endpoints, pagination, retries, and api-core plugins.

Readme

@api-wrappers/trakt-wrapper

GitHub Repo stars

Modern TypeScript client for the Trakt API.

It is designed to pair well with @api-wrappers/tmdb-wrapper: TMDb covers rich movie and TV metadata, while Trakt covers watch history, watchlists, ratings, lists, calendars, scrobbling, and user sync.

Install

bun add @api-wrappers/trakt-wrapper
npm install @api-wrappers/trakt-wrapper

Quick Start

import { Trakt } from "@api-wrappers/trakt-wrapper";

const trakt = new Trakt({
	clientId: process.env.TRAKT_CLIENT_ID,
	accessToken: process.env.TRAKT_ACCESS_TOKEN,
});

const trending = await trakt.movies.trending({ limit: 10, extended: "full" });

for (const item of trending.data) {
	console.log(item.watchers, item.movie.title);
}

console.log(trending.pagination.itemCount);

OAuth

const trakt = new Trakt({
	clientId: process.env.TRAKT_CLIENT_ID,
	clientSecret: process.env.TRAKT_CLIENT_SECRET,
	redirectUri: "urn:ietf:wg:oauth:2.0:oob",
});

const authorizeUrl = trakt.auth.getAuthorizationUrl({ state: "state-token" });
console.log(authorizeUrl);

const token = await trakt.auth.exchangeCode("authorization-code");
trakt.setAccessToken(token.access_token);

Device code flow is also available:

const code = await trakt.auth.deviceCode();
console.log(code.verification_url, code.user_code);

const token = await trakt.auth.deviceToken(code.device_code);

Examples

Search Trakt by TMDb ID:

const [result] = await trakt.search.id("tmdb", 438631, { type: "movie" });
console.log(result.movie?.title);

Add a TMDb movie to the authenticated user's watchlist:

await trakt.sync.addWatchlist({
	movies: [{ ids: { tmdb: 438631 } }],
});

Scrobble a movie:

await trakt.scrobble.stop({
	progress: 90,
	movie: { ids: { tmdb: 438631 } },
});

Fetch a user's history:

const history = await trakt.users.history("me", "movies", undefined, {
	limit: 25,
});

console.log(history.pagination.pageCount);

Fetch the authenticated user's movie watchlist:

const watchlist = await trakt.sync.watchlist({
	type: "movies",
	sort: "rank",
	extended: "full",
});

Fetch another user's show watchlist with pagination:

const watchlist = await trakt.users.watchlist("sean", {
	type: "shows",
	sort: "added",
	limit: 20,
});

Included Endpoints

  • auth: OAuth authorization, token exchange, refresh, device flow, revoke
  • search: text search and ID lookup
  • movies: trending, popular, played, watched, collected, anticipated, details, comments, lists, people, ratings, related, stats, watching
  • shows: trending, popular, played, watched, collected, anticipated, details, seasons, comments, lists, people, ratings, related, stats, watching
  • seasons and episodes: summaries, comments, lists, people, ratings, stats, watching
  • calendars: all and authenticated show/movie calendars
  • users: profile, watching, watched, history, ratings, watchlist, collection, lists
  • sync: last activities, playback, watched, history, collection, watchlist, ratings
  • scrobble: start, pause, stop
  • checkin: create and remove check-ins
  • lists: trending, popular, summary, items, create, update, delete, add/remove items

Low-Level Requests

Use trakt.api when Trakt adds a new endpoint before the wrapper has a typed method for it.

const data = await trakt.api.get("/movies/trending", {
	query: { limit: 5, extended: "full" },
});

const page = await trakt.api.paginated("/movies/trending", {
	query: { page: 1, limit: 10 },
});

Runtime

This package uses the shared @api-wrappers/api-core HTTP runtime, so custom fetch, retry configuration, timeouts, transports, and plugins are supported.

const trakt = new Trakt({
	clientId: "client-id",
	fetch: customFetch,
	retry: { maxAttempts: 3, delayMs: 250 },
	timeoutMs: 10_000,
});

Quality Gates

bun run validate

validate runs source typechecking, test typechecking, the unit test suite, and the production build.