librespot

An open source Spotify Connect receiver and client library that turns any device into a Spotify speaker.

librespot is an open source Rust implementation of the Spotify client protocol. It ships both as a library — used by projects like ncspot, Spotifyd, and Snapcast — and as a standalone headless binary that registers itself as a Spotify Connect receiver on your local network. Once running, any Spotify app on the same network can cast audio to it as if it were an official Spotify device: a speaker, an AV receiver, a Raspberry Pi, or any other machine you can run a binary on. It replaces the official libspotify, which Spotify deprecated and has since shut down.

Note: librespot requires a Spotify Premium account. Free accounts are not supported and this will not change.

Features

  • Spotify Connect receiver — appears as a castable device in the Spotify app on any platform without any additional pairing step.
  • Multiple audio backends — ships with support for Rodio (default), ALSA, GStreamer, PulseAudio, JACK, PortAudio, SDL, Pipe, and Subprocess backends, selectable at compile time.
  • Volume normalisation — built-in loudness normalisation keeps playback levels consistent across tracks.
  • Credential caching — stores an authentication blob locally so the daemon can restart without re-entering credentials.
  • Configurable device type — advertises itself as any Spotify device type (speaker, AVR, TV, computer, etc.), controlling which icon appears in the app.
  • Bitrate selection — choose 96, 160, or 320 kbps streaming quality.
  • Library crate — the core protocol, audio, and playback crates are published separately so other projects can embed Spotify Connect support without building the binary.

Installation

cargo install librespot

On Linux, audio playback requires ALSA development headers regardless of which backend you use:

# Debian / Ubuntu
apt install build-essential libasound2-dev

# Fedora
dnf install alsa-lib-devel make gcc

Then install the binary:

cargo install librespot
# macOS
# No ALSA dependency needed; Rodio uses CoreAudio automatically.
cargo install librespot

# Arch Linux
# Available in the community repository
pacman -S librespot

# Nix
nix-env -iA nixpkgs.librespot

Pre-built binaries for common architectures (including ARM for Raspberry Pi) are available on the releases page.

Usage

Basic headless receiver

# Start a Spotify Connect receiver named "Living Room"
librespot --name "Living Room"

Once running, open any Spotify client on the same network and the device will appear in the Connect device list.

Common options

# Set bitrate to 320 kbps, initial volume to 75%, enable normalisation
librespot \
  --name "Librespot" \
  --bitrate 320 \
  --initial-volume 75 \
  --enable-volume-normalisation

# Advertise as an AV receiver (changes the icon in the Spotify app)
librespot --name "Hi-Fi" --device-type avr

# Cache credentials and audio data in a local directory
librespot --name "Librespot" --cache ./cache

# Use PulseAudio instead of the default Rodio backend
librespot --name "Librespot" --backend pulseaudio

# Pipe raw audio to another process (e.g. for custom processing)
librespot --name "Librespot" --backend pipe --device /tmp/audio.pipe

Running as a systemd service

Create /etc/systemd/system/librespot.service:

[Unit]
Description=Librespot Spotify Connect receiver
After=network.target sound.target

[Service]
ExecStart=/usr/local/bin/librespot \
  --name "My Speaker" \
  --bitrate 320 \
  --enable-volume-normalisation \
  --cache /var/cache/librespot
Restart=on-failure
User=librespot

[Install]
WantedBy=multi-user.target
systemctl enable --now librespot

Compiling with a specific audio backend

The audio backend is selected at compile time via Cargo features:

# PulseAudio backend
cargo install librespot --features pulseaudio-backend

# GStreamer backend
cargo install librespot --features gstreamer-backend

# JACK backend
cargo install librespot --features jackaudio-backend

# Disable the default Rodio backend and use ALSA directly
cargo install librespot \
  --no-default-features \
  --features alsa-backend

librespot is the foundation for several higher-level Spotify clients:

ProjectDescription
ncspotCross-platform ncurses Spotify TUI (also on this site)
SpotifydLightweight UNIX daemon built on librespot
SpotGTK/Rust native Spotify client for GNOME
SnapcastSynchronised multi-room audio using librespot as a Spotify source
raspotifyTurnkey Spotify Connect for Raspberry Pi