Identifying an MP3 file

Given an MP3 file, the Echo Nest has several ways to help you identify the actual song that it represents. This tutorial will show you the different approaches that are available.

Identifying an MP3 file by its metadata

The easiest way to identify an MP3 file is by using the artist and title provided within the MP3 metadata tags. Unfortunately, this method requires that the user has correctly tagged his or her file with the right artist and song names. In this case, you can use a library appropriate to your development environment to extract the artist and song titles from the MP3 ID3 tags, and pass them to the Echo Nest via a song/search API call.

Often, however, you will want to ensure a higher degree of accuracy than an artist name/song name lookup can ensure. To do this, there are two options available to you. Both of them involve the use of the Echo Nest audio fingerprinter, to extract a unique audio identifier of the song. The two paths are: 1) upload a file to The Echo Nest for fingerprinting and analysis (available to everyone), and 2) using the Echo Nest fingerprinter yourself on the audio file and providing the fingerprint codes for lookup.

Identifying an MP3 file via uploading

To upload a file to The Echo Nest, use the track/upload API call. Posting tracks with /track/upload can be done in two manners:

  • An HTTP POST request with Content-Type "multipart/form-data" where all parameters are in the post body and the track is in the "track" section of the post "files"
  • An HTTP POST request with Content-Type "application/octet-stream", with the local file as the body of the request, and the parameters in the URL

Example Posts

curl -X POST "http://developer.echonest.com/api/v4/track/upload" -d "api_key=FILDTEOIK2HBORODV&url=http://example.com/audio.mp3"

curl -F "api_key=FILDTEOIK2HBORODV" -F "filetype=mp3" -F "track=@audio.mp3" "http://developer.echonest.com/api/v4/track/upload"

curl -X POST -H "Content-Type:application/octet-stream" "http://developer.echonest.com/api/v4/track/upload?api_key=FILDTEOIK2HBORODV&filetype=mp3" --data-binary "@audio.mp3"

Response

{
    "response": {
        "status": {
            "version": "4.2",
            "code": 0,
            "message": "Success"
        },
        "track": {
            "status": "complete",
            "artist": "How to Destroy Angels",
            "title": "Fur Lined",
            "analyzer_version": "3.01a",
            "release": "How to Destroy Angels",
            "audio_md5": "97507e1eeda3e62abeabcc8dd51e6bd6",
            "bitrate": 320,
            "id": "TRGOVKX128F7FA5920",
            "samplerate": 44100,
            "md5": "cd9276287838f11f2d7f39cd10391195"
        }
    }
}

This will return an id which is a Track ID. You can then make calls to track/profile to see the details about the track.

Example

Response

{
    "response": {
        "status": {
            "code": 0, 
            "message": "Success", 
            "version": "4.2"
        }, 
        "track": {
            "analyzer_version": "3.01a", 
            "artist": "How to Destroy Angels", 
            "audio_md5": "97507e1eeda3e62abeabcc8dd51e6bd6", 
            "audio_summary": {
                "analysis_url": "https://echonest-analysis.s3.amazonaws.com:443/TR/TRGOVKX128F7FA5920/3/full.json?Signature=5RpVgJbbI9V9GyWApJnYGlMcTfw%3D&Expires=1308071436&AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ", 
                "danceability": 0.59608747988903843, 
                "duration": 240.27383, 
                "energy": 0.74113818413872323, 
                "key": 2, 
                "loudness": -6.0359999999999996, 
                "mode": 1, 
                "tempo": 124.033, 
                "time_signature": 4
            }, 
            "bitrate": 320, 
            "id": "TRGOVKX128F7FA5920", 
            "md5": "cd9276287838f11f2d7f39cd10391195", 
            "release": "How to Destroy Angels", 
            "samplerate": 44100, 
            "status": "complete", 
            "title": "Fur Lined"
        }
    }
}