Create svg cards to showcase your top Spotify artists, tracks, or albums on any website or README.
Images are cached for 1 day to reduce load time by a significant amount.
This project is based on the stats.fm API.
Depending if your stats.fm account is free or premium, you will have different features available.
Account | Top Artists | Top Tracks | Top Albums | Msplayed | Streams | Max Items |
---|---|---|---|---|---|---|
FREE | ✅ | ✅ | ❌ | ❌ | ❌ | 50 |
PREMIUM | ✅ | ✅ | ✅ | ✅ | ✅ | 99+ |
- Login to stats.fm with your Spotify account
- Open the network tab of your browser
- Refresh the page
- Find any request to the API, and retrieve the username from the url
Host the code on any server that support php and then install the package using composer :
composer install
I recommand creating a cron job that run the clean.php script. This script remove all cached images if they are older than 7 days. This will avoid using to much space for nothing.
To generate the image you need only provide the link where your script is hosted along with your username. For example, https://example.com?username=sheldon_cooper
.
Customize your card further with additional parameters:
Param | Default | Description |
---|---|---|
range | lifetime | Range for the stats (weeks, months, lifetime) |
type | artists | Type of stat displayed (artists, tracks, albums) |
limit | 5 | Limits the number of items displayed |
width | 600 | Width of the container |
height | 180 | Height of the container |
spacing | 20 | The space between the items |
y_offset | 10 | Y-axis offset of odd elements |
rounded | 4 | Container border radius |
i_rounded | 100 | Elements border radius |
g_start | 0D1117 | Gradient start color |
g_stop | 000000 | Gradient end color |
type=tracks&range=months&display=streams
type=albums&spacing=50&y_offset=20&limit=4
type=artists&range=weeks&limit=4&width=400&height=140
type=artists&rounded=40&i_rounded=100&g_start=36E7FF&g_stop=3F5DFF
Im open to contributions! If you'd like to contribute, please create a pull request and I'll review it as soon as I can.
This project is licensed under the MIT License - see the LICENSE file for details.