Jeff Gould has written part two in his series on utilizing the WordPress REST API. Again, he delivers, as this is one of the most in-depth code heavy tutorials I’ve seen.
In part two, Jeff describes how to add fields to existing endpoints, and also how to create brand new endpoints for an application.
Another thing I gleaned from his post is that V2 of the API has its own subsite of documentation, that I somehow missed before. If you’re working with the API on new applications, you should definitely be using version 2, so that subsite will help.
He explains at the end what you gain from the post, and what you have to look forward to in part 3:
As you can see, WP-API makes adding custom fields and endpoints a relatively trivial task. Custom API endpoints often make much more sense than using admin-ajax and are a bit easier to deal with, in my opinion.
At the moment, our app isn’t much more than it was when you started reading this article, but there’s a lot of potential now that we’ve unlocked the power of custom routes. If WP-API makes it this easy to expose new data, then it’s probably just as easy to expose new ways to interact with our data. That’s an exciting prospect, and it’s exactly what we’ll be exploring next time!
I love these kinds of guides. I’d be really excited to see more working guides on built x, y, and z with the WordPress REST API. This kind of development is still pretty foreign for a lot of folks that came up through the WordPress ranks and not a traditional development path, so anything you’ve got experience with would be well received I’m sure, no matter how trivial it may seem to you.