CS 257: Software Design

Lab: using HTTP-based APIs

Nothing to hand in

I recommend doing the coding part of this with a partner for fun and to have a sounding board as you do the work. If you want me to assign you somebody, let me know. Otherwise, I'll leave you to it.

APIs via HTTP

The acronym API stands for Application Programming Interface, and refers to a mechanism by which one software entity can obtain a service from another software entity. For example, when your Java program wants to compute a square root, it might use the Math.sqrt method, which has an interface that we sometimes call a signature (e.g. public static double sqrt(double))...and can also be referred to as an API.

API is one of those terms that can be used for lots of different but related things. For example, you might refer to the signature of Math.sqrt as an API. Or you might refer to the collection of methods in the Math class as an API. Or you might refer to the entirety of the Java standard libraries as an API.

More recently, as APIs made available over the web have started to become popular among programmers, some people have started using API to refer only to such entities. Such is the fate of technical vocabulary. Sometimes it's precise, sometimes it's muddy.

This week, we're going to take a look at these latter types of APIs—the kind that you can access via HTTP. An easy example is my linguistic API that I will demonstrate for you in a video or in class. By pointing your browser at a particularly formatted URL, you can conjugate verbs, look up word translations, pluralize nouns, find root words, etc. in about a dozen languages. The resulting output is in a machine-readable form (JSON—JavaScript Object Notation) unless you specifically request human-readable results (HTML). That machine-readable output is particularly interesting, because it allows other software developers to use this API to help build new services.

Your goal for this lab will be to learn more about the structure of HTTP-based APIs, and to learn how to make use of them from Python programs.

Your tasks