Web APIs#

Start by watching a 4 minute video overview of APIs.

We’re focusing on web APIs, which allow for information or functionality to be manipulated by other programs via the internet. Web APIs are a popular workflow for making data available from large-scale repositories. A few examples…

  • The U.S. National Archives and Records Administration (NARA) makes the National Archives catalog, Executive Orders, and photographic image content available via an API.

  • The Smithsonian Institution allows open access to museum collection metadata via an API.

  • The U.S. Library of Congress provides access to digital collection metadata, digitized historical newspaper images, public radio and television programs, and World Digital Library collections via APIs.

  • The U.S. Census Bureau makes a wide range of public data available via API.

APIs let us bring a live data connection into a programming environment and interact or work with it based on the format and protocols established as part of the API.

For example, imagine you want to know winter weather road conditions or the status of snow plow routes. Downloading a static dataset isn’t going to work for this specific use case–you need a live data feed with up-to-date information. This is the beauty of APIs!

API Terminology & General Workflow#

Some terminology that goes along with APIs.

  • HTTP (HyperText Transfer Protocol): primary means of communicating or transferring data on the world wide web.

  • URL (Uniform Resource Locator): an address or location information for information on the web. A URL describes the location of a specific resource.

  • JSON (JavaScript Object Notation): plain-text data storage format

  • REST (REpresentational State Transfer): best practices for implementing APIs. APIs that follow these principles are called REST APIs.

A very general web API workflow…

  • Request data from a URL

    • Sometimes you have to specify additional parameters, like headers or an access key/token.

  • Store the response in Python

  • Convert the response to the appropriate Python data structure

Let’s look at a couple of examples.

Section Table of Contents#