Using the Spotify API in Alteryx to Analyse Your Favourite Artist

What is an API?

API stands for Application Programming Interface. It’s a set of rules that allows different software systems to talk to one another. Think of it like a waiter in a restaurant: you (the application) tell the waiter (the API) what you want, and the waiter communicates with the kitchen (another system) to bring back your order.

There are countless APIs available, from weather and finance data to social media and music. In this blog, I’ll walk through how I used the Spotify Web API to pull data about one of my favourite artists, Floating Points, using Alteryx.

Why Spotify’s API?

The Spotify Web API offers a wide range of music-related data, including artists, albums, tracks, and playlists. The documentation is comprehensive, making it relatively beginner-friendly, and it allows you to retrieve data such as:

  • An artist’s top tracks
  • Track popularity
  • Genre and metadata
  • Audio features like tempo, energy, and danceability

You can find Spotify’s API documentation here:
https://developer.spotify.com/documentation/web-api

Step 1: Read the Documentation

Before working with any API, it’s essential to read the documentation. This gives you the key concepts, endpoints, request formats, authentication methods, and examples to guide you.

To use the Spotify API, you’ll first need to create a Spotify Developer Account and set up a new App. This will generate your Client ID and Client Secret, which are required for authentication.

The documentation includes clear instructions on how to get started and how to request an access token using the Client Credentials Flow.

Step 2: Requesting an Access Token in Alteryx

Once you’ve obtained your client ID and client secret, you’ll need to input them into Alteryx.

A) Text Input Tool
Start by adding a Text Input Tool and create the following fields:

B) Download Tool


Drag in a Download Tool and connect it to the Text Input.

The Download Tool is used to retrieve data from external sources, such as APIs. It can send requests, receive responses, and handle web-based data within your workflow.

In the Basic tab, set the URL field to the value in your URL column.

Make sure that DCM (Data Connection Manager) is turned off to keep the setup simple and avoid connection prompts.

In the headers section ensure to have Content-Type ticked.

In the Payload ensure to have client_id, client_secret, and grant_type ticked. This is all information obtained from reading the documentation in the Spotify Web API website.

Step 3: Parse the JSON Response

Now that you’ve received a response, it’s in JSON format, which is a structured way of storing data often used in APIs.

The JSON Parse Tool breaks that response into a format that’s easier to work with in Alteryx, essentially splitting the nested JSON into rows of data.

  • Connect the JSON Parse Tool to the Download Tool
  • Choose the DownloadData field to parse

You’ll now see fields like:

  • access_token
  • token_type
  • expires_in

Step 4: Preparing the Token for Reuse

You only need the access_token field. Use a Filter Tool and Formula Tool to isolate this, and then prepare it for use in the header of your next API call.


Step 5: Get Your Favourite Artist’s ID

Next, retrieve your artist’s Spotify ID by going to their page on the Spotify app or website. The ID is the string after /artist/ in the URL. For example:

The section after /artist/ is the Artist ID:

Enter this into another Text Input Tool in Alteryx.

Step 6: Build the Track Request URL

Use a Formula Tool to create the endpoint to get the artist’s top tracks.



Step 7: Retrieve the Top Tracks

You can then append this onto the same workflow where you obtained the authorisation token. Following the Spotify Web API documentation, you can now retrieve all the relevant information about the artist by correctly configuring a new Download Tool, this time using the artist-specific URL you’ve constructed and setting the header to include your authorisation token.

This will return a large and complex dataset in JSON format. To make it usable, you can apply a JSON Parse Tool followed by a Text to Columns Tool to split out the relevant fields. From there, use a Filter Tool to keep the data you’re interested in, then reshape it using a Crosstab Tool, and finally tidy it up with a Select Tool to extract the information you need, such as your artist’s top tracks.

Overall, this process shows how powerful APIs can be when combined with Alteryx. By following a few key steps such as, authentication, building requests, parsing JSON, and cleaning the output, you can extract meaningful data from Spotify and tailor it to your interests. Whether you’re exploring your favourite artist’s top tracks or building a dashboard, it’s a great way to practise working with real-world data in a hands-on way.

Author:
Tyler McKillop
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab