2 Introduction to API design patterns
This chapter covers...
- What is an API design pattern?
- Why API design patterns are important
- The anatomy and structure of an API design pattern
- An example of designing an API with and without using design patterns
Now that we have a grasp of what APIs are and what makes them “good,” we can start to explore how we might use apply different patterns when building an API. We’ll start by exploring what API design patterns are, why they matter, and how they’ll be described in the later chapters. Finally, we’ll look at an example API and see how using pre-built API design patterns can save lots of time and future headache when building an API.
2.1 What are API design patterns?
Before we start exploring API design patterns we have to lay a bit of groundwork, starting with a simple question: what is a design pattern? If we note that “software design” refers to the structure or layout of some code written in order to solve a problem, then a software design pattern is what happens when a particular design can be applied over and over to lots of similar software problems, with only minor adjustments to suit different scenarios. This means that the pattern isn’t some pre-built library we use to solve an individual problem, but instead more of a blueprint for solving similarly structured problems.