As both a musician and a data analyst, it shouldn’t come as a surprise that I’ve been really keen to explore some music artist data, so I have decided to put together a simple guide that outlines how to use Alteryx to connect to Spotify’s API and get all the data you could want!


1. Login to Spotify for Developers and click Create App to generate a Client ID and Client Secret.


2. Click into the app and click on Settings to view your unique Client ID and Client Secret.


3. Begin your Alteryx workflow by dragging on a Text Input with a column named URL and underneath This API will provide the client with an access token, valid for one hour, that is necessary to provide to access Spotify’s data.


4. Drag on a Download tool that will take the URL from the text input and, in the Configuration pane’s Payload tab, change the HTTP Action to POST and add the following data:

Name: grant_type  –  Value: client_credentials
Name: client_id  –  Value: your Client ID from above
Name: client_secret  –  Value: your Client Secret from above


This workflow will now return a JSON file as DownloadData that contains your access token.


5. Drag on a JSON Parse tool and select the JSON Field as DownloadData. The output will contain an access_token value, a token_type value and an expires_in value.


6. Now we must concatenate the token_type and access_token as the header for our ultimate API call, which we can do with a few core Alteryx tools:

a. Drag on two Filter tools each coming from the JSON Parse tool, one filtering for [JSON_Name]=’access_token’ and the other for [JSON_Name]=’token_type’.


b. Next, conect each of the True anchors into an Append tool, deselecting all fields except a URL field and each of the JSON_ValueString fields, renamed accordingly as access_token and token_type.


c. Finally, drag on a Formula tool to create a new field called URL with the desired API endpoint – in this case we are searching for the first 50 entries in the list of albums by The Weeknd; you can create your own according to the documentation. Additionally, create a new field called Authorization with the formula [token_type] + ‘ ‘ + [access_token]. This will be required to authorise the API call. Afterwards, add a Select tool to keep only the new URL and Authorization fields.


7. Drag on another Download tool that will take the new URL and, in the Configuration pane’s Payload tab, tick Authorization.


The output should return a 200 OK response in DownloadHeaders field, and the data will be contained in the DownloadData field! Drag on another JSON Parse tool and begin to parse out the information you wish to observe.


Hopefully this will help you obtain and visualise some really interesting data from Spotify. Happy developing!


Cover image by Tom Majric from Pixabay

Hunter Iceton
Author: Hunter Iceton

Hunter Iceton is an enthusiastic and positive individual. He graduated from Sydney Uni in 2017 with a Bachelor of Commerce (Liberal Studies) majoring in Finance, Marketing and Quantitative Business Analytics. For the next few years, Hunter spent his time creating and releasing music, while tutoring primary and high school students in Mathematics and Business Studies. Hunter is now excited to be joining The Data School, looking forward to approaching analytics with a creative perspective. In his spare time, Hunter enjoys continuing to create music, reading philosophy and cooking plant-based dishes. Otherwise, he can usually be found at a restaurant, a bar or an art gallery.