Downloads Code coverage Latest release Commits since latest release

ytmusicapiJS: Unofficial API for YouTube Music

ytmusicapiJS is a TypeScript implementation of the Python 3 library ytmusicapi

It emulates YouTube Music web client requests using the user's cookie data for authentication.

This library is intended to carry the same functionality as the library it is inspired by. As such, unless the need becomes great enough for a specific feature in this library, I recommend all API specific changes be directed to ytmusicapi instead.

Features

See API here https://codyduong.github.io/ytmusicapiJS/

Feature Parity

✅ - Implemented

🐣 - Partially implemented

❌ - Not implemented

Feature Implementation Status ytmusicapi version parity
Browsing
search (w/ filters)0.21.0
get artist info0.21.0
get user info0.21.0
get albums0.21.0
get song metadata0.21.0
get watch playlists0.21.0
get song lyrics0.21.0
Exploring
get moods/genres playlists0.21.0
get latest charts0.21.0
Library Management
get library contents0.21.0
add/remove library content0.21.0
Playlists
create/delete playlists0.21.0
modify playlists0.21.0
get playlist contents0.21.0
Uploads
upload/remove songs0.21.0
list uploaded songs0.21.0
Other
locale0.21.0

Setup and Usage

npm yarn
npm install @codyduong/ytmusicapi yarn add @codyduong/ytmusicapi

Quick Usage Snippet

import YTMusic from '@codyduong/ytmusicapi';

const ytm = new YTMusic()

const results = await ytm.search('Rickroll')

results

[
  {
    category: 'Top result',
    resultType: 'video',
    title: 'Never Gonna Give You Up',
    views: null,
    videoId: 'dQw4w9WgXcQ',
    duration: null,
    year: null,
    artists: [ [Object], [Object] ],
    thumbnails: [ [Object] ]
  },
  {
    category: 'Songs',
    resultType: 'song',
    title: 'Never Gonna Give You Up',
    album: null,
    feedbackTokens: { add: null, remove: null },
    videoId: 'lYBUbBu4W08',
    duration: null,
    year: null,
    artists: [ [Object], [Object] ],
    isExplicit: false,
    thumbnails: [ [Object], [Object] ]
  },
  {
    category: 'Songs',
    resultType: 'song',
    title: 'Rickroll',
    album: null,
    feedbackTokens: { add: null, remove: null },
    videoId: 'oBKeQItWbnA',
    duration: null,
    year: null,
    artists: [ [Object], [Object], [Object] ],
    isExplicit: false,
    thumbnails: [ [Object], [Object] ]
  },
  ...
]

Documentation

The API does support usage in browsers, however you will have to use a proxy since YTmusic does not have CORS support.

Contributing

The library is intended to keep features within the same scope of the original Python 3 library. This may/may not change at my discretion.

Pull requests are welcome, esp. with regards to resolving any API differences that occured through mistakes or otherwise. However, note that I would like to remain with similar API to the original library, so it is unlikely new API features will be approved (unless strictly relevant to the JS/TS version).

The source code is structured almost identically to the Python 3 Library. I've also mocked some other dependencies, this is to maintain readability and ease of changes between the two APIs.

Acknowledgements

A majority of this codebase is possible thanks to the work done by sigma67