API’s: Alteryx or Python? Which one is more friendly user?

by Ronaldo Licaj

What is an API?

API stands for Application Programming Interface. It is similar to a server used to send data and retrieve data through programming scripts. The purpose is to retrieve the data from the web and display to a software application so that the end user can have access to the data.

API’s are similar in this sense to a webpage browser in the way they function. A request is send to the server where a response is being send back. The server at least in the case we use Python will provide the data in a JSON format, which stands for JAVASCRIPT OBJECT NOTATION, and it is the case when using most programming languages. In the case, the user is using Alteryx to interact with the API, things are more straightforward as we will see below by going through a typical Alteryx workflow that I recently worked on.

API Status Code

Status codes indicate information on the request you made with the server. As you can observe the status codes starting with either 4 or 5 indicate an error while with 2 it means a success. Some of the most relevant are:

· 200: OK

· 400: Bad Request

· 401: Unauthorized

· 404: Not Found

· 503: Internal Server Error

API request Python vs. Alteryx:

In Python, the most common library for making request and working with API’s is the requests library. To able to use it you will need to install it first.

After installation you have to import the library by using a simple command line.

Making an API request in Python is usually done by using the requests.get() function, by giving the URL in parentheses of the API we want to retrieve the data from. In this case we use a simple API from https://randomfox.ca/ .

The result is a dictionary in JSON format.

In Alteryx, the whole process is so much more easy. All we need is to drag and drop a “Text Tool” in the canvas and paste the API’s URL on the designated field, in order to get the list of books from our webpage.

Next we need to use the Download Tool in order to get the data from the API by using the URL.

To parse the data we use the JSON parse tool. All that we need to do is select the field which contains all the data (in this case the DownloadData column). This will split the information in two new columns. The JSON_Name column contains the headers for the data, while JSON_ValueString contains the data itself.

Next we need a text to columns tool to get our headers out from each column, as shown in the example below.

The final step after a bit of cleaning, is to use the Cross tab tool the data to give us the clean data we need to create a dashboard. The cross tab tool takes the data from this…

In the end we have a nice clean table ready to use.

Final thoughts:

My personal experience so far, both in Alteryx as well as in Python shows that although it is easier to extract the API call and clean it in Alteryx, the possibilities that coding provides for those who are into coding are infinite. But of course to extract the required data from the server certainly Alteryx, with its drag and drop functionality will do it much faster. The end choice and preference is yours.