SpotifyTracker

raw JSON →
0.0.18 verified Sat May 09 auth: no python

Track your Spotify play history by fetching recently played tracks and storing them locally. Version 0.0.18 is in early development; releases are sporadic.

pip install spotifytracker
error AttributeError: module 'spotifytracker' has no attribute 'SpotifyTracker'
cause Importing the module directly without the class.
fix
Use 'from spotifytracker import SpotifyTracker'
error TypeError: __init__() got an unexpected keyword argument 'token'
cause The 'token' parameter was renamed to 'access_token'.
fix
Replace 'token=' with 'access_token=' in SpotifyTracker instantiation.
error spotifytracker.exceptions.AuthenticationError: Invalid client
cause The provided client_id or client_secret is incorrect or the Spotify app is not configured to use the redirect URI.
fix
Verify your Spotify Developer Dashboard settings and re-set environment variables.
gotcha The library requires Spotify API credentials with the 'user-read-recently-played' scope. Without it, no data is fetched and no error is raised.
fix Ensure your Spotify app has the scope enabled and you pass correct credentials.
gotcha run() blocks indefinitely; there is no built-in way to stop gracefully except KeyboardInterrupt. The library does not support async or background threads.
fix Wrap with timeout or run in a separate thread if non-blocking behavior is needed.
deprecated The constructor parameter 'token' was renamed to 'access_token' in v0.0.15. Old code using 'token' will break.
fix Use 'access_token' instead of 'token' when instantiating SpotifyTracker.

Minimal example: authenticate and start tracking play history.

from spotifytracker import SpotifyTracker
import os

client_id = os.environ.get('SPOTIFY_CLIENT_ID', '')
client_secret = os.environ.get('SPOTIFY_CLIENT_SECRET', '')

if not client_id or not client_secret:
    raise ValueError("Set SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET environment variables")

tracker = SpotifyTracker(client_id, client_secret)
tracker.run()