There’s been lots of hubbub surrounding the WordPress REST API which initially started as a separate plugin, but quickly grew to be part of the WordPress core. It’s not finalized yet but this merger with the core codebase means that WordPress developers will have a much easier time accessing the API in their themes and plugins.
Yet as with any API there’s a lot to learn. That’s where the book Learning WordPress REST API comes into play.
It spans just over 200 pages written by fellow web developer Sufyan bin Uzayr. He has years of experience working on WordPress and writing about it online. So when I saw that he was the author I had a good feeling about this title.
With nine total chapters and many sub-chapters this book gets deep into REST and HTTP API requests along with CRUD management using the WordPress API. Here’s a breakdown of each chapter:
The intro starts off a little dull covering the basics of APIs and REST. I’m already well-versed in this stuff but a beginner would find this information valuable.
Introductory content ties everything together explaining how REST resources connect into WordPress and how data is transmitted(primarily JSON or XML). This intro carries on far too long while explaining REST implementation in many different programming languages like Ruby and Java.
But finally in chapter 2 we finally get to work in WordPress.
The author recommends using Postman as a tool for HTTP interactions. This does offer a free account and it might help newbies grasp the REST concepts a little easier. Intro examples cover PHP functions like wp_remote_get() and how WP functions can retrieve JSON content from the API.
By chapter 6 you’ll learn how to create an entire WordPress webapp from scratch. Updating older posts, creating new ones, and retrieving data for display on the frontend are all covered.
The final few chapters talk about WordPress API security tips and best practices. You’ll learn about the major differences between the v1 and v2 API release, plus the potential future benefits of WordPress’ API being merged with the core.
Overall the book feels a little light, but still covers all the necessary functionality for anyone brand new to the WordPress API.
I was able to confidently put all this code into action without trouble. I know the API is still in flux and constantly being improved. But the content in Learning WordPress REST API really helped me understand the absolute fundamentals of this API.
Everything is well documented and you can look up functions in the WordPress codex or the book’s index. This means you can do research and find answers to your own questions to keep moving through the book at a steady pace.
My biggest gripe is the hand-holding made for beginners. I fully understand why this was done; introductory content appeals to a wider audience of inexperienced developers.
But I just felt there was just too much introductory content, and too much veering off into topics that are more related general API development rather than WordPress API development. If you’re brand new to all of this you will definitely be able to keep up and follow along without trouble. If you’re more experienced then you’ll want to skip the first chapter.
One other complaint I have is with the code indentation. I was reading on the PDF so maybe it’s different in print, but some of the code snippets weren’t indented at all. This naturally makes it hard to read and more difficult to just copy/paste into a project.
Thankfully most of the code was split up into smaller blocks so there weren’t too many large non-indented code snippets. And strangely many of the snippets actually were indented, so it wasn’t even a book-wide issue.
Also some of the content organization seems strange. The later chapters covered most of the theory which I expected to find much earlier in the book. Chapter 8 is basically a rundown of the WordPress API in written words, but I would’ve expected that to be well before all the code examples & tutorials.
But regardless the book is still easy to get through and does cover the API in more depth than I was able to find elsewhere. Even with all these minor complaints I still think this is one of the most useful WordPress books I’ve ever read.
Also the index was pretty decent and provided enough of a directory to help me find specific functions & best practices without flicking through the whole book.
My overall impression of this book is overwhelmingly positive. I think Learning WordPress REST API will be a cornerstone for developers who want to pick up API development for WordPress projects.
I also think this will be a great title for experienced WordPress devs who know nothing of the API and want to get their hands dirty. The code is genuinely useful and the tutorials get into detail about things I didn’t know about like the register_rest_route() function.
If you’re a more advanced developer then you may be able to pick up these topics on your own. There is online documentation but I find the docs to be dry and hard to apply in real life. The details are right, but they lack direction for how to apply these features in a real WordPress site.
This is where Learning WordPress REST API really shines. It may walk you through at a beginner’s level and take a while to get going. But once you get into the meaty chapters with live examples you’ll learn a lot of practical techniques very quickly.