Get Started with Spotify API

Learn how to obtain the client credentials required to use the Spotify API.

To use the Spotify API, we need the "Client ID" and "Client Secret" that the Spotify API provides. We'll also need to add a redirect URL on which we want to land once the user grants us the required permissions. Initially, we need to set up an account and create an app on Spotify. We'll look at how we can do this step-by-step in this lesson.

Create an app

Let's look at how to create an app on Spotify:

  1. Go to the Spotify registration page and create your Spotify account.

  2. Once the account has been created, go to the Developers Dashboard and click the "LOG IN" button. The Spotify Developer Terms of Service will appear. When we accept these terms, we'll be redirected to the Developers Dashboard.

  3. Click the "CREATE AN APP" button. A dialog box requesting the app's name and description will pop up.

  4. Fill in this information and click the "CREATE" button. We'll be redirected to the app overview page.

The process is visually depicted in the slides below:

Fetch the "Client ID" and "Client Secret"

Creating an app generates a "Client ID" and a "Client Secret" associated with that specific app. We'll need these keys to get an authorization token for making API calls. Once we land on our app overview page, follow the steps below:

  1. Click the "SHOW CLIENT SECRET" button to reveal the "Client Secret" key.

  1. Copy the "Client ID" and "Client Secret" keys.

  2. Click the "Edit" button in the widget below.

  3. Assign the values of "Client ID" and "Client Secret" to CLIENT_ID and CLIENT_SECRET keys respectively.

  4. Click the "Save" button to save these keys so they can be used throughout the course.

Press + to interact
console.log("Your Client ID is: {{CLIENT_ID}}");
console.log("Your Client Secret is: {{CLIENT_SECRET}}");

Add the redirect URL

Before generating the authentication token, the last step is to add a redirect URL in the Spotify app. This URL is where we want the user to land once the user has logged in and granted us the required permissions. The redirect URL for this course is given below:

Press + to interact
{{EDUCATIVE_LIVE_VM_URL}}/callback

Follow these steps to add this URL to your Spotify app:

  1. Click the "EDIT SETTINGS" button on the app overview page. A dialog box from where you can change your Spotify API app settings will appear.

  2. Copy the redirect URL from the widget above and add it to the "Redirect URIs" list in the dialog box.

  3. Click the "SAVE" button at the end of the dialog box to save these settings.