Unofficial REST API for YouTube Music — search, tracks, lyrics and albums via Innertube.
⚠️ Disclaimer: This project is not affiliated with Google or YouTube. It uses YouTube Music's internal Innertube API for educational and personal use only. Respect YouTube's Terms of Service.
- 🔍 Search — songs, videos, albums, artists, playlists
- 🎵 Track metadata — title, artist, duration, thumbnail, view count
- 📝 Lyrics — full lyrics text when available
- 💿 Album pages — metadata + full track list
- ❤️ Health check endpoint
- 🛠️ Dev tool — built-in structure explorer for debugging Innertube responses
Requirements: Node.js 18+
git clone https://github.com/BoziaO/BoziaYT4PI.git
cd BoziaYT4PI
npm install
npm startServer runs at http://localhost:3001 by default.
All endpoints return JSON. Errors use { "error": "message" } with appropriate HTTP status codes.
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
GET |
/search?q=...&filter=... |
Search YouTube Music |
GET |
/song/:videoId |
Track details |
GET |
/lyrics/:videoId |
Track lyrics |
GET |
/album/:browseId |
Album metadata + tracklist |
Search filters: songs (default) · videos · albums · artists · playlists
# Search for songs
curl "http://localhost:3001/search?q=oasis&filter=songs"
# Get track details
curl "http://localhost:3001/song/dQw4w9WgXcQ"
# Get lyrics
curl "http://localhost:3001/lyrics/dQw4w9WgXcQ"
# Get album
curl "http://localhost:3001/album/MPREb_9nMX15oNiJk"Search response
[
{
"videoId": "dQw4w9WgXcQ",
"title": "Never Gonna Give You Up",
"artist": "Rick Astley",
"thumbnail": "https://..."
}
]Song response
{
"videoId": "dQw4w9WgXcQ",
"title": "Never Gonna Give You Up",
"author": "Rick Astley",
"durationSeconds": 213,
"thumbnail": "https://...",
"viewCount": "1400000000"
}Lyrics response
{
"lyrics": "We're no strangers to love..."
}Album response
{
"title": "Whenever You Need Somebody",
"artist": "Rick Astley",
"year": "1987",
"thumbnail": "https://...",
"tracks": [ ... ]
}BoziaYT4PI/
├── api/
│ ├── server.js # Express app & route definitions
│ ├── ytmusic.js # Innertube client and response parsers
│ └── find-structure.js # CLI tool for debugging Innertube JSON
├── .env.example
├── package.json
└── README.md
When YouTube changes its internal API and parsers break, use this CLI to inspect raw responses:
npm run explore -- search "radiohead"
npm run explore -- song dQw4w9WgXcQ
npm run explore -- next dQw4w9WgXcQ
npm run explore -- browse MPREb_9nMX15oNiJk
npm run explore -- diff snapshot-a.json snapshot-b.jsonSnapshots are saved to api/ytmusic-snapshots/ (gitignored).
- YouTube Music's Innertube API is undocumented and may change at any time.
- This project is intended for educational and personal use only.
- Do not use it to circumvent YouTube's monetization or violate copyright law.
Maciej (Bozia) — github.com/BoziaO · Portfolio