Using the Spotify API, I am trying to search through tracks of an artist. The query I used is working, and looks like:
https://api.spotify.com/v1/search?q=track:' + song + '%20artist:' + artist + '&type=track&limit=10
It's working however it's returning tracks for artists containing the artist name provided in any part of their artist name string. For example, if I want to be explicit about artist name, and want to search in ZHU's tracks, I couldn't find a way how I should make the query, so it becomes explicit about artist's name.
As I said, if I want to search in ZHU's tracks, it also returns me Natalie Zhu's tracks as well.
What is the proper way of being explicit about artist name?
Is there a way to explicitly define that I am going to search in ZHU's tracks?
Edit: I also tried using quotation marks:
https://api.spotify.com/v1/search?q=track:"' + song + '"%20artist:"' + artist + '"&type=track&limit=10
Maybe I used it wrong, I am not sure, but if I didn't this doesn't seem to solve :/
It seems that currently there is no way to explicitly search for tracks of a single artist. You can only limit artists by name, as you have done, but this has the drawback of potentially including tracks by other artists whose name contains the name of the intended artist, as you explained. The only way around this is to filter the returned results and fetch more if necessary.
I have opened an issue about this at the Soptify API issue tracker Github repo, but so far, there is no info about the implementation.