1

I'm building a simple app, where users can share the song they're listening with friends. If the user is a Spotify subscriber and his/her friend is an Apple Music subscriber, and the Spotify user is sharing the song, how can I search for the same song in apple catalog? Is there any common ID, like ISRC on Apple Music? Or any other comparison method? I know how to use search already for songs/albums etc. The question is how to make sure that the result is the same song from spotify. Any ideas? Thank you!

jscs
  • 63,694
  • 13
  • 151
  • 195
GuiOS
  • 73
  • 9

3 Answers3

5

The ISRC code is certainly the trick here. Here's how to search in either direction:

Spotify to Apple Music

curl -g -X "GET" "https://api.music.apple.com/v1/catalog/us/songs?filter[isrc]=ISRC" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer DEVELOPER_TOKEN"

Apple Music to Spotify

curl -X "GET" "https://api.spotify.com/v1/search?q=isrc:ISRC&type=track" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer OAUTH_TOKEN"

I wrote more about this on my Medium. Good luck!

Lee Martin
  • 81
  • 1
  • 5
2

Song model for MusicKit does not have ISRC according to the documentation. iTunes EPF has ISRC info, but this is not a part of MusicKit API.

Bahri Okuroglu
  • 178
  • 1
  • 7
1

I did something similar with one of my projects, so hopefully it can get you on the right track. In short, you can use the iTunes API alongside the Spotify API to search for the same results.

An example in Python.

Get the current playing song/artist with the Spotify API. Search through the response for the information you want, in my case, it was the artist name and album name.

results = sp.currently_playing()
artist = results["item"]["album"]["artists"][0]["name"]
album = results["item"]["album"]["name"]

Look it up with the iTunes API.

i_artist = itunes.search_album(album, artist)[0]

You'll have to learn how the API's work. With iTunes, a search results in a list of results. I'm taking my chances and just grabbing the first one (the most popular). But you can certainly filter through them to make sure it matches what you want. You'll obviously run into things like artists having the same album titles, or even sharing the same name.

It looks like your target platform is iOS, but my code should be a starting point. It's just a matter of saving the information from one platform into variables, and the searching then next one with them.

Hopefully I understood your question correctly, I can expand or provide more code if needed.

23k
  • 1,596
  • 3
  • 23
  • 52
  • 1
    Thank you 23k. I've been doing like you said. But most of the calls returns different songs...even when comparing name, album and duration. But probably is the easiest way out, Or try EPF as @bahriOkuroglu says below. The ideal world would be an id as ISRC. – GuiOS Aug 03 '17 at 20:58
  • @GuilhermeSolDuschenes Yup that would be the most ideal solution. I also run into the problem of incorrect results more than I would like. I guess it's also dependent on how popular the song you are listening to is. I'll keep looking into this problem and update my answer if I find anything more reliable. – 23k Aug 03 '17 at 21:04
  • @23k, Thanks for your solution. Can you Please provide me a `search API` with the `parameters`? – Ilesh P Nov 01 '18 at 05:33
  • @ilesh Not sure I understand what you're asking for. – 23k Nov 01 '18 at 14:40
  • @23k, iTunes Search API for the find the similar song of the Spotify. Are you using `isrc` or `songName`, `artist Name` and etc? – Ilesh P Nov 02 '18 at 05:30