This week at the Data School, I learnt how to use a API’s to retrieve information. API’s are rules or protocols that allow applications to communicate with one another. They’re essentially the middle man between two points of communication. Think of yourself as point A, and your Instagram server as point B. As you drag your screen down and release to refresh page and now you’re looking at that holiday photo your friend posted 30 seconds ago, your phone had just made an API call to Instagram’s server to deliver that latest bit of information to your phone.

There are many benefits of using API for data retrieval, but here are a couple of my favourites:

  1. Automation: API’s enable automated data collection, which means you can real time data such as weather updates, bank transactions, or bird spotting, can be sent to your selected analytics applications instantly.
  2. Security: With various authorisation methods such as OAuth and Basic Authorisation, only users with access keys can retrieve data.

 

Having said that, Alteryx can make API calls using its very own Download tool. In this example, I’ll be using dataset on whisky distilleries retrieved using Whisky Hunter’s API (https://whiskyhunter.net/api/) to find out which country is the top producer of whiskies, and the top 5 most expensive distilleries.

 

Step 1: Gather API Documentation

There are three things to look for in an API documentation: authorisation, refresh limit, and pagination.

In this example, the Whisky Hunter API does not require any authorisation, no explicit rate limit, and there were no pagination information found in the Parameters.

 

Step 2: Test the Request URL

It’s always a good practice to test out the API url. Using postman.co with GET method, copy and paste the URL from Whisky Hunter site. Code “200” means the url is working and the API call was successful.

 

Step 3: Add Text Input tool

Rename column as URL, then paste the request URL into the table.

 

Step 4: Connect Download tool

Connect Text Input tool to a Download tool. Leave most of the configurations to default. If you have multiple columns in your Text Input, make sure you select the correct one for Field.

 

Step 5: Parse and clean JSON

Connect JSON Field tool to Download tool. Once you ran the workflow, you should expect to see “200 OK” in the DownloadedHeaders column. You can then proceed to clean your data as you normally would.

 

Step 6: Visualise clean data

Output your workflow as an Excel file or csv, then visualise them using your BI tool of choice.

 

 

The Data School
Author: The Data School