agentsclimarketplace

Lastfm

Skill mykeyy/lastfm

Comprehensive reference for the Last.fm Music Discovery API. Use this skill when the user asks about Last.fm API methods, authentication flows, scrobbling, signing requests, error codes, or how to build something with the Last.fm API. Also use it when helping edit or maintain the local API documentation files in the lastfm workspace.From its SKILL.md

Install
npx -y skills add mykeyy/lastfm

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

12.6 KB, ~3.3k tokens by cl100k_base, as published. Nobody here has run it

Last.fm API Reference Skill

This skill contains everything needed to answer questions about and work with the Last.fm API.

Documentation Files

The full API reference docs are in the references/ folder alongside this skill:

FileContents
references/fm_a_main.txtOverview, all 3 auth flows, scrobbling guide, signing calls, API ToS
references/fm_api_album.txtalbum.* methods
references/fm_api_artist.txtartist.* methods
references/fm_api_auth.txtauth.* methods
references/fm_api_chart.txtchart.* methods
references/fm_api_geo.txtgeo.* methods
references/fm_api_library.txtlibrary.* methods
references/fm_api_tag.txttag.* methods
references/fm_api_track.txttrack.* methods (incl. scrobble + nowplaying)
references/fm_api_user.txtuser.* methods

Always read the relevant reference file before answering specific method questions.


API Basics

Base URL: http://ws.audioscrobbler.com/2.0/

Request format: REST — send a method parameter (e.g. album.getinfo) plus method-specific params.

Response format: XML by default. Append &format=json for JSON.

Encoding: All arguments must be UTF-8. Use a User-Agent header on all requests.

Example GET request:

GET http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=YOUR_KEY&artist=Cher&album=Believe&format=json

Example URL pattern used in docs:

/2.0/?method=album.getinfo&api_key=YOUR_API_KEY&artist=Cher&album=Believe[&format=json]

The [&format=json] suffix is optional — omit for XML.


Authentication

There are 3 authentication flows. All write services require auth. Read-only methods do not.

Auth Type Summary

MethodWhen to use
Web appYou have a callback URL; user logs in via browser redirect
Desktop appNo callback URL; user logs in via browser then returns to app
Mobile appYou have the user's password; use auth.getMobileSession over HTTPS POST

Signing Calls (all flows share this)

To generate api_sig:

  1. Take all parameters for the call except format and callback.
  2. Sort them alphabetically by parameter name.
  3. Concatenate as <name><value><name><value>... (no separators).
  4. Append your shared secret.
  5. MD5 hash the whole string.

Example for auth.getSession:

api_sig = md5("api_keyXXXXmethodauth.getSessiontokenYYYYmysecret")

The result is a 32-character hex string.

Important: When using array notation (e.g. for batch scrobbles), parameters MUST be sorted by ASCII order — artist[10] sorts before artist[1].

Session Keys

  • Session keys are infinite lifetime by default.
  • Store them securely — users can revoke them in their Last.fm settings.
  • Auth tokens (used to get a session) expire after 60 minutes and can only be used once.

Web App Flow

  1. Redirect user to http://www.last.fm/api/auth/?api_key=XXX (optionally &cb=YOUR_CALLBACK)
  2. Last.fm redirects back to your callback with ?token=YYYY
  3. Call auth.getSession with api_key, token, api_sig → receive sk (session key)
  4. Sign all authenticated calls with api_key, sk, api_sig

Desktop App Flow

  1. Call auth.getToken with api_key + api_sig → receive token
  2. Open browser to http://www.last.fm/api/auth/?api_key=XXX&token=YYY
  3. User grants access, returns to app
  4. Call auth.getSession with api_key, token, api_sig → receive sk
  5. Sign all authenticated calls with api_key, sk, api_sig

Mobile App Flow

  1. Call auth.getMobileSession via HTTPS POST with username, password, api_key, api_sig
  2. Receive sk directly (no browser redirect needed)
  3. Sign all authenticated calls with api_key, sk, api_sig

Common Parameters

These appear in many methods:

