LastFm API

⭐ Beginner's Pick Music / API Key Intermediate HTTPS
Varies by plan (check documentation)

Overview

Last.fm is a music discovery and social listening platform with over 15 years of scrobbling data. The API gives access to artist biographies, similar artists, top tracks, album info, and personal listening histories. It is one of the most comprehensive music metadata APIs available and free to use with an API key.

💡

Beginner Tip

Start with the artist.getInfo method to explore the API—add method=artist.getInfo, artist=Radiohead, api_key=YOUR_API_KEY, and format=json as query parameters. The format=json parameter is required or the API returns XML by default.

Available Data

track name and artist
album metadata
audio preview URLs
popularity score
genre classification
Use case: Integrate music data into web and mobile applications

Example Response

JSON Response
{
  "name": "Bohemian Rhapsody",
  "artist": "Queen",
  "album": "A Night at the Opera",
  "duration_ms": 354000,
  "popularity": 92,
  "preview_url": "https://p.scdn.co/mp3-preview/..."
}

Field Reference

artist.name The canonical artist name as stored on Last.fm.
artist.listeners Total number of unique listeners on Last.fm (returned as a string).
artist.playcount Total number of scrobbles (plays) recorded for this artist across all users.
artist.bio.summary Short HTML-formatted biography of the artist.
artist.similar.artist List of similar artist objects with name and image.
artist.tags.tag Array of genre/style tags applied to the artist by the Last.fm community.

Implementation Example

// ⚠️ Note: This URL may be a documentation page. Check official docs for actual API endpoint.
const url = "https://www.last.fm/api";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "X-API-Key": "YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

{"error":10} Invalid API key The api_key parameter is missing or contains an invalid value.
Register at last.fm/api/account/create and use the key provided as ?api_key=YOUR_API_KEY.
Response is XML instead of JSON The format=json parameter was omitted.
Always append &format=json to your request URL.
{"error":6} Artist not found The artist name was misspelled or is not in the Last.fm database.
Use the artist.search method first to find the correct artist name spelling.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 10/20
🔒 Security 15/15
🛠 Developer XP 12/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth API Key
HTTPS REQUIRED
CORS UNKNOWN
Category Music
Difficulty Intermediate
Verified: 2026-04-04

Alternatives to LastFm

Technical alternatives for different use cases.

Listening statistics and similar artist recommendations

Better For

Official catalog data and audio playback

Trade-off

Music discovery based on listening habits

Community-maintained open music database

Better For

Accurate metadata and music identification

Trade-off

User listening statistics and social features

Richer audio features and official streaming integration

Better For

Building music players with audio analysis

Trade-off

Cross-platform listening history aggregation

Similar APIs

View All →