The Sovereign Individual
Book Review

API Design Patterns

API Design Patterns lays out a set of design principles for building internal and public-facing APIs.

Gary Woodfine

Gary Woodfine

24 Sept 2024

API Design Patterns

API Design Patterns

API Design Patterns reveals best practices for building stable, user-friendly APIs. These design patterns can be applied to solve common API problems and flexibly altered to fit specific needs. Hands-on examples and relevant cases illustrate patterns for API fundamentals, advanced functionalities, and uncommon scenarios.

The use of design patterns in software development is prevalent, primarily because they are templates to solve common problems providing repeatable solutions, which can be applied common problems. The benefit of software design patterns lies in their re-usability and extensibility of the already developed applications enabling more sophisticated and advanced approaches.

API are a set of instructions, standards or requirements that enables a software or app to employ features/services of another app, platform or device for better services.

Why you should read this book

It seems almost inevitable today, that whatever software project you embark on there will always be a requirement for a web based API. Indeed over the past several years I have been on many projects that have involved as much. Yet it seems, whenever the teams embark on these types of projects they think they are the first to do so. I often find teams repeating the same mistakes, and in most cases never actually successfully implement an API and rather create a loosely collated collection of functions available over HTTP, which are different things.

It stands to reason, that after several years of Web API development, there must be recurring patterns and practices that can be used by software development teams to develop truly scalable, robust, secure and consistent web API's.

about the book

API Design Patterns lays out a set of design principles for building internal and public-facing APIs. Google API expert JJ Geewax presents patterns that ensure your APIs are consistent, scalable, and flexible. You’ll improve the design of the most common APIs, plus discover techniques for tricky edge cases. Precise illustrations, relevant examples, and detailed scenarios make every pattern clear and easy to understand.

The book provides a comprehensive analysis of key API patterns that will improve your design skills, leading to consistent APIs that consumers crave. The author goes into great depth to explain not only why patterns are useful in API design, but why these specific patterns lead to better APIs.

The author clearly has an extensive experience designing and developing a comprehensive set of API's and is able to draw on this experience to present a foundational reference packed full of expert well-thought-out examples, with modern API design patterns.

Pros

I particularly learned more from this book, than I originally anticipated and appreciated that I had previously barely utilised the rich HTTP design patterns available via REST. Discovering that I can extend the typical REST methods with custom methods and that there was a convention one could follow to do so!

I particularly enjoyed and learned a lot from the chapters on Pagination and Partial Updates and Retrievals. Pagination enables large collections of results or large single resources to be consumed in a series of bite-sized chunks rather than as a single large API response using three special fields: maxPageSize , pageToken , and nextPageToken .

If there are more pages, a response will include a nextPageToken value, which can be provided in the pageToken field of a subsequent request to get the next page. We rely on a maximum page size rather than an exact page size as we don't know how long it will take to fill a page exactly and must reserve the ability to return even before a page of results is fully populated.

There was also the additional bonuses of discovering patterns for handling long-running operations and file based operations.

There are not many code samples and the vast majority of the ones that are , are in Java but they are clear and concise enough for developers in any language to understand.

I found authors style of writing and explanations to be clear, really informative and easy to read. This book is s one of the few guidebooks providing insights of a variety of practical issues you're most likely to face as a back end engineer, providing common patterns and approaches ways to design APIs with pros and cons of each.

I firmly believe you'll improve the design of your APIs and discover techniques for tricky edge cases. Due to the fact that the book provides precise illustrations, relevant examples, and detailed scenarios make every pattern clear and easy to understand. It certainly did so for me.

Recommendation

In my opinion, this book should be required reading for any team or developers embarking, planning or even currently developing an API regardless of whether there are plans for the API to be released publicly or not. There are a number of best practice patterns and implementations you can learn to your advantage.

Gary Woodfine
Gary Woodfine

Back-end software engineer

Experienced software developer, specialising in API Development, API Design API Strategy and Web Application Development. Helping companies thrive in the API economy by offering a range of consultancy services, training and mentoring.

Need help starting your API project?

We'll help you with your API First strategy, Design & Development