- The easiest way is
pip3 install --user git+https://github.com/karlicoss/spotifyexport
.Alternatively, use
git clone --recursive
, orgit pull && git submodule update --init
. After that, you can usepip3 install --editable .
. - To use the API, you need to create a new app on Spotify for Developers
For
redirect_uri
: you can pick pretty much anything, e.g.https://github.com
. After that you’ll getclient_id
andclient_secret
. - On the first script run, you’ll be prompted to approve the script access.
Once approved, the token is saved to
cache_path
(will be created if doesn’t exist). After that you won’t need to enter the password again as long as you pass the samecache_path
.
Usage:
Recommended: create secrets.py
keeping your api parameters, e.g.:
client_id = "CLIENT_ID" client_secret = "CLIENT_SECRET" redirect_uri = "REDIRECT_URI" cache_path = "CACHE_PATH"
After that, use:
python3 -m spotifyexport.export --secrets /path/to/secrets.py > output.json
That way you type less and have control over where you keep your plaintext secrets.
Alternatively, you can pass parameters directly, e.g.
python3 -m spotifyexport.export --client_id <client_id> --client_secret <client_secret> --redirect_uri <redirect_uri> --cache_path <cache_path> > output.json
However, this is verbose and prone to leaking your keys/tokens/passwords in shell history.
I highly recommend checking exported files at least once just to make sure they contain everything you expect from your export. If not, please feel free to ask or raise an issue!
- you might want to do a GDPR export in addition, just in case
- “Recently played” API endpoint **only returns the 50 most recent tracks**, which makes it kind of useless unless you export the data every hour or so.
If you care about them, might be a good idea to connect Spotify to Last.FM.
GPDR export has more tracks, but also seems incomplete (e.g. my data is missing first few years).