API Reference
searchYouTube
Search YouTube for videos, channels, playlists, movies or live streams and return normalized, paginated results.
ts
searchYouTube(query: string, options?: SearchOptions): Promise<SearchResult>Parameters
| Name | Type | Description |
|---|---|---|
query | string | Search query. Must be a non-empty string. |
options | SearchOptions | Optional type, sort and limit settings. |
Returns
Resolves to SearchResult.
Example
js
import { searchYouTube } from "ytsearch.js";
const results = await searchYouTube("JavaScript tutorial", {
type: "video",
sort: "relevance",
limit: 20,
});
console.log(results.videos);
console.log(results.metadata);