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

stophy

v0.3.0

Published

Official TypeScript SDK for Stophy - The YouTube context API for AI agents.

Readme

stophy

Official TypeScript SDK for Stophy YouTube context API for AI agents. Search videos, fetch transcripts, read comments and live chat, inspect channels and playlists, use YouTube Music and YouTube Kids, and get autocomplete suggestions, all returned as structured JSON.

Install

npm install stophy

Get an API key from your Stophy dashboard. The SDK sends it as Authorization: Bearer <key> on every request.

Quick start

import { Stophy } from "stophy";

const stophy = new Stophy(); // reads STOPHY_API_KEY
const result = await stophy.transcript(
  "https://www.youtube.com/watch?v=D7liwdjvhWc",
);
console.log(result.data.text);

Methods

| Method | Description | | --- | --- | | stophy.videoDetails(url) | Video metadata and related videos | | stophy.transcript(url) | Timestamped captions and full text | | stophy.comments(url, options?) | Top-level comments | | stophy.replies(token) | Replies for a comment thread | | stophy.liveChat(url, options?) | Live stream chat messages | | stophy.search(query, options?) | Search with filters | | stophy.channel(url, options?) | Channel metadata and content | | stophy.playlist(url, options?) | Playlist items, paginated | | stophy.suggest(query, options?) | Search autocomplete suggestions | | stophy.music(body) | YouTube Music search, suggestions, songs, lyrics, albums, artists, playlists | | stophy.kids(body) | YouTube Kids search and video metadata | | stophy.credits() | Current credit balance | | stophy.logs(query?) | Recent request logs | | stophy.usage(query?) | Daily credit/request counts |

Examples

// Search
const results = await stophy.search("typescript tutorial", {
  sortBy: "popularity",
  duration: "long",
});

// Comments (top-level), then replies to a comment.
// `video()` is overloaded on `type`, so `data` is typed - no casts needed.
const comments = await stophy.comments(videoUrl, { sortBy: "top" });
const firstReplyToken = comments.data.items[0]?.repliesToken;
if (firstReplyToken) {
  const replies = await stophy.replies(firstReplyToken);
}

// Channel videos
const channel = await stophy.channel("https://www.youtube.com/@mkbhd", {
  tab: "video",
});

// Autocomplete
const { data: s } = await stophy.suggest("react", { hl: "en", gl: "US" });
console.log(s.suggestions);

// YouTube Music
const music = await stophy.music({
  type: "search",
  q: "lofi",
  searchType: "song",
});
console.log(music.data.items);

// YouTube Kids
const kids = await stophy.kids({ type: "search", q: "science" });
console.log(kids.data.items);

// Account
console.log((await stophy.credits()).data.credits);

Pagination

List endpoints return a continuationToken. Pass it back in to fetch the next page:

let token: string | undefined;
do {
  const page = await stophy.search("lofi", { continuationToken: token });
  // ...handle page.data.items
  token = page.data.continuationToken ?? undefined;
} while (token);

Errors

Non-2xx responses throw a StophyError:

import { Stophy, StophyError } from "stophy";

try {
  await stophy.credits();
} catch (err) {
  if (err instanceof StophyError) {
    console.error(err.status, err.code, err.message, err.requestId);
    // err.code: "UNAUTHORIZED" | "INSUFFICIENT_CREDITS" | "BAD_REQUEST" |
    //           "INVALID_INPUT" | "NOT_FOUND" | "CONCURRENCY_LIMITED" | "INTERNAL_ERROR"
  }
}

License

MIT