Announcements

Help Wizard

Step 1

NEXT STEP

preview_url doesn't give an url anymore

preview_url doesn't give an url anymore

Hello, I'm writing an app (at the moment is just sperimental) which uses the preview_url given by this API endpoint

 

https://api.spotify.com/v1/tracks/


This is my workflow, summed up in a few line:

 

1. Creating my client creds using Client_Id and Client_Secret, both given by Spotify

//this is written in dart

String clientCreds=clientId+":"+clientSecret;
var clientCredsEncoded = utf8.encode(clientCreds);
String clientCredsB64 = base64Encode(clientCredsEncoded);

2. Retriving my token using api/token endpoint

http.Response risposta = await http.post(
url,
headers: {"Authorization": "Basic " + creds},
body: params
);


3. Getting a track info using v1/tracks endpoint

 

(I get a random track from this playlist)

https://open.spotify.com/playlist/4str4OJTVRLrFUpWMoZywC?si=nxcOSZKHRO6B_YJ--pB5iA)


And it worked since yesterday. Some songs didn't have the preview_url but just a few, most of the song had it. Today it doesn't work anymore, every song has the preview_url = null. I can get every info of a track, like the image, the title, the artist, but the preview_url is equal to null, in every songs. I don't know if it is a problem linked to my account, some sort of limitation (I registered the app with another account with a free plan), but I can't figure it out

Reply
20 Replies

Hey @Luca289, help's here!


That's odd! I tried to replicate this and saw that if you included a 'market' in your request, that the API does return the preview_url. You can get the market the user is in with the 'me'-endpoint (country). Could you try to let me know if that helps here?

Keep me in loop!

 

Have a great one and happy coding,

Hubo

HuboSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Thanks a lot! Including the market (in my case IT market) in the request works fine. But some songs still doesn't have a preview_url (screenshot in the attachments). They are avaible in Italy, because i get the songs from a playlist that I've created myself and I use it daily. There's something I'm missing? Maybe the preview_url of these songs isn't avaiable in Italy? But if I try to use spotify on a browser web whitout a login, I can reproduce the 30 sec. preview of all the songs in the playlist.

Screen1.PNG
screen2.PNG

I'm finding the same problem. Albums that would previously have had previews no longer do.

 

Yesterday they addressed a new bug in the search API (only returned 1 page of results). Tonight I've just also noticed that recommendations are no longer returned for genre seeds.

 

Never seen so many problems turning up in the API than in the last few days!

I can also confirm this behaviour.

 

If you request recommendations using v1/recommendations:

https://developer.spotify.com/documentation/web-api/reference/browse/get-recommendations/

 

Then some of tracks have a preview url and others which don't have previews are set to 'null'.


If you then put the same recommended tracks back into this endpoint:

https://developer.spotify.com/documentation/web-api/reference/tracks/get-several-tracks/

 

Not a single track has a preview_url filled. They are all 'null'.

I just did a little test (thanks to Hubo who helped me to fix the request) and I found out that just the 30-50% of the songs in a playlist have setted the preview_url, so more than half of the songs have not a preview_url. I tested it on 4 different playlist, but I think that the results won't change a lot on other playlists. Is this intentional by Spotify? Or is it just a bug?

Reply to djpip27

Are you by any chance including the "market" parameter in the recommendations request, but not the tracks one? My requests that include market are typically still returning preview urls, but others don't.

This is the requests I'm doing

https://api.spotify.com/v1/tracks/{track_id}?market=IT

 I tried to do this call on the first 100 songs in the playlist "Rock Classics", the first time setting the market=US, and I got the 62 working preview_url and 38 preview_url = null.

The second time setting the market=IT and I got 60 working preview_url.

The third time setting the market=ES and I got 60 working preview_url.

I can't understand this, from Italy I can listen to all the songs in the playlist (so this mean that they are avaiable in the italian market), and if I try to open the playlist without logging in I can listen the 30 sec. preview of all the songs. 

 

This is so strange to me, maybe the preview_url that we can get is different from the actual 30 sec preview used by spotify 

Recommendation Web API Request:

(No market provided)

 

curl -X "GET" "https://api.spotify.com/v1/recommendations?limit=10&seed_tracks=4eVU4U063iMLFJFXb9kzkb&min_energy=0.4&min_popularity=50" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer XXXXX"

 


Response (trimmed for ease of use):

 

...
"id":"6GJk65Bxh1lTntJQEOBHIQ",
"is_local":false,
"name":"Heaven",
"popularity":58,
"preview_url":"https://p.scdn.co/mp3-preview/2726a9595503bf33fdf44d0e85ae8abc7d876d44?cid=774b29d4f13844c495f206cafdad9c86",

 

 

