Operating System
Web API
My Question or Issue
There is a bug in the Spotify Web API where for some tracks availableMarkets is sometimes empty. You can currently try track id 18GLelA5vVdzd9X7WGPmJ8 and see for yourself.
Get Track API:
https://api.spotify.com/v1/tracks/18GLelA5vVdzd9X7WGPmJ8Response:
"uri": "spotify:track:18GLelA5vVdzd9X7WGPmJ8",
"available_markets": [],
But if I include a market:
https://api.spotify.com/v1/tracks/1bpTsEhmS4DQ1rC6htLlWL?market=USResponse:
"uri": "spotify:track:18GLelA5vVdzd9X7WGPmJ8",
"is_playable": true,so it is available in that market and several others, but that is not properly reflected in the API response sometimes.
So you are expected to get (without market parameter):
"uri": "spotify:track:18GLelA5vVdzd9X7WGPmJ8",
"available_markets": [],
And you are expected to get (with market parameter):
"uri": "spotify:track:6zsH33Xbm0gAtBTx9R2vP0",
"is_playable": true,
"linked_from": {
"uri": "spotify:track:18GLelA5vVdzd9X7WGPmJ8"
}
But instead of getting data from the linked track (with market parameter):
"name": "(Poor Mi) Israelites"
you are getting data from the originally requested track (with market parameter):
"name": "Israelites"
This is not the expected behavior. If there is a relinked track, the metadata should come from that track.
I just wanted to confirm that there is an inconsistency in how Track Relinking is being done in the API. We intend to address this next year.
But what you are seeing is actually the intended behavior. When you do not provide a market, we are unable to determine playability in a market, so we instead return the available markets for that specific track.
When you provide a market, we can not only determine if that track is playable or not, we can also get any possible relinked track. This basically means that the licensor has chosen to replace one version of a track (the one you are requesting) with another (the one relinked).
The API should then return all the metadata of the relinked track, and only provide a limited amount of data about the track you were requesting in the `linked_from` field.
However, today this does not happen fully. Some of the metadata of the relinked track is there, but it is mixed in with the track you originally requested. We intend to fix this so that the behavior is as described in the documentation:
"...Web API recognizes that the specified track is unplayable and instead returns information about a track that is playable in the specified market."
There is a good illustration of this with example JSON in the documentation about Track Relinking. I suggest checking that out. Also, thank you for reporting this and making us aware of the bug.