API Directory › 🎬 Movies, TV & Music › Last.fm
API KeyHTTPSCORS

Last.fm API

Music metadata, scrobbling, artist info and charts.

Auth
API Key
HTTPS
Yes
CORS
Yes
Open Last.fm docs ↗

What it does

The Last.fm API exposes scrobbling data and music metadata: artist, album and track info, similar artists, tags, global and per-user charts, and a user’s listening history and loved tracks. Read methods are simple GET calls; scrobbling requires a signed session.

Base URL

https://ws.audioscrobbler.com/2.0/

Authentication

Register for a free API key and pass it as &api_key=YOUR_KEY with &format=json and a &method=. Write methods (scrobble, love) need a user session key plus an MD5 api_sig of the sorted parameters.

Code examples

curl
curl -s "https://ws.audioscrobbler.com/2.0/?method=artist.getinfo"\
"&artist=Bjork&api_key=$LASTFM_KEY&format=json"
Python
import requests

r = requests.get("https://ws.audioscrobbler.com/2.0/", params={
    "method": "user.getrecenttracks", "user": "rj",
    "api_key": KEY, "format": "json", "limit": 5}, timeout=10)
for t in r.json()["recenttracks"]["track"]:
    print(t["artist"]["#text"], "-", t["name"])

Rate limits & quotas

Guideline of roughly 5 requests/second per IP for read methods; sustained heavier use can get your key throttled or revoked. Errors come back as JSON with an error code and message, sometimes with HTTP 200.

Key response fields

artist.stats.listeners / playcountPopularity for artist.getinfo
toptracks.track[]Ranked tracks with playcount
recenttracks.track[]A user’s scrobbles, newest first
@attr.nowplayingPresent on the currently-playing track
error / messageNon-zero code means the call failed

Common errors

error 10Invalid API key.
error 6Invalid parameters — e.g. unknown user or missing artist.
error 29Rate limit exceeded — slow down.
error 17User has their listening data set to private.

When to use it (and alternatives)

Best for listening-history features, music discovery (similar artists, tags) and charts. For catalogue metadata with stable IDs use MusicBrainz; for previews and playback use Spotify or Deezer.

FAQ

Can I read someone's scrobbles without their permission?

Yes, if their profile is public — user.getrecenttracks and friends work with just your API key. Private profiles return error 17.

Do I need the shared secret?

Only for authenticated write methods (scrobble, love/unlove) and for creating a user session. Plain reads need just the api_key.

Why is artist data sometimes missing or merged oddly?

Last.fm keys metadata on name strings, so different artists with the same name can collide. Use the mbid parameter (a MusicBrainz ID) when you have one for exact matches.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

JSON Formatter

Related Movies, TV & Music APIs

← Back

More Movies, TV & Music APIs · All 196 APIs