Zero-setup music discovery CLI for Spotify - just clone, build, and start finding music!
A natural language Spotify search tool that understands your mood, vibe, and era preferences using AI-powered query parsing and Spotify's recommendation engine.
No Spotify app registration, no API keys, no configuration - just works!
- π Zero Setup: Works immediately without any configuration
- π Secure Authentication: Uses Spotify's Authorization Code Flow with PKCE
- π― Smart Port Detection: Automatically finds available ports for authentication
- π€ AI-Powered Search: Natural language processing for mood and genre understanding
- π΅ Smart Recommendations: Leverages Spotify's recommendation API
- πΎ Token Management: Automatic token refresh and secure local storage
- π Cross-Platform: Works on macOS, Linux, and Windows
# 1. Clone and build
git clone https://github.com/lorrehuggan/moodify.git
cd moodify
go build
# 2. Login (opens browser automatically)
./moodify login
# 3. Start discovering music!
./moodify search happy energetic workout songs
./moodify search chill 90s alternative rock
./moodify search sad indie songs for rainy daysThat's it! No configuration files, no API keys, no Spotify app setup required.
# Just run this - it handles everything automatically
./moodify login
# Advanced: Use specific port if needed
./moodify login --port 9000
# Advanced: Use your own Spotify app
./moodify login --client-id "your_client_id_here"# See authentication status and configuration
./moodify status./moodify logout# Mood-based search
./moodify search chill lofi study music
./moodify search energetic workout songs
./moodify search sad melancholy indie
# Era-based search
./moodify search 90s alternative rock
./moodify search 2000s pop hits
# Genre-specific
./moodify search jazz fusion instrumental
./moodify search deep house electronic
# Combined preferences
./moodify search happy 80s dance music
./moodify search relaxing ambient for sleep
# Advanced options
./moodify search --limit 25 --market GB indie rock--limit, -n: Number of tracks to return (1-100, default: 15)--market: ISO market code for regional results (default: US)
Moodify works immediately without any setup using a shared Spotify application. Your authentication is still completely private and secure.
For power users who want their own Spotify app:
# Optional: Use your own Spotify Client ID
export SPOTIFY_CLIENT_ID="your_client_id_here"
# Optional: Run the setup wizard
./moodify setupMoodify works great out-of-the-box, but adding OpenAI makes it significantly smarter:
# Get your API key from https://platform.openai.com/api-keys
export OPENAI_API_KEY="sk-your-openai-api-key-here"π€ With OpenAI enabled:
- Much better understanding of complex mood descriptions
- Smarter genre detection and audio feature mapping
- More accurate results for phrases like "nostalgic dreamy shoegaze" or "aggressive workout metal"
π Without OpenAI (default):
- Uses basic keyword matching
- Still works well for simple queries like "chill jazz" or "happy pop"
- Completely free and private
π‘ How to get an OpenAI API key:
- Sign up at https://platform.openai.com/
- Add a payment method (pay-per-use, typically $0.01-0.10 per search)
- Create an API key in your dashboard
- Export it:
export OPENAI_API_KEY="your_key_here"
The app will automatically detect and use OpenAI when available, and clearly indicate when AI processing is being used.
- Config Directory:
~/.config/moodify/ - Token Storage:
~/.config/moodify/token.json
Moodify uses a pre-configured shared Spotify application for instant setup:
- Smart Port Detection: Automatically finds an available port (8808, 8080, 3000, etc.)
- Secure PKCE Flow: Uses Spotify's Authorization Code Flow with PKCE
- Browser Integration: Opens your browser automatically (with fallback for headless systems)
- Token Management: Securely stores and auto-refreshes your personal tokens
- Privacy First: Your tokens never leave your machine
The app processes your search query using:
- π€ AI Enhancement (when
OPENAI_API_KEYis set): GPT-4o-mini powered query analysis that understands complex mood descriptions, musical nuances, and context - π Fallback Parser (default): Keyword-based mood and genre detection using curated patterns
- π΅ Audio Feature Mapping: Converts natural language to Spotify's tuneable attributes (danceability, energy, valence, tempo, etc.)
The app will always tell you which parsing method it's using and automatically falls back to keyword parsing if AI fails.
- Uses Spotify's recommendation engine with calculated audio features
- Supports genre seeds, artist seeds, and audio attribute ranges
- Post-filters results by era/year when specified
- Balances popular and discoverable tracks
- β No passwords handled: Uses OAuth2 flow only
- β No client secrets: PKCE eliminates need for secrets
- β Secure token storage: Tokens stored with 600 permissions
- β Automatic token refresh: Handles token expiry transparently
- β Local-only storage: No data sent to third parties
# Try a specific port
./moodify login --port 9999
# Check what's happening
./moodify statusThe app automatically displays the authorization URL to copy/paste manually.
- Check status:
./moodify status - Try logout and login:
./moodify logout && ./moodify login - For persistent issues, try custom setup:
./moodify setup
# Check if OpenAI is detected
./moodify status
# Test with a complex query to see the difference
./moodify search melancholic indie with dreamy reverbCommon OpenAI problems:
- Invalid API key: Check your key at https://platform.openai.com/api-keys
- Billing required: OpenAI requires a payment method for API access
- Rate limits: Wait a moment and try again
- Network issues: The app automatically falls back to basic parsing
- Try broader search terms
- Check your market setting
- Increase limit:
./moodify search --limit 50 your query - If using complex descriptions without OpenAI, try simpler keywords
moodify/
βββ cmd/ # CLI commands
β βββ login.go # Authentication command
β βββ logout.go # Logout command
β βββ search.go # Search command
β βββ root.go # Root command setup
βββ internal/
β βββ auth/ # PKCE authentication
β βββ ai/ # Query parsing & AI integration
β βββ spotify/ # Spotify API wrapper
βββ main.go # Application entry point
βββ go.mod # Dependencies
git clone https://github.com/lorrehuggan/moodify.git
cd moodify
go mod tidy
go build- Cobra - CLI framework
- Spotify Web API SDK - Spotify API client
- OpenAI Go SDK - AI query processing
- Shared App: Uses a pre-registered Spotify application with multiple redirect URIs
- PKCE Security: No client secrets involved - your authentication is still private
- Smart Fallbacks: Tries multiple ports and provides guidance if issues occur
- Optional Advanced Setup: Power users can still configure their own Spotify app
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
- π Create an issue
- π¬ Discussions
- π Spotify Web API Documentation
π΅ Start discovering music in 30 seconds: moodify login