Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Pulling song names for Rolling Stone 500 greatest albums API

Inactive User
Not applicable

Hello All,

 

So I have a data set with the names of the rolling stone 500 greatest albums. What I'm trying to do now is pull the song names for each of those albums using an API connection from (Lastfm,musicbrainz,discogs whichever works really). My question is, how would I only pull those 500 albums from an API connection, using the text input and download tools? Attached below is the data set, any help would be greatly appreciated.

5 REPLIES 5
bbak
9 - Comet

Hi rjanezic,

 

If you want to use LastFM, your API query will look like this


http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=APIKeyGoesHere&format=json&artist=The...

 

First, you need to go to create an API account at https://www.last.fm/api/account/create

 

Just put in whatever application name and description that you want. Once you create your API account, they will give you an API key. If you want to test this out to see if it works, you can put that query string into a text input (Don't forget to put your API key into the string where I have "APIKeyGoesHere"), hook it up to a download tool, and check the "DownloadData" field to make sure it is pulling all of the data that you need. 

 

If you notice at the end of the example query I provided, you see "&artist=The Beatles&album=Sgt. Pepper's Lonely Hearts Club Band". This is the piece that needs to be swapped out with each artist/album combination for your list. I used a formula tool with the formula "&artist="+[Artist]+"&album="+[Album]

 

Then I appended each artist/album combo to the end of the base API query that won't change http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=APIKeyGoesHere&format=json

 

This gave me a list of queries that needed to be run. Then I created a macro with the download tool in it so that I could send each query string through and stack the outputs. The resulting data is in JSON format, so you will still need to parse that information out.

 

 

 

 

 

 

 

LastFM Api Query.PNG

 

download macro.PNG

 

 

I hope this helps!

bbak
9 - Comet

Hi Rjanezic,

 

First, you need to create an API account with lastFM. You can use one of the other services, I just picked it because it was first. They will give you an API key after registering and creating an application.

 

Here is the basic API call where you will swap in your API Key:

http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=APIKeyHere&format=json&artist=The Beatles&album=Sgt. Pepper's Lonely Hearts Club Band

 

The two parts to this are the base

http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=APIKeyHere&format=json

 

and the artist/album

&artist=The Beatles&album=Sgt. Pepper's Lonely Hearts Club Band 

 

You need a formula tool that creates this second part of the string using the formula "&artist="+[Artist]+"&album="+[Album] from your CSV file.

 

Then, you add these combinations onto the end of the base string http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=APIKeyHere&format=json using another formula tool.

 

After that, you create a macro that sends these strings through a download tool and returns the download data which will have the track list and other album data which will then need to be parsed out. 

 

I hope this helps!

 

 

 

LastFM Api Query.PNGdownload macro.PNG

Inactive User
Not applicable

Wow! Thank you this is working great. Quick question though, I've noticed that Artists or Albums with ampersands (&)  aren't pulling in the data and I'm getting an error. I've looked into different ways of handling this, but I haven't found anything that works. Any ideas?

BenMoss
ACE Emeritus
ACE Emeritus
Have you tried using %26 to replace the & in the band name?

Ben
Inactive User
Not applicable

That did the trick! Much appreciated, I was using &amp

Labels