ytsearch.js
Guide

YouTube Search with TypeScript

Use ytsearch.js as a typed dependency in TypeScript applications.

1

Import the API

Import functions and types from ytsearch.js.

2

Annotate where useful

SearchResult and SearchOptions can make application boundaries explicit.

3

Handle errors

Use YtSearchError for typed error handling.

ts
import { searchYouTube, type SearchResult } from "ytsearch.js";

const result: SearchResult = await searchYouTube("typescript", {
  type: "video",
  limit: 20,
});