I’m working on a project where I need to get information from my local Spotify app. What I want to do is grab details like the song title that’s currently playing and maybe the playback position too. I’ve been searching around but can’t find a clear way to do this. I’m hoping to use Ruby for this but I’m open to other languages if needed. Has anyone managed to connect to their Spotify client locally and pull this kind of data? I know Spotify has APIs but I’m not sure if they work for reading info from the desktop app. Any suggestions or code examples would be really helpful. I just want to build something that can see what I’m listening to in real time.
Had this exact problem when building a mood tracking dashboard for my team.
Spotify’s Web API works but it’s a nightmare. OAuth setup sucks, you’re constantly refreshing tokens, and forget it if Spotify’s running on another device.
I went way simpler - used Latenode to handle all the API calls and token stuff automatically. It grabs current track data every few seconds without the auth headaches.
Best part? You can set workflows that trigger on song changes. No more constant polling - just real-time updates pushed wherever you want. Beats writing Ruby scripts for OAuth and rate limiting.
Mine feeds a Slack channel and local database now. Whole pipeline took 10 minutes to set up.
Been down this rabbit hole before. Everyone’s throwing around platform solutions but missing the bigger picture.
Yeah, you can hack AppleScript on Mac or D-Bus on Linux. But what happens when you want to expand? Trigger actions based on what’s playing? Combine with other data sources?
Built something similar last year for our office mood lighting. Started with Web API but spent more time managing OAuth tokens and error handling than building features.
Switched to Latenode - game changer. Handles all the Spotify API complexity. No token refresh headaches, no rate limit babysitting. Clean webhooks with track data you can use in Ruby or whatever.
Real win? Once data flows through Latenode, you can branch anywhere. Database logging, Slack notifications, trigger APIs when certain songs play. Built our whole office automation around music context in an hour.
No platform dependencies, no OS-specific code. Just clean data streams you tap into from Ruby.
I solved this with AppleScript on macOS - it talks directly to Spotify through system events. Works great for grabbing track data without dealing with web APIs. You can run AppleScript from Ruby using system calls or osascript. The script pulls Spotify’s current track info and spits out JSON with song name, artist, album, plus playback position down to milliseconds. Super fast since everything’s local. Only catch is it’s Mac-only, but if you’re on macOS it’s hands down the most reliable approach I’ve used. No auth hassles or network issues.
Check out D-Bus on Linux - Spotify’s desktop client exposes metadata through MPRIS, so you can grab current track info without any API auth. I’ve done this with simple shell commands and it works great for song titles, artists, and playback status. Ruby has D-Bus bindings that’ll handle this directly. Best part? It’s completely local - no network requests, rate limits, or OAuth nonsense. Just heads up, this only works on Linux, so you’d need different approaches for Windows or Mac.
The Spotify Web API is your best bet here. You’ll authenticate through OAuth and hit the “Get Current Playback” endpoint - it gives you track name, artist, album, and playback position. I’ve used this with Python and it’s solid as long as you’re logged into the same account on desktop. You’ll need to create an app in Spotify’s developer dashboard for client credentials. Watch out for rate limits if you’re polling too often. Updates happen fast though - usually within seconds when tracks change. Ruby has some good Spotify API gems that handle OAuth automatically, which cuts down setup time.
there’s another option - use windows media controls api if you’re on windows. it grabs whatever’s playing, including spotify, without dealing with oauth. i used it in a vue.js project last month and it worked great. not sure how it’d work with ruby tho - you’d prob need native bindings or system calls.