Search code examples
spotifyurlencode

How to link to correctly urlencode spotify search


Something seem to have changed in how one links to a spotify search. The following code should work:

<a href="spotify:search:track:castle+on+the+hill+artist:ed+sheeran">spotify:search:track:castle on the hill artist:ed sheeran</a>

When Spotify opens it says No result found for "track:castle+on+the+hill+artist:ed+sheeran"

We have also tried percent encoding:

<a href="spotify:search:track:castle%20on%20the%20hill%20artist:ed%20sheeran">Castle on the hill Ed Sheeran</a>

But this also fails.

Any advice on how to properly link to a Spotify search?


Solution

  • I figured it out, solution posted here https://pappmaskin.no/2017/02/linking-to-a-spotify-search-with-both-track-and-artist/

    There is a new format for the url:

    track:"castle on the hill" artist:"ed sheeran" 
    

    And you need to urlencode that part separately, to

    track%3A%22castle%20on%20the%20hill%22%20artist%3A%22ed%20sheeran%22.
    

    And add spotify:search:in front: spotify:search:track%3A%22castle%20on%20the%20hill%22%20artist%3A%22ed%20sheeran%22