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.

  • Go to the Spotify registration page and create your Spotify account.
  • Once  the account has been created, go to the Developers Dashboard. The Spotify Developer Terms of Service will appear. When we accept these terms, we'll be redirected to the Developers Dashboard.
  • Click the "CREATE AN APP" button. A dialog box requesting the app's name and description will pop up.
  • 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:

    • Click the "SHOW CLIENT SECRET" button to reveal the "Client Secret" key.
    • Copy the "Client ID" and "Client Secret" keys.
    • Click the "Edit" button in the widget below.
    • Assign the values of "Client ID" and "Client Secret" to CLIENT_ID and CLIENT_SECRET keys respectively.
    • Click the "Save" button to save these keys so they can be used throughout the course.
    print("Your Client ID is: {{CLIENT_ID}}");
    print("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:

    {{EDUCATIVE_LIVE_VM_URL}}/callback

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

    • 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.
    • Copy the redirect URL from the widget above and add it to the "Redirect URIs" list in the dialog box.
    • Click the "SAVE" button at the end of the dialog box to save these settings.