Simple REST API JSON Example

Have you heard of pulling data from API? In a previous Tableau blog post here, I am taking a course on API. Wikipedia defines API as "An application programming interface is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. "


There are several types of API according to Techolution > LINK

  • Public APIs that are open and available for use by anyone. These can be blocked if you are on an internal network.

  • Partner APIs API's available through a third-party business partnership

  • Internal/Private APIs which are only available through a secured network for internal business use.

  • Composite API: which can be a combination of above with the objective of speed and performance for users

In the example below I will show you I will be using REST API which is short for Representational State Transfer.’ This means in order to pull data from the API it must have the following;

  • It must not allow the receiver to keep information they receive from the sender. It must be "stateless."

  • It must exist independently from the client and the server.

  • It must have an ability to be cached.

  • It must be uniform and be able to be communicated via HTTP, URI's, CRUD and JSON.

  • It must be layered with a hierarchy.


Steps for your workflow;


First I will grab a Text Input Tool onto my Alteryx canvas. I will paste the following URL in this tool and rename the column World Clock Input;

http://worldclockapi.com/api/json/est/now

This site is public and uses REST API. It also pulls the current time via JSON format.


Next I will grab the Download Tool from the Developer tab and connect it to this Text Input Tool.

I select the World Clock Input column from the URL field. I will not make any changes to any of the other tabs etc. Depending on the API you are pulling you may need to adjust details on those tabs; for this very simple example, you do not need to make any changes.

Next I grab the JSON Parse Tool in the Developer tab and attach it to my Download Tool. I need to select DownloadData from the JSON Field drop-down.



Your workflow should look like this;


In my results you can see that it parsed out the different time variables. You can see Current Date Time and the UTC (Universal Time) Offset since I am in EST.



Try it yourself! There are other links for the World clock in this site below;

http://worldclockapi.com/


133 views0 comments