1 Introduction to APIs

This chapter covers

  • What are interfaces?
  • What are APIs?
  • What is resource orientation?
  • What makes an API “good”?

Chances are that by picking up this book you’re already familiar with the high-level concept of an API. Additionally, you probably already know that API stands for application programming interface, so the focus of this chapter will cover what these basics actually mean in more detail, as well as why they matter. Let’s start by looking more closely at this idea of an API.

1.1 What are web APIs?

An API defines the way in which computer systems interact. And since an exceptionally small number of systems live in a vacuum, it should come as no surprise that APIs are everywhere. We can find APIs in the libraries we use from language package managers (e.g., an encryption library that provides a method like function encrypt(input: string): string) and technically in the code we write ourselves, even if it’s never intended for use by anyone else. But there’s one special type of API that is built to be exposed over a network and used remotely by lots of different people, and it’s these types that are the focus of this book, often called “web APIs.”

1.2 Why do APIs matter?

1.3 What are resource-oriented APIs?

1.4 What makes an API “good”?

1.4.1 Operational

1.4.2 Expressive

1.4.3 Simple

1.4.4 Predictable