DSNY3 Week8: API

What is API?

In Week 8, we learned the concepts and user cases for API, which stands for Application Programming Interface. To put it simple, API is a piece of software that allows programs to talk to each other. An API defines how different software components should interact with each other, including what data can be exchanged, what actions can be performed, and what rules govern the communication.

For example, let's say you're using a weather app on your smartphone to check the weather in your location. The app needs to fetch the weather data from a weather service provider to display the information.

The app developer can use the weather service provider's API to retrieve the weather data. The API defines the structure of the data and the rules for how the app can access and use the data.

When the app sends a request to the API for weather data, the API checks the request and sends back the requested data in a standardized format such as JSON or XML. The app can then use this data to display the current weather conditions on your smartphone.

Without the API, the app would have to access the weather data directly from the weather service provider's database, which would be complex and time-consuming for the app developer. Using an API makes it much easier and more efficient for the app developer to integrate weather data into their app.

APIs & Alteryx

There are a number of software to request and receive data from API and last week, we practiced the techniques in Alteryx. Here is an example of how you can use the Air Quality Index API to download information about air quality data in Alteryx:

1) First, you will need to create an account with the Environmental Protection Agency’s AirNow and obtain an API key from their website: https://docs.airnowapi.org/login

2) Once you have your API key, choose a particular API you want to use to request the data you are interested in (here I chose “Historical Observations by Reporting Area”)

The nice point of this website’s API is that it allows you to build and test the API you want.

3) So, here you can see, each generated URL represents the air quality data for a single date and for a particular area (one zip code). If I want to get more data for different dates and locations, I need to change the parameters highlighted. So the followings are what I did in Alteryx:

For the inputs, I put the basic URL (URL part before the ? mark when you see in the generated URL picture) and the dates I am interested in.

Then, I created full URL link by using the formular tool in Alteryx. Here I also edited the zip code to have 10038 for the New York and 90012 for the California. After that, I used Download tool in Alteryx to request data from website API. Once the data was successfully downloaded, I added more tools to clean the data for future analysis and saved the output.

The final output data looks like this:

Author:
Zhengyi Qiu
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
© 2025 The Information Lab