Tracks Endpoint:

(No market provided - querying the same track retrieved above)

 

 

curl -X "GET" "https://api.spotify.com/v1/tracks?ids=6GJk65Bxh1lTntJQEOBHIQ" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer XXXXX"

 


Response (trimmed for ease of use):

 

...
"id": "6GJk65Bxh1lTntJQEOBHIQ",
"is_local": false,
"name": "Heaven",
"popularity": 58,
"preview_url": null,
...

 


It is therefore confusing how dpending on which endpoint is used the preview_url is missing for the same track. I therefore believe this either must be a bug or Spotify are removing track previews from their responses?

Same here! All my tracks are missing the preview_url field now! Will this be resolved soon?

Thanks for bringing this up, folks. We have rolled back a change that was affecting our preview URIs this week. I hope this helps. Please do keep in mind that preview URIs are not always available for every track.

Hello Josh and thanks for your answer! 

However I'm still experiencing issues when trying to retrieve preview_url from Get Album endpoint.

 

For example with a track, I'm correctly getting the preview_url from the track endpoint : https://developer.spotify.com/console/get-track/?id=4NGUT4p5CTbmMXiNUAlPpa 

But if I try to get it through the track's album, no preview_url is returned : 
https://developer.spotify.com/console/get-album/?id=52g9iztdfy5tL8hMeFi7Xe&market=

I suppose the rollback was only affecting tracks?

Hi Josh, unfortunately this hasn't restored previews where they previously loaded (I'm taking into account that some albums never had previews).

 

I would have previously had preview_urls for tracks in this request:

https://api.spotify.com/v1/albums/7wPJ4V3ueggJxvaYscV9Ou

 

Note that I'm not using the "market" parameter, but I never have done when requesting a specific album (or track). I do use the "market" parameter with the search and recommendations endpoints, and these do return URLs (including for tracks from the album above).

 

I am using App Authorisation rather than User Authorisation. Wondering if this means the API therefore doesn't know which market I'm in so can't provide a preview... but it did do until a week ago.

It looks like the fix has now gone through - previews are now back!

@kkhal Glad to hear it.

Hi,

 

By the looks of this thread this issue is supposed to be fixed, but when I try to get preview_url on an album track list it still doesn't work. I am 100% sure that these track had preview urls before but not now.

 

Here are a couple of album IDs which are missing the preview_url now:

1vnXKvlA4hKlkhMhwbQxub 

0Jt7hyudx1Q76SQi7eWuBa 

 

Regards,

Ljupche

I can confirm that neither of those album IDs are returning track previews for the way my API project requests them (without specifying preferred market).


However the same request to my above example album ID 7wPJ4V3ueggJxvaYscV9Ou (and other albums I know to generally have previews) is still providing track preview URLs.

Hi farhanghazi97,

 

Thanks for looking into that. However I am not sure why those track do not have preview_url and they did before.

 

@spotifyjosh in which cases would a track not have preview_urls?

 

Thanks

 

I wonder if some folks here who still aren't seeing preview urls are being hit by this potential bug that I raised a while ago: https://community.spotify.com/t5/Spotify-for-Developers/Possible-Bug-Some-preview-urls-for-tracks-ar...

Worth trying the user authentication flow to see if it gives you a preview url.

Looking into this, it seems that different endpoints return different things when it comes to the preview_url. For example, If I do 'https://developer.spotify.com/console/get-search-item/?q=Kanye&type=track&market=&limit=&offset=&inc... and look through the response for 'Flashing Lights' for example, I can see that it doesn't have a preview URL

 

        "id": "31I3Rt1bPa2LrE74DdNizO",
        "is_local": false,
        "name": "Flashing Lights",
        "popularity": 76,
        "preview_url": null,
        "track_number": 9,
        "type": "track",
        "uri": "spotify:track:31I3Rt1bPa2LrE74DdNizO"

 

However, if I take that track ID and go to https://developer.spotify.com/console/get-track/?id=31I3Rt1bPa2LrE74DdNizO&market=  I do get a preview URL returned

 

  "id": "31I3Rt1bPa2LrE74DdNizO",
  "is_local": false,
  "name": "Flashing Lights",
  "popularity": 76,
  "preview_url": "https://p.scdn.co/mp3-preview/9ae0ad0278c48e41e5e3efa6ebb3bd61f6add244?cid=774b29d4f13844c495f206cafdad9c86",

 

Is this intentional? Seems strange to me, I don't want to have to query each track to get the preview.

Suggested posts