youtubei.js Documentation

repository·main·Indexed 26 days ago

https://github.com/luanrt/youtube.js

A JavaScript client for YouTube's private internal API, InnerTube, compatible with Node.js, Deno, and modern web browsers. It provides specialized clients for YouTube Kids, Music, and Studio, along with managers for accounts, interactions, and playlists. The library includes a comprehensive Parser namespace for data transformation, ProtoUtils for protocol encoding/decoding, and a robust set of type definitions for request and response objects.

Tokens
111.7K
Snippets
21
Records
1.1K
Agent score
88%

What's inside youtubei.js

  1. Overview of the youtubei.js Parser namespace

    main
    The Parser namespace in youtubei.js provides a suite of functions and type definitions for processing and transforming YouTube data structures. It includes utilities for parsing specific YouTube response formats (like parseResponse, parseFormats, parseRR), handling mutations (applyMutations), and managing error handling via ParserError and ParserErrorHandler.
  2. Explore YTNodes classes in youtubei.js

    main

    The YTNodes namespace contains a comprehensive collection of classes representing various YouTube UI components, data structures, and API endpoints parsed from YouTube's internal data formats. These classes allow developers to programmatically interact with and understand the structure of YouTube's responses, including videos, channels, playlists, comments, live chat, and search results.

    Key categories of nodes include:

    • Media Entities: Video, Channel, Playlist, Movie, Shorts (via ReelItem).
    • UI Components: Button, Card, Grid, ListView, Shelf, ThumbnailView.
    • Interaction Endpoints: SubscribeEndpoint, LikeEndpoint, ShareEndpoint, WatchEndpoint.
    • Live Features: LiveChat, LiveChatParticipant, LiveChatTextMessage.
    • Metadata & Info: VideoPrimaryInfo, ChannelMetadata, Transcript.
  3. Use specialized YouTube clients in youtubei.js

    main

    The youtubei.js library provides specialized client classes to interact with different versions of the YouTube platform. Depending on your use case, you can instantiate one of the following clients:

    • Kids: For interacting with the YouTube Kids interface.
    • Music: For interacting with the YouTube Music interface.
    • Studio: For interacting with the YouTube Studio interface (creator dashboard).

    Each client provides a specific set of methods and data structures tailored to that platform's API.

  4. Use youtubei.js Managers to handle specific YouTube entities

    main

    The youtubei.js library provides specialized Manager classes to interact with different aspects of YouTube. These managers encapsulate the logic for managing accounts, user interactions, and playlists.

    Available Managers:

    • AccountManager: For managing user accounts and authentication-related tasks.
    • InteractionManager: For handling user interactions like likes, dislikes, and comments.
    • PlaylistManager: For managing playlists, including creation, modification, and retrieval.
  5. Explore youtubei.js API Reference

    main

    The youtubei.js API is organized into several namespaces, classes, and interfaces to interact with YouTube services.

    Key Namespaces

    • YT, YTMusic, YTKids, YTShorts: Specialized namespaces for different YouTube service flavors.
    • Parser: For handling data parsing.
    • Clients: For managing different client configurations.
    • Managers: For high-level service management.
    • Utils & Helpers: For general utility functions.

    Core Classes

    • Innertube: The primary entry point for interacting with the YouTube InnerTube API.
    • Player: For managing video playback data and configurations.
    • OAuth2: For handling authentication flows.
    • HTTPClient: For managing underlying network requests.

    Data Contracts

    • Interfaces: Includes ApiResponse, IPlayerResponse, IStreamingData, and IPlayabilityStatus for structured data handling.
    • Type Aliases: Defines request/response shapes such as SearchRequest, BrowseRequest, WatchRequest, and PlaylistEditRequest.
  6. MediaInfo Class Overview

    main
    The MediaInfo class is a mixin that provides core media metadata and playback capabilities. It is extended by several specialized classes including VideoInfo (for YouTube), TrackInfo (for YouTube Music), VideoInfo (for YouTube Kids), and ShortFormVideoInfo (for YouTube Shorts). It contains essential properties like basic video information, streaming data, captions, and player configurations, along with methods for downloading, streaming, and interacting with watch history.
  7. Explore the YT namespace classes in youtubei.js

    main
    The YT namespace in youtubei.js provides access to various classes representing different YouTube entities and features. You can use these classes to interact with specific parts of the YouTube platform, such as searching for videos, managing playlists, viewing channel information, or accessing video details and transcripts.