Simple API Project for NodeJS written in TypeScript inspired by sigma67's python library
These instructions will get you a copy of the project up and running on your local machine for development.
- NodeJS 10+
- Yarn v2
- Google Account (optional)
Clone github repo
$ git clone https://github.com/vladdenisov/ytmusic-api
Install dependencies
$ yarn
Build it
$ yarn build
You will see dist
folder, where all built files are stored.
You should be able to just use it, if you need only information-getting features:
const api = new YTMUSIC()
const data = await api.getPlaylist('RDCLAK5uy_k1Wu8QbZASiGVqr1wmie9NIYo38aBqscQ')
console.log(data.title)
Get the auth cookie from requests to YTMusic in your browser:
- Open YouTube Music in browser
- Go to the developer tools (Ctrl-Shift-I) and find an authenticated POST request. You can filter for /browse to easily find a suitable request.
- Copy
cookie
fromRequest Headers
Import lib to your code:
const { YTMUSIC } = require('ytmusic')
// or if you build it yourself
const { YTMUSIC } = require('path/to/ytmusic/dist/index.js')
Create new Instance of api with your cookie:
const api = new YTMUSIC("cookie")
// or if you want it to use not default account, specify userID (refer to docs to get it):
const api = new YTMUSIC("cookie", "userID")
Use it:
const data = await api.getPlaylist('RDCLAK5uy_k1Wu8QbZASiGVqr1wmie9NIYo38aBqscQ')
console.log(data.title)
// { text: '80s Pop-Rock Anthems' }
- TypeScript - JavaScript that scales.
- node-fetch - A light-weight module that brings window.fetch to Node.js
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Just contribute <3
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Vlad Denisov - Initial work - vladdenisov
- Daniel Leong - dhleong
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details