Result from querying Spotify API differs from identical query in web client
I've been using the Spotify API to query for an exact track by a given artist, making a GET request like so:
https://api.spotify.com/v1/search?q=track:"track+title"+artist:"artist+name"&type=track
(with the Authorization header Bearer [access_token])
This works like expected in most cases, but for one track I got a problem: I'm trying to find the track I Might Just Stay Home, with Shannon Lyon.
With my previously successful GET request adjusted to this tracks title and artist, this is what it should look like:
https://api.spotify.com/v1/search?q=track:"I+Might+Just+Stay+Home"+artist:"Shannon+Lyon"&type=track
This however yields zero results. And what makes it really strange: if I copy the exact same search query (track:"I+Might+Just+Stay+Home"+artist:"Shannon+Lyon") into the Spotify Web player, I get the one search result I'm expecting. And I can also use the same query in the Spotify Desktop player, giving me the one result.
So, the question is: What could be the reason to why I don't get a result from the API, whilst I get a result in both the web and desktop client using the exact same query?
One likely reason Potray has already given. The thing you see in the client comes from an internal API. They differ slightly from the public Web API.
Another more likely reason is just different availability in different countries and your two queries are for different countries, but you might not realize it.
When you search in the client, it is always a user who searches. A user is connected to a country. You can only play what is available in your country, so searching in the client only returns what you can play.
When you search with the Web API, you don't need to specify which Spotify user is searching. You also don't need to specify which country you want search results for.
Since the very beginning, not specifying a country, the search results would list tracks that were available in at least one country. Since last year, because of a bug, it instead defaults to the US. You can change country, but you can no longer search in all countries.
https://github.com/spotify/web-api/issues/194
链接地址: http://www.djcxy.com/p/55604.html