A powerful Node.js/Express.js API that provides access to multiple music streaming services including YouTube Music, YouTube Search, Last.fm, Saavn, Piped, and Invidious. Perfect for building music applications, playlists, and discovery features.
# Clone the repository
git clone https://github.com/Shashwat-CODING/ytify-backend.git
cd Music/js
# Install dependencies
npm install
# Start the server
npm start
The API will be available at http://localhost:5000
Create a .env
file:
PORT=5000
NODE_ENV=development
LASTFM_API_KEY=your_lastfm_api_key
http://localhost:5000
GET /health
Search for songs, albums, artists, and playlists on YouTube Music.
GET /api/search?q={query}&filter={type}&limit={number}
Parameters:
q
(required): Search queryfilter
(optional): songs
, albums
, artists
, playlists
, videos
limit
(optional): Number of results (default: 20)Example:
curl "http://localhost:5000/api/search?q=edm&filter=songs&limit=10"
Response:
{
"success": true,
"results": [
{
"id": "dQw4w9WgXcQ",
"title": "Never Gonna Give You Up",
"artist": "Rick Astley",
"duration": "3:33",
"thumbnail": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg",
"type": "song"
}
]
}
Search YouTube videos, channels, and playlists.
GET /api/yt_search?q={query}&filter={type}&limit={number}
Example:
curl "http://localhost:5000/api/yt_search?q=music&filter=videos&limit=5"
Get search suggestions for autocomplete features.
GET /api/search/suggestions?q={query}
Example:
curl "http://localhost:5000/api/search/suggestions?q=edm"
Get streaming URLs from multiple sources (Saavn, Piped, Invidious).
GET /api/stream?id={videoId}&title={title}&artist={artist}
Parameters:
id
(required): YouTube video IDtitle
(optional): Song title for Saavn matchingartist
(optional): Artist name for Saavn matchingExample:
curl "http://localhost:5000/api/stream?id=dQw4w9WgXcQ&title=Never%20Gonna%20Give%20You%20Up&artist=Rick%20Astley"
Response:
{
"success": true,
"service": "saavn",
"instance": "saavn.dev",
"streamingUrls": [
{
"url": "https://...",
"quality": "320kbps",
"format": "mp3"
}
],
"metadata": {
"title": "Never Gonna Give You Up",
"artist": "Rick Astley",
"duration": "3:33"
}
}
Get similar tracks using Last.fm recommendations.
GET /api/similar?title={title}&artist={artist}&limit={number}
Example:
curl "http://localhost:5000/api/similar?title=Shape%20of%20You&artist=Ed%20Sheeran&limit=5"
Get latest videos from subscribed channels (requires auth token).
GET /api/feed?authToken={token}&preview={boolean}
Get latest videos from specified channels.
GET /api/feed/unauthenticated?channels={channelIds}&preview={boolean}
Parameters:
channels
(required): Comma-separated channel IDspreview
(optional): Limit to 5 videos per channelExample:
curl "http://localhost:5000/api/feed/unauthenticated?channels=UCuAXFkgsw1L7xaCfnd5JJOw,UCBJycsmduvYEL83R_U4JriQ&preview=1"
Alternative endpoint format for channel feeds.
GET /api/feed/channels={channelIds}?preview={boolean}
Example:
curl "http://localhost:5000/api/feed/channels=UCuAXFkgsw1L7xaCfnd5JJOw,UCBJycsmduvYEL83R_U4JriQ?preview=1"
Response:
[
{
"id": "dQw4w9WgXcQ",
"authorId": "UCuAXFkgsw1L7xaCfnd5JJOw",
"duration": "3:33",
"author": "Rick Astley",
"views": "1.2B",
"uploaded": "2009-10-25T06:57:33.000Z",
"title": "Never Gonna Give You Up"
}
]
Fetch detailed information about an album.
GET /api/album/{albumId}
Example:
curl "http://localhost:5000/api/album/MPREb_qTDpBqltt6c"
Response:
{
"success": true,
"album": {
"id": "MPREb_qTDpBqltt6c",
"playlistId": "OLAK5uy_mwBKAsTr40eAsSEDTgy6iiEoI2edmH9q8",
"title": "Releases for you",
"artist": "Nseeb",
"year": "2025",
"thumbnail": "https://lh3.googleusercontent.com/...",
"tracks": [
{
"id": "K9R7KcaettM",
"title": "I Really Do...",
"artist": "Nseeb",
"duration": "3:14",
"thumbnail": "https://i.ytimg.com/vi/K9R7KcaettM/hqdefault.jpg",
"videoId": "K9R7KcaettM"
}
]
}
}
The API automatically fetches and caches streaming instances from remote sources:
https://raw.githubusercontent.com/n-ce/Uma/main/dynamic_instances.json
saavn.dev
for reliable access{
"success": true,
"data": [...],
"timestamp": "2025-10-16T04:52:24.045Z"
}
{
"success": false,
"error": "Error message",
"code": "ERROR_CODE"
}
{
"success": true,
"results": [...],
"pagination": {
"page": 1,
"limit": 20,
"total": 100,
"hasMore": true
}
}
js/
├── app.js # Main Express application
├── api/
│ └── app.js # Vercel serverless entry point
├── lib/ # Custom libraries
│ ├── ytmusicapi.js # YouTube Music API
│ ├── youtube-search.js # YouTube Search API
│ ├── lastfm_api.js # Last.fm integration
│ └── get_youtube_song.js # YouTube song helper
├── routes/
│ └── api.js # Main API routes
├── vercel.json # Vercel configuration
├── package.json # Dependencies
└── README.md # This file
# Development
npm run dev
# Production
npm start
# Test
npm test
The API is configured for Vercel deployment:
vercel.json
configuration will handle the deploymentLASTFM_API_KEY=your_lastfm_api_key
NODE_ENV=production
MIT License - see LICENSE file for details.
For issues and questions:
Made with ❤️ for the music community