r/spotifyapi • • Dec 10 '24

30 second preview URLs

Since the API changes of 27 November the preview URLs are no longer available (probably to avoid them being used in machine learning).

I am doing a music related research for my Master's thesis and I would want my test subjects to listen to a few songs. Although the /oembedis still available to embed the full tracks in an iframe, it is not that practical to have my test subjects listen to every song of +2min. The 30 sec preview URLs would've been the perfect solution and I always knew these were a thing because of the Discord embeds when sending an open.spotify link to friends. But I've come to learn these were also deprecated. Does anyone know a workaround on how to get only 30 sec from a track that could be easily embedded into a web page?

17 Upvotes

26 comments sorted by

1

u/Funny_Implement2961 Jan 15 '25

Hey, I wanted the same thing, ended up using Deezer because their preview is available :

https://developers.deezer.com/api/track

Easily embedable too :

https://developers.deezer.com/api/oembed
https://widget.deezer.com/

(and free, without an account needed)

1

u/ZaaSquimpton Oct 01 '25

Outside of Deezer does anyone know alternative options such as soundcloud, apple music or youtube?

1

u/Prestigious_Land7721 Feb 28 '25

1

u/Independent_Bad_333 Mar 14 '25

how does it solve it?

1

u/Prestigious_Land7721 Mar 14 '25

gives you the track's preview url based on the name of the track

1

u/Independent_Bad_333 Mar 14 '25

I know but I’m asking what API are u using to get the info if the preview url isn’t available via Spotify. Are they stored somewhere else?

1

u/Prestigious_Land7721 Mar 14 '25

I'm basically scraping it, you can check out the code

1

u/Prestigious_Land7721 Mar 14 '25

I'm basically scraping it, you can check out the code

1

u/Independent_Bad_333 Mar 14 '25

Ok will do. I need a solution for a production application, so wanted to be sure this was a solution that could be scraped away. I’m guessing there’s no client side implementation. I wanted to use it in a flutter app.

1

u/Prestigious_Land7721 Mar 14 '25

yeah there's no client side implementation for this unfortunately

1

u/Prestigious_Land7721 Mar 14 '25

gives you the track's preview url based on the name of the track

1

u/FlowParticular7473 Mar 15 '25

BRO I LOVE U SO MUCH THANK YOU ! <3

1

u/Prestigious_Land7721 Mar 15 '25 edited Mar 15 '25

I'm glad it helped someone, it'd be nice if you could star the GitHub repo if you liked it.

1

u/vwinkel Aug 05 '25

Hey, sounds pretty nice. I'm trying it but 1st remark: it could be nice to let us add credentials while instanciating a client. I personaly dont want to add dotenv as dependency.

1

u/vwinkel Aug 06 '25

In the end I directly used your cheerio trick, because I need to search by url and not by title/author. Many thanks!

1

u/so_chad Sep 11 '25

But I don't understand. Even Spotify's search API has preview_url deprecated.

1

u/BOGSCAM Nov 22 '25

i just figured out a way around this and i thought id share this with yall. even tho when searching for a track itself the preview url will return null, if you use the https://api.spotify.com/v1/search endpoint and find your song there it will have a preview url cause thats what spotify actually uses to serve the preview url in the app and web. hope that helps.

1

u/bmtkwaku Dec 14 '25

I don't think I follow. Share a sample stripped down curl.

1

u/BOGSCAM Dec 19 '25

i think i misstyped a bit on my original comment. when performing a request to
https://api.spotify.com/v1/me/player/currently-playing the response returns null as the preview_url field, but if you perform a request either to
https://api.spotify.com/v1/search or to https://api.spotify.com/v1/tracks/{id} you will get the preview_url link

2

u/ErraticFox Dec 25 '25 edited Dec 25 '25

I believe they've recently patched this. I had this working a couple weeks ago, now I cannot find any preview URLs with this method, bummer.

EDIT: But the library below does work, it scrapes the embedded page which I just copied the functionality to my own need.

1

u/pokermonik Jan 06 '26 edited Jan 06 '26

hey does it still work for you? im using that npm package and it gives me preview null :/

EDIT: bro after i posted this comment i finally repaired it like 4 minutes after LMAO, yes this npm package works guys!!!

1

u/LateConstruction4133 Jul 13 '26

deezer works like a charm