Getting Started with Spotify API with Visual Studio

I have personal project to understand the meaning of music through Azure Cognitive Services. In order to obtain music information, I use Spotify. Spotify is a music subscription services just like Amazon, Pandora, or Apple Music. Spotify has API that can be accessed through our application. On this post, I will overview the Spotify API and how to integrate it on Visual Studio 2019 Development environment.

Before we begin

  • You should register and create Spotify account and activate your developer account here.
  • You should also install visual studio 2019 here

Our Mission

On this mission, we will explore the Spotify API and will create skeleton project in Visual Studio.

#1 Creating and Application on Spotify

You can login to Developer Dashboard on Spotify. If you have trouble login, I suggest you use another browser like Opera, I have login issue with Edge / Internet Explorer. You will create an app to get client ID and Client Secret. After obtaining client ID & Secret, we can continue the look the documentation

#2 Understanding the Spotify API features

Let's visit the docs pages here. You can see that Spotify has several categories on their API platform.

  • The Web API. Many analytics scenario can be obtained through this API. Playlists, recommended song, history, and many more. It is good API for your music and personalization need.
  • Web Playback. This will developer create music player by using Spotify control.
  • IOS, Android, and Widgets. This API will have specific features for the selected platform.

For this article, I will choose the Web API and see the dynamic documentation through console. You can explore the API, through console. It uses JSON for the data format.

#3 Creating Spotify Project

On this step, I will use class library that will use the Spotify API. You can create any project in Visual Studio. You have two choices to consume Spotify API. The first choice is by using JSON Parser (just like Newton Soft). The second choice is using the API wrapper. We use the second choice on this article

  • Open your NuGet Manager and Search Spotify
  • I use Spotify Net by installing through NuGet

#4 Let's Call the API

We got some help from Spotify Net. It means we don't need to do REST API call. I create a class library project with SpotifyHelper class. The AccessToken can be obtained from here and click the Get Token. In real project, we will create a login to obtain the token. The codes will list top ten artist based on user.

#5 Let's test the API

I create the windows forms app. Creating a simple interface and call the class library

I get my top ten artist that listened by the user


That's it! You can try by yourself and ping me for any questions.

Add comment

  Country flag

  • Comment
  • Preview

Topics Highlights

About @ridife

This blog will be dedicated to integrate a knowledge between academic and industry need in the Software Engineering, DevOps, Cloud Computing and Microsoft 365 platform. Enjoy this blog and let's get in touch in any social media.


Month List