Step by Step Guide: Extracting random jokes from an API with just 5 Alteryx tools

by Natalia Miteva

During week 8, Andre introduced us to the magic of working with APIs in Alteryx.

API stands for Application Programming Interface – a set of routines, protocols, and tools for building software applications. In plain English, an API allows applications to communicate with one another. Each time you use social media apps such as Twitter and Facebook, or check the weather on your phone, you’re using an API.

I was super excited to learn about them but also a little bit apprehensive, thinking it will be quite complicated.

To my surprise, it is really quite simple and with a few tools we were able to download information from any API! We used this great collection of free public APIs on github.com to practice.

In this blog post, I will walk you through the steps of extracting random jokes from the Official Joke API with just 5 Alteryx tools.

Step 1. Paste the API URL into a Text Input tool.

Text Input Tool

Step 2. Extract the data from the URL with the Download tool.

Download Tool

Check out the Results window: you can already see the joke popping up in the DownloadData field. It is currently in JSON format.

Step 3. Use the JSON Parse tool to split the joke parts from the DownloadData field into separate rows of data.

JSON Parse tool

Here are the results:

Step 4. Use the Cross Tab tool to structure the joke parts (joke type, setup and punchline) into columns and rows.

Cross Tab tool

The result is a table with some blank spaces and unnecessary columns. Let’s clean this up further.

Step 5. Drag the Summarize tool and select the Max values of the fields type, setup and punchline. This will remove the blank rows in the table.

Summarize tool

Click Run and generate numerous random jokes!

Comment your favourite joke below.

Avatar

Natalia Miteva