A Node.js REST API server that recreates Spotify's "blend" feature, allowing users to share and compare musical preferences.
- Spotify OAuth2 Authentication: Secure login with Spotify accounts
- User Profile Management: Access user profiles and music preferences
- Top Artists & Tracks: Retrieve users' most listened to artists and tracks
- Preference Sharing: Generate shareable links to compare music tastes
- Artist Comparison: Analyze and compare musical preferences between users
- Blend Playlist Creation: Automatically generate playlists based on shared musical interests
- Track Recommendations: Get personalized recommendations based on common artists
- Runtime: Node.js
- Framework: Express.js
- Authentication: Spotify OAuth2
- HTTP Client: Axios
- Session Management: express-session
- Documentation: Swagger UI
- Node.js (v14 or higher)
- npm or yarn
- Spotify Developer Account
- Go to Spotify Developer Dashboard
- Create a new application
- Note your Client ID and Client Secret
- Add
http://localhost:8080/api/auth/callbackto your Redirect URIs in the app settings
# Clone the repository
git clone <your-repo-url>
cd Server
# Install dependencies
npm installCreate a .env file in the root directory:
cp .env.example .envEdit .env with your Spotify credentials:
SPOTIFY_CLIENT_ID=your_spotify_client_id_here
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_here
SPOTIFY_REDIRECT_URI=http://localhost:8080/api/auth/callback
PORT=8080
NODE_ENV=development
SESSION_SECRET=your_random_session_secret_here# Development mode (with auto-reload)
npm run dev
# Production mode
npm startThe server will start at http://localhost:8080
Once the server is running, access the interactive API documentation at:
- Swagger UI:
http://localhost:8080/api-docs
GET /api/auth/login- Initiate Spotify OAuth flowGET /api/auth/callback- OAuth callback handlerPOST /api/auth/refresh- Refresh access tokenPOST /api/auth/logout- Logout user
GET /api/user/profile- Get current user's profileGET /api/user/top-artists- Get user's top artistsGET /api/user/top-tracks- Get user's top tracksGET /api/user/:userId/profile- Get specific user's profile
POST /api/preference/create-link- Create a preference sharing linkGET /api/preference/link/:linkId- Get preference link detailsPOST /api/preference/accept/:linkId- Accept and compare preferencesGET /api/preference/my-links- Get all links created by user
POST /api/playlist/create-blend- Create a blend playlistGET /api/playlist/recommendations- Get track recommendationsGET /api/playlist/my-playlists- Get user's playlistsGET /api/playlist/:playlistId- Get specific playlist details
-
Authentication:
- User visits
/api/auth/login - Redirected to Spotify for authorization
- Callback returns access token
- User visits
-
Create Preference Link:
- POST to
/api/preference/create-link - Receive shareable link
- POST to
-
Share & Compare:
- Share link with friends
- They POST to
/api/preference/accept/:linkId - Receive comparison results showing common artists and match percentage
-
Create Blend Playlist:
- Use common artist IDs from comparison
- POST to
/api/playlist/create-blend - Playlist created in Spotify account
time_range:short_term(4 weeks),medium_term(6 months),long_term(all time)limit: Number of results (default: 20)
seed_artists: Comma-separated artist IDslimit: Number of recommendations (default: 20)
Server/
├── src/
│ ├── config/
│ │ └── spotify.js # Spotify API configuration
│ ├── middleware/
│ │ └── auth.js # Authentication middleware
│ ├── routes/
│ │ ├── auth.js # Authentication routes
│ │ ├── user.js # User profile routes
│ │ ├── preference.js # Preference sharing routes
│ │ └── playlist.js # Playlist management routes
│ └── index.js # Main server file
├── .env.example # Environment variables template
├── .gitignore
├── package.json
└── README.md
Currently, preference links and user data are stored in-memory using JavaScript Maps. For production use, implement a proper database (MongoDB, PostgreSQL, etc.).
All endpoints include comprehensive error handling with appropriate HTTP status codes:
400: Bad Request401: Unauthorized404: Not Found500: Internal Server Error
- Never commit
.envfile to version control - Keep your Spotify Client Secret secure
- Use HTTPS in production
- Implement rate limiting for production use
- Consider using a database for session storage in production
# Install nodemon for development
npm install -D nodemon
# Run with auto-reload
npm run dev- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
ISC
For issues and questions, please create an issue in the repository.
- Based on the original VibeLink Spring Boot Server
- Built with Spotify Web API