Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

youtube-music-ts-api

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

youtube-music-ts-api

An unofficial YouTube Music API written in TypeScript for easy integration into your projects

  • 1.8.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-54.55%
Maintainers
0
Weekly downloads
 
Created
Source

youtube-music-ts-api

Description

This is a TypeScript API for YouTube Music (not to be confused with music videos and what not that you can watch on YouTube). This is written in TypeScript with all the appropriate types exported, so that you can easily use this API in your developer tools.

Using the API

This node module can be used as a dependency of another node module. Run npm install youtube-music-ts-api --save to add it as a dependency to your node module. An example usage of the module (note this example was built with TypeScript using these options tsc demo.ts --target es6 --module commonjs):

import YouTubeMusic from "youtube-music-ts-api";

async function main(): Promise<void> {
    const cookieStr = "TODO: PUT YOUR COOKIE STRING HERE";
    const ytm = new YouTubeMusic();
    const ytma = await ytm.authenticate(cookieStr);
    const playlists = await ytma.getLibraryPlaylists();
    if (playlists) {
        for (const playlist of playlists) {
            console.log("Playlist: " + playlist.name);
            const playlistDetail = await ytma.getPlaylist(playlist.id);
            if (playlistDetail) {
                for (const track of playlistDetail.tracks) {
                    console.log("    Track: " + track.title);
                }
            }
        }
    }
}
main();

For more detailed information regarding the API, visit the DOCUMENTATION.md.

Contributing

It would be greatly appreciated to have others contribute into this project by submitting pull requests that can be merged. The main things that could be worked on would be improved API authentication to remove the current manual process and/or building out more API calls that YouTube Music provides. All other features and changes are welcome as well pending a code review. Some commands that are useful when developing in this project are:

  1. Run npm install to initialize the project.
  2. Run npm run test to run the unit tests or npm run test-coverage to retrieve code coverage.
  3. Run npm run build to build the production version of the API or npm run build-debug to build a debuggable version of the API.
  4. Run npm run build-docs to build an updated API documentation markdown file.

Attribution

A huge thanks goes to the ytmusicapi which is a Python API that did a lot of the groundwork reverse engineering the YouTube Music API.

Thanks to this StackOverflow post for reverse engineering the authentication to the YouTube Music API (which is attributed in the source code of ytmusicapi).

Thanks to YouTube Music for building a platform for our music pleasures.

Keywords

FAQs

Package last updated on 31 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc