gitmyhub

librespot

Rust ★ 6.9k updated 6d ago

Open Source Spotify client library

librespot is a Rust library that lets developers build custom Spotify Connect receivers, so any device or app can appear as a Spotify speaker without relying on Spotify's discontinued official library.

RustCargoALSAPulseAudioGStreamersetup: moderatecomplexity 3/5

librespot is an open source Rust library that lets applications play music from Spotify and act as a Spotify Connect receiver. Spotify Connect is the feature that allows you to choose which device plays music from within the Spotify app, the way you might send audio from your phone to a smart speaker. With librespot, developers can build custom devices or software that appear as Spotify speakers without relying on Spotify's official, now discontinued, closed-source library.

The library only works with Spotify Premium accounts, and the maintainers have stated they will not add support for free-tier features such as ads or skipping limits.

To use it, you install it via Cargo, Rust's package manager, with a single command. Once running, it creates a named receiver that shows up in the Spotify app alongside any other Spotify Connect devices you own. You can set the audio bitrate, initial volume, volume normalization, and how the device appears in the app. Credentials and cached audio data are stored locally for repeat use.

On macOS and Windows, building requires no extra steps. On Linux, a small number of audio library packages need to be installed first. The library supports many audio output backends, including ALSA, PulseAudio, GStreamer, PortAudio, JACK, and SDL, so it fits into a wide range of Linux audio setups. Pre-built packages are also available through official package managers on Linux, FreeBSD, and NetBSD.

Several community projects build on librespot: Spotifyd turns it into a lightweight background service, ncspot wraps it in a terminal-based Spotify player, and raspotify makes it straightforward to set up a Raspberry Pi as a Spotify speaker.

Where it fits