A simple API that fetches the currently playing or most recently played track from Last.fm for a given user.
curl -s https://lastfm.alexraskin.com/{your lastfm username}
- Go 1.24 or later
- Last.fm API key (get one from Last.fm API)
-
Clone this repository
git clone https://github.com/alexraskin/lastfm-now-playing.git
-
Install dependencies:
go mod download
-
Take a look at the
config.yaml.example
file and create aconfig.yaml
file in the root of the project. -
Run the application:
go run main.go
- Build the Docker image:
docker build -t lastfm-now-playing .
- Run the container:
docker run -p 8000:8000 -e LASTFM_API_KEY={your lastfm api key} lastfm-now-playing
GET /:username
Example:
GET /twizycat
{
"album": "Album Name",
"artist": "Artist Name",
"nowPlaying": true,
"playedAt": "",
"playedAtUnix": 0,
"track": "Track Name"
}
GET /twizycat?format=shields.io
[](https://github.com/alexraskin/lastfm-now-playing)
GET /widget
- type: extension
url: https://lastfm.alexraskin.com/widget
allow-potentially-dangerous-html: true
cache: 30s
parameters:
user: twizycat