ParamMeaning
api_keyYour 32-char API key (always required)
api_sigMD5 signature (required for auth'd calls and write services)
skSession key from auth flow (required for write services)
autocorrect[0|1]Fix misspelled artist/track names automatically
mbidMusicBrainz ID — can substitute for artist+track/album name
limitResults per page (default usually 30 or 50)
pagePage number (1-indexed)
formatjson or omit for XML
langISO 639 alpha-2 language code (for bio/wiki text)

Method Index

album.*

MethodAuthDescription
album.addTagsRequired (POST)Tag an album with up to 10 user tags
album.getInfoNoneGet metadata + tracklist for an album
album.getTagsNoneGet tags applied by a specific user to an album
album.getTopTagsNoneGet top tags for an album across all users
album.removeTagRequired (POST)Remove a user's tag from an album
album.searchNoneSearch for albums by name

artist.*

MethodAuthDescription
artist.addTagsRequired (POST)Tag an artist with user tags
artist.getCorrectionNoneCheck if artist name has a canonical correction
artist.getInfoNoneGet artist metadata and biography
artist.getSimilarNoneGet similar artists based on listening data
artist.getTagsNoneGet tags applied by a user to an artist
artist.getTopAlbumsNoneGet top albums for an artist
artist.getTopTagsNoneGet top tags for an artist
artist.getTopTracksNoneGet top tracks for an artist
artist.removeTagRequired (POST)Remove a user's tag from an artist
artist.searchNoneSearch for an artist by name

auth.*

MethodAuthDescription
auth.getMobileSessionNone (but needs HTTPS POST)Get session key using username + password
auth.getSessionNoneExchange an auth token for a session key
auth.getTokenNoneGet an unauthorized request token (desktop apps)

chart.*

MethodAuthDescription
chart.getTopArtistsNoneGet the top artists chart
chart.getTopTagsNoneGet the top tags chart
chart.getTopTracksNoneGet the top tracks chart

geo.*

MethodAuthDescription
geo.getTopArtistsNoneGet top artists by country
geo.getTopTracksNoneGet top tracks by country

library.*

MethodAuthDescription
library.getArtistsNoneGet artists in a user's library

tag.*

MethodAuthDescription
tag.getInfoNoneGet metadata for a tag
tag.getSimilarNoneGet similar tags
tag.getTopAlbumsNoneGet top albums for a tag
tag.getTopArtistsNoneGet top artists for a tag
tag.getTopTagsNoneGet the overall top tags on Last.fm
tag.getTopTracksNoneGet top tracks for a tag
tag.getWeeklyChartListNoneGet available weekly chart date ranges for a tag

track.*

MethodAuthDescription
track.addTagsRequired (POST)Tag a track with user tags
track.getCorrectionNoneCheck if track/artist name has a canonical correction
track.getInfoNoneGet metadata for a track
track.getSimilarNoneGet similar tracks
track.getTagsNoneGet tags applied by a user to a track
track.getTopTagsNoneGet top tags for a track
track.loveRequired (POST)Love a track on a user's profile
track.removeTagRequired (POST)Remove a user's tag from a track
track.scrobbleRequired (POST)Submit a track play to a user's history
track.searchNoneSearch for tracks by name
track.unloveRequired (POST)Unlove a track
track.updateNowPlayingRequired (POST)Notify Last.fm a user started listening

user.*

MethodAuthDescription
user.getFriendsNoneGet friends of a user
user.getInfoNoneGet a user's profile info
user.getLovedTracksNoneGet a user's loved tracks
user.getPersonalTagsNoneGet tracks/artists/albums a user has tagged
user.getRecentTracksNoneGet a user's recent listening history
user.getTopAlbumsNoneGet a user's top albums
user.getTopArtistsNoneGet a user's top artists
user.getTopTagsNoneGet a user's top tags
user.getTopTracksNoneGet a user's top tracks
user.getWeeklyAlbumChartNoneGet weekly album chart for a user
user.getWeeklyArtistChartNoneGet weekly artist chart for a user
user.getWeeklyChartListNoneGet available chart date ranges for a user
user.getWeeklyTrackChartNoneGet weekly track chart for a user

Scrobbling Guide

When to Scrobble

A track qualifies for scrobbling when both are true:

  • Track duration > 30 seconds
  • User has listened for at least 50% of the track duration OR 4 minutes (whichever comes first)

Now Playing vs Scrobble

  • track.updateNowPlaying — Send immediately when a track starts. Optional but recommended. Shows on the user's profile in real time. Failed nowplaying requests should not be retried.
  • track.scrobble — Send when scrobble conditions are met (usually at end of track). Failed scrobbles should be cached and retried.

Batch Scrobbling

Send up to 50 scrobbles in one request using array notation:

artist[0]=Cher&track[0]=Believe&timestamp[0]=1234567890
artist[1]=Madonna&track[1]=Ray+of+Light&timestamp[1]=1234568130

Timestamps must be UTC Unix timestamps. Sort array params by ASCII order when signing.

chosenByUser Parameter

Set to 0 when the track was chosen by someone other than the user (e.g., radio, recommendations). Otherwise omit it (defaults to 1).

Do NOT

  • Determine track metadata from filenames — use ID3 tags or structured sources only.
  • Use now-playing corrections as scrobble input unless explicitly approved by the user.

Scrobble Ignored Message Codes

CodeMeaning
0None — passed all filters
1Filtered artist (e.g. "Unknown Artist")
2Filtered track
3Timestamp too far in the past
4Timestamp too far in the future
5Daily scrobble limit exceeded

Error Handling

Response Structure

Always inspect the response body — a 200 OK HTTP status does NOT mean the request succeeded.

Check the <lfm status="..."> attribute:

  • "ok" → success
  • "failed" → inspect <error code="N"> for details

Retry Logic for Scrobbles

ErrorAction
Code 9 (Invalid session key)Re-authenticate, then retry
Code 11 (Service Offline)Retry later
Code 16 (Temporarily unavailable)Retry later
Any other codeDo NOT retry — fix the request

Standard Error Codes (all methods)

CodeMeaning
2Invalid service — this service does not exist
3Invalid Method — no method with that name
4Authentication Failed — no permission to access
5Invalid format — service doesn't exist in that format
6Invalid parameters — missing required parameter
7Invalid resource specified
8Operation failed — something else went wrong
9Invalid session key — please re-authenticate
10Invalid API key — must be granted a valid key
11Service Offline — temporarily offline, try again
13Invalid method signature supplied
16Temporary error / service temporarily unavailable
26Suspended API key — account suspended
29Rate limit exceeded — too many requests from your IP

Tips & Gotchas

  • Rate limits: Don't hammer the API. Avoid calling on every page load. Your key can be suspended.
  • Write services always require HTTP POST with form-urlencoded body. Never GET for write operations.
  • HTTPS required for auth.getMobileSession specifically.
  • autocorrect=1 is handy — it fixes misspelled artist/track names and returns the corrected name in the response.
  • mbid (MusicBrainz ID) is usually more reliable than artist+track name strings when you have it.
  • duration in track.getInfo is in milliseconds; in track.scrobble it's in seconds.
  • The format=json parameter is excluded from signature calculation.
  • Commercial or research use requires contacting [email protected] before use.

What ships with it: 13 files

124.7 KB alongside SKILL.md

Keep looking

Skills are one crate of 326,286. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.