A tool for creating recommended playlists for Spotify

spotify, recommendation, music
pip install spotirec==1.3.1



Script that creates a playlist of recommendations based on the user's top artists or tracks, or genres extracted from top artists. A sort of Discover Weekly on demand.


Install dependencies with pip

pip install requests
pip install spotipy
pip install bottle

Run the script in terminal for a first time setup

$ python /path/to/

The first time setup will cache access and refresh tokens used to perform various remote actions on your spotify account. The first time setup will host a localhost port and open this in your browser. On this page you simply log in to your spotify account to authorize access to Spotirec - once this is done, you can close the page and exit the script.


To use Spotirec, simply run it from terminal

$ python /path/to/

Optionally you can add a limit as an integer value

$ python /path/to/ 50

This option determines how many tracks should be added to your new playlist. The default value is 20, and the max value is 100.

Additionally, you can pass arguments to specify the what the recommendations should be based on

$ python /path/to/ -t 
$ python /path/to/ -a
$ python /path/to/ -tc
$ python /path/to/ -ac
$ python /path/to/ -gc


  • -t is based off your most played tracks,
  • -a is based off your most played artists,
  • -tc you can define 1-5 of your most played tracks,
  • -ac you can define 1-5 of your most played artists,
  • -gc you can define 1-5 genre seeds

By default, the script will base recommendations off of your top genres extracted from your top artists. For this method, pass none of the above 5 arguments.


If you encounter issues adding tracks to your playlist, try running the script from a terminal. This should output a status code of the request, as well as some information about the code. Should you need additional help regarding status codes, consult the table in the Response Status Codes section here