I’m currently in the middle of a client project which will produce playlists for both Spotify and Apple Music. In order to pull this off, I need to create a local database of tracks that contains ids from both services I can utilize when calling their respective “Create Playlist” functions. Sadly, if you look at a Spotify track response, you will not find an Apple Music track id and the same goes for the opposite. In fact, the only additional track identifier available on Spotify now is an ISRC code. Luckily for us, the Apple Music API added search by ISRC during WWDC 2018. But, what the hell is an ISRC code?
Apparently the ISRC or International Standard Recording Code was codified in 1986 to uniquely identify sound recordings and music video recordings. The ISRC identified a particular recording, not the composition and lyrical content. As such, remixes, edits, and different recordings will receive their own ISRC. Works, on the other hand, are identified by an ISWC. In addition, remastered recordings may retain their original ISRC depending on the significance of audio changes.
Tight, let’s use it.
Spotify to Apple Music
So, let’s say you have a Spotify track response. Within this response you will find the
external_ids key and it should contain an ISRC value. With this value you can then search for the matching track on 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 will allow you to send up to 25 ISRC codes at once. Note, given what we know about ISRC, you may receive more than one song from the Apple Music catalog. I’ll let you decide how you may want to deal with that.
Need an Apple Music developer token? I wrote a little helper for that as well.
Apple Music to Spotify
On the other hand, you might have an Apple Music song object. Within this object you will find an attributes object that contains an ISRC property. Using this value you can now search for the matching track with the 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’m not sure how many of these queries you can string together in a single call as it isn’t clear in Spotify documentation but feel free to experiment. An easy way to generate a Spotify OAuth Token is to use the provided Console.