Skip to content

Configuration

spotify-sync is configured via a JSON file, environment variables, and CLI flags. Settings are resolved in this order — higher items win:

  1. CLI flags (highest priority)
  2. Environment variables
  3. Config file
  4. Defaults (lowest priority)

Config file

Location: ~/.config/spotify-sync/config.json

The exact path is $XDG_CONFIG_HOME/spotify-sync/config.json. On most systems $XDG_CONFIG_HOME defaults to ~/.config.

A missing config file is not an error — spotify-sync will use environment variables and defaults for any fields not explicitly set.

Minimal config

The four fields below are required. Everything else has a sensible default.

json
{
  "spotify": {
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "playlist_url": "https://open.spotify.com/playlist/..."
  },
  "library": {
    "path": "/path/to/your/music"
  }
}

Full config with defaults shown

json
{
  "spotify": {
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "playlist_url": "https://open.spotify.com/playlist/..."
  },
  "library": {
    "id": "default",
    "path": "/path/to/your/music"
  },
  "download": {
    "backend": "yt-dlp",
    "format": "mp3",
    "bitrate_kbps": 320,
    "concurrency": 3,
    "retry_count": 3,
    "search_source": "youtube-music"
  },
  "logging": {
    "level": "info",
    "max_run_logs": 20
  }
}

Config field reference

spotify

FieldTypeRequiredDescription
spotify.client_idstringYesOAuth client ID from your Spotify developer app.
spotify.client_secretstringYesOAuth client secret. Used for token validation (not sent in the PKCE exchange).
spotify.playlist_urlstringYesFull Spotify playlist URL, e.g. https://open.spotify.com/playlist/....

library

FieldTypeDefaultDescription
library.pathstringRequiredAbsolute path to the directory where downloaded tracks are stored.
library.idstring"default"Logical library name. Reserved for future multi-library support; leave as "default" for now.

download

FieldTypeDefaultDescription
download.backendstring"yt-dlp"Download backend. Only "yt-dlp" is supported in v1.
download.formatstring"mp3"Output audio format.
download.bitrate_kbpsnumber320Target bitrate in kbps. Must be a positive integer.
download.concurrencynumber3Number of tracks to download in parallel. Must be a positive integer.
download.retry_countnumber3Number of retry attempts per track on failure. Must be a non-negative integer.
download.search_sourcestring"youtube-music"Search source used by yt-dlp when looking up a track.

logging

FieldTypeDefaultDescription
logging.level"debug" | "info" | "warn" | "error""info"Minimum log level written to the run log file.
logging.max_run_logsnumber20Maximum number of per-run log files to retain. Older logs are pruned automatically.

Advanced / override fields

FieldTypeDefaultDescription
data_dirstring | nullnullOverride the data directory. Defaults to $XDG_DATA_HOME/spotify-sync (~/.local/share/spotify-sync).
db_pathstring | nullnullOverride the SQLite database file path. Defaults to <data_dir>/db.sqlite.

Environment variables

Every config field can be set via an environment variable. The naming convention is:

SPOTIFY_SYNC_<DOTTED_FIELD_PATH_IN_UPPERCASE_WITH_UNDERSCORES>

For example, spotify.client_idSPOTIFY_SYNC_SPOTIFY_CLIENT_ID.

Full list:

Environment variableConfig field
SPOTIFY_SYNC_SPOTIFY_CLIENT_IDspotify.client_id
SPOTIFY_SYNC_SPOTIFY_CLIENT_SECRETspotify.client_secret
SPOTIFY_SYNC_SPOTIFY_PLAYLIST_URLspotify.playlist_url
SPOTIFY_SYNC_LIBRARY_PATHlibrary.path
SPOTIFY_SYNC_LIBRARY_IDlibrary.id
SPOTIFY_SYNC_DATA_DIRdata_dir
SPOTIFY_SYNC_DB_PATHdb_path
SPOTIFY_SYNC_DOWNLOAD_BACKENDdownload.backend
SPOTIFY_SYNC_DOWNLOAD_FORMATdownload.format
SPOTIFY_SYNC_DOWNLOAD_BITRATE_KBPSdownload.bitrate_kbps
SPOTIFY_SYNC_DOWNLOAD_CONCURRENCYdownload.concurrency
SPOTIFY_SYNC_DOWNLOAD_RETRY_COUNTdownload.retry_count
SPOTIFY_SYNC_DOWNLOAD_SEARCH_SOURCEdownload.search_source
SPOTIFY_SYNC_LOGGING_LEVELlogging.level
SPOTIFY_SYNC_LOGGING_MAX_RUN_LOGSlogging.max_run_logs

CLI flag overrides

Two config fields can be overridden directly on the command line. These take the highest precedence and apply to every subcommand:

FlagConfig fieldDescription
--library-path <path>library.pathOverride the local library directory for this run.
--db-path <path>db_pathOverride the SQLite database file path for this run.

Example:

bash
spotify-sync --library-path /tmp/test-lib sync

File locations

PurposeDefault path
Config file$XDG_CONFIG_HOME/spotify-sync/config.json~/.config/spotify-sync/config.json
Auth token$XDG_CONFIG_HOME/spotify-sync/auth.json (mode 0600)
Data directory$XDG_DATA_HOME/spotify-sync~/.local/share/spotify-sync
Database<data_dir>/db.sqlite
Log files$XDG_STATE_HOME/spotify-sync/logs/<run-id>.log~/.local/state/spotify-sync/logs/

XDG variables ($XDG_CONFIG_HOME, $XDG_DATA_HOME, $XDG_STATE_HOME) fall back to their standard defaults (~/.config, ~/.local/share, ~/.local/state) when unset.

Released under the ISC License.