API's in Alteryx

API Stands for Application Programming Interface. Usually we interact with websites buy sending URL Request and retrieving. Below we can see that the differences between an API and a website is that with an API we receive data in either JSON, CSV or XML format.  

Another clear benefit of using an API over web scraping is that an API will have documentation. This is not to say that the documentation will always be good but in comparison to web scraping some documentation is better than none.

How to use an API in Alteryx

For this example we will use the swapi.dev api. This is a free to use API that is showing star wars data. Therefore if you have Alteryx you can follow along with the next steps.

Firstly we start by dragging in the text input tool and type the URL of the API you want to connect to.

Alteryx Text Input Tool

Now use the download tool from the developers tab, configure the tool and untick "use Data Connection Manager".

Alteryx Download Tool

Now use the JSON Parse tool. Make sure to select the field that contains the JSON. and also to select "Output Values into single string field" You will now have all your data in one column (JSON_ValueString) with the headers in the column next to it (JSON_Name).

Alteryx JSON Parse

You will notice that the values in the column with all the headers (JSON_Name) are split by full stops. To extract the headers, use the text to columns tool to split by delimiters.

Alteryx Text to Columns

Now we can now use the cross tab tool to pivot our data.

Alteryx Cross Tab

After using the select tool to only keep the columns that we want we end up with a table like the one below.

Alteryx Output

Just like that we have connected to an API and extracted the data and cleaned it so that it is ready for analysis.

Author:
Alexander Wood
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
© 2024 The Information Lab