Displays your currently playing Spotify track as an embeddable and customizable SVG widget for GitHub READMEs and websites.
- Spotify Widgetify
Spotify Widgetify is a web widget that displays your currently playing Spotify track, designed to be embedded in GitHub profile READMEs and websites. It automatically updates to reflect your currently playing or recently played tracks on Spotify.
- Refresh a Spotify access token, cached until it expires.
- Fetch the currently playing track, falling back to the most recently played, then to a "Not Playing" state.
- Map the Spotify response to a
Trackmodel and derive a color palette from the album art. - Apply the requested theme and render a Jinja2 SVG template.
The rendered SVG inlines its assets as base64 and carries its CSS in a <style> block. It runs no
JavaScript and makes no external requests, so it renders the same in a README or offline.
GitHub serves widget images through a caching proxy, so a profile can show the previous track for a minute or two after playback changes.
- Eight themes inspired by defining GUI eras, including iPod (skeuomorphic design), Windows 98 (Windows Classic), Macintosh (Platinum), and more.
- Current track, or the most recently played when nothing is on.
lightanddarkstyles on the themes that support both.- Custom accent color via
?color=.
Previews show the track currently playing on the hosted demo account.
Embed the widget using /github as the <img> source and linking it via /link, which opens an embedded Spotify player for the track you're currently playing.
<div align="center">
<a href="https://spotify-widgetify.vercel.app/link">
<img src="https://spotify-widgetify.vercel.app/github?theme=ipod" alt="Spotify Now Playing" width="440" />
</a>
</div>NOTE: Replace spotify-widgetify.vercel.app with a self-hosted deployment if needed.
| Endpoint | Returns |
|---|---|
/github |
The widget as image/svg+xml, for use in an <img>. |
/ |
The widget as an HTML page, for previewing in a browser. |
/link |
An HTML page embedding the current track's Spotify player. |
Options are query parameters on /github and /:
| Parameter | Default | Values | Notes |
|---|---|---|---|
theme |
default |
any theme= value in §3 |
Unknown values fall back to default. |
style |
light |
light, dark |
Effective on default, vinyl, ipod, retro. Other themes render one fixed look. |
color |
— | hex digits, no # (e.g. 609dbd) |
Custom accent for default, vinyl, ipod. Ignored by other themes. |
eq_color |
1ED760 |
hex digits, rainbow, none |
Equalizer color on themes that show one. |
Example with a custom iPod body color and no equalizer:
<img src="https://spotify-widgetify.vercel.app/github?theme=ipod&color=609dbd&eq_color=none" alt="Spotify Now Playing" width="440" />- Python 3.11+
- uv
- A Spotify account and a Spotify Developer application
- Open the Spotify Developer Dashboard and create an app.
- Record the Client ID and Client Secret.
- Add
http://127.0.0.1:8888/callbackto the app's Redirect URIs. The token script in step 6.3 uses it.
Create a .env file in the project root:
SPOTIFY_CLIENT_ID=your_client_id
SPOTIFY_CLIENT_SECRET=your_client_secret
SPOTIFY_REFRESH_TOKEN= # filled in by step 6.3Run the helper script to complete the Authorization Code + PKCE flow and save SPOTIFY_REFRESH_TOKEN to .env. Make sure SPOTIFY_CLIENT_ID is set and the redirect URI from step 6.1 is registered.
uv run python scripts/get_refresh_token.pyThe script opens Spotify’s consent page, captures the redirect at 127.0.0.1:8888, exchanges the authorization code, and saves the refresh token.
uv sync
uv run uvicorn app.main:app --reloadOpen http://127.0.0.1:8000/?theme=ipod for the preview, or http://127.0.0.1:8000/github?theme=ipod for the raw SVG.
The repository includes vercel.json. Import the project in Vercel, set SPOTIFY_CLIENT_ID,
SPOTIFY_CLIENT_SECRET, and SPOTIFY_REFRESH_TOKEN in the project environment, and deploy. The
widget is then served at https://<app>.vercel.app/github.
Server-rendered SVG. No build step.
app/
├── api/ # web requests
├── schemas/ # URL query parameters
├── domain/ # track + theme models
├── services/ # builds widget UI via colors + rendering
├── providers/ # Spotify client
├── themes/ # theme styling
├── templates/ # SVG layouts
├── assets/ # logos/images encoded into the SVG
└── static/ # source SVG files
- Confirm music is playing and that
SPOTIFY_CLIENT_ID,SPOTIFY_CLIENT_SECRET, andSPOTIFY_REFRESH_TOKENare set. An invalid or unscoped refresh token yields an empty access token and the fallback state. - The token needs the
user-read-currently-playinganduser-read-recently-playedscopes (which the script requests).
- GitHub caches the image through its proxy. Append a parameter
such as
&cb=1to fix the cache.
- Confirm
http://127.0.0.1:8888/callbackis registered exactly in the app's Redirect URIs and that port 8888 is free.
- Spotify Web API for track data
- FastAPI and Jinja2
- Pillow for album-art color extraction
- Vercel for hosting