1

I am working on an application which would allow users to enter some text as song name and another input for the artist name, and then will check whether a song exists that matches both the input parameters. I'm currently using Spotify's API for the same by querying for the song 'Get In The Game' using this endpoint:

https://api.spotify.com/v1/search?q=get%20in%20the%20game&type=track

However, Spotify's API does not allow filtering the results using both the song name and artist name together. As a result, the above query returns a list of all songs that match the Get in the Game song title.

How can I find whether a song exists based on the song and artist name?

xskxzr
  • 12,442
  • 12
  • 37
  • 77
Manas Chaturvedi
  • 5,210
  • 18
  • 52
  • 104

1 Answers1

1

You could use the last.fm API, specifically the track.getInfo Endpoint. This lets you specify both artist and track at once.

On success (you could also request for a json response) you get something like:

<lfm status="ok">
    <track>
        <name>Shine on You Crazy Diamond</name>
        <mbid>cb20321d-ecda-4fc1-a32a-0439a096a1bc</mbid>
        <url>
            http://www.last.fm/music/Pink+Floyd/_/Shine+on+You+Crazy+Diamond
        </url>
        <duration>763000</duration>
        <streamable fulltrack="0">0</streamable>
        <listeners>256400</listeners>
        <playcount>1511578</playcount>
        <artist>
            <name>Pink Floyd</name>
            <mbid>83d91898-7763-47d7-b03b-b92132375c47</mbid>
            <url>http://www.last.fm/music/Pink+Floyd</url>
        </artist>
        ...
    </track>
</lfm>

when the song is not found:

<lfm status="failed">
    <error code="6">Track not found</error>
</lfm>
Simon Fromme
  • 3,104
  • 18
  • 30