Fetch Tracks from Spotify library iOS(Swift)

Square Infosoft
1 min readJan 3, 2019

--

I am dividing this article in 3 Section:
1. Setup the iOS SDK
2. Fetch Tracks
3. Integrate Spotify Player

Now we fetch tracks from Spotify Using Spotify Web API. If you want fetch current login user tracks which is user followed and already added in user Library in Spotify than call below API:

GET - https://api.spotify.com/v1/me/tracks?offset=0&limit=50

Need to Pass access token as ‘Bearer’ token in header so your header format is like:

let header =  ["Accept":"application/json",
"Content-Type":"application/json",
"Authorization":"Bearer \(acess_token)"]

You can call above API using Any Other Network Library or class like URLSession and Alamofire. API response in JSON format also included Song Name, Thumbnail, URI (which you want to use while playing song), PreviewURl, Album details, Artist details and other details related to song.

API response is divided as per limit which you want to pass in URL. You can check response Model or other details on Spotify Web SPI Document.

Now your favorite song is in your app…🙂

--

--