Search code examples
last.fm

Using Last.fm api to get song metadata


I am trying to get a track's metadata from Last.fm web api. I tried getting the details using the track name and track artists and it worked. But to get more accurate results I wanted to use a song's MusicBrainzId(mbid) to get the details.

last.fm api's documentaion for reference

Now I am using the following GET request to get a json response

http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=INSERT_API_KEY&format=json&mbid=bfcc6d75-a6a5-4bc6-8282-47aec8531818

But I am getting an error response i.e.

{"error":6,"message":"Track not found","links":[]}

As I understood from the api documentation we can use mbid instead of track and artist params. Its not working for me. Please help me on this.


Solution

  • That mbid is for an artist, Cher

    That API is for getting information about tracks, not artists

    Try, for example http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=INSERT_API_KEY&format=json&mbid=251f6d72-a1d9-4b9d-944a-2df9b26f6212

    or http://ws.audioscrobbler.com/2.0/?method=artist.getTopTracks&api_key=INSERT_API_KEY&format=json&mbid=bfcc6d75-a6a5-4bc6-8282-47aec8531818