This article on developing a WordPress REST API app was originally published by Torque Magazine, and is reproduced here with permission.
Excitement over the WordPress REST API has been building for what seems like an eternity, but we’re still pretty much at the starting gate in terms of what it’s actually going to mean for site owners and developers once it finally lands.
Though I’ve written extensively about the potential implications of the REST API, I’ve been holding back on actually diving in and getting my hands dirty to date. With the REST API finally taxiing on the runway, now seemed a great time to grasp that nettle and really start digging into detail.
A Brief Note on My Background
Though WordPress has long been a passion of mine, I’m a writer and entrepreneur by trade. I can’t pretend to be coming at this project from any type of serious development background. “Knows just about enough to be dangerous” would be how I’d charitably classify my coding experience to date.
So, this series won’t be quite the deep dive you might expect from a theming professional such as Jack Lenox, or a senior web developer such as Ramsay Lanier. It should also be no great surprise that I’m not approaching this from the point of view of an established top-tier digital agency looking to kick the tires of the latest technology.
Nope, this series will be much more along the lines of an average WordPress user looking to get to grips with the next generation of the platform via a practical, exploratory project.
Hopefully that’s an approach that will also resonate with a significant percentage of other site owners out there. Put it this way – if your eyes instantly start to glaze over at the introductions of other (admittedly excellent) tutorials such as the one below, this is the series for you:
In the following weeks, through a series of articles, I’ll explain how I’m using Node.js and Express on the backend with a GraphQL server hooked up to a MYSQL WordPress database that uses Apollo to fetch data and pipe it into React components. Don’t worry, I’ll still be using the tried and true WordPress admin interface.
With those caveats out of the way, let’s briefly recap why now is a great time to be really rolling up your sleeves and using the REST API in earnest.
Why Now Is the Time to Embrace the REST API
We’ve already seen entire conferences devoted to exploring the implications of the REST API, and increasingly large real-world projects basing themselves around it, despite its late arrival. From Microsoft to the New York Times, blue-chip companies worldwide are chomping at the bit to really explore its power.
If you’re a theme or plugin developer, you can rest assured that the vast majority of your competition are already, at the very least, actively researching the topic. If you’re a site owner, you can expect the next five years or more of your site’s development to be significantly defined by the possibilities that the REST API opens up. No matter what way you look at it, now is the time to get on board this particular train.
What We’ll Be Looking to Do in This Series
Along the way, we’ll touch on subjects such as alternative front end solutions, integration with mobile apps, design tips and tweaks, and experimenting with third-party APIs for added functionality. By the time we’re finished, you should have a much more grounded and practical view of what the REST API is actually all about.
We’ll be using WordPress 4.5.3 running on a local development environment, version 2 of the REST API as a plugin, React, and a whole lot of patience and persistence to put together our finished project. Stick along for the ride and you’re sure to pick up a ton of useful info along the way!
The tools to get cracking with the REST API already exist, it’s used in production by several major sites worldwide, and it won’t be long until it hits the mainstream WordPress world in earnest. There’s simply never been a better time to learn about it.
Learn PHP for free!
Make the leap into server-side programming with a comprehensive cover of PHP & MySQL.
RRP $11.95 Yours absolutely free
Aimed at a relatively non-technical audience, our series on developing a REST API app from scratch will take you from zero to hero in no time at all. You won’t need a computer science degree to follow along – just a little time, patience and perseverance.
Stay tuned for part two, in which we’ll fire up our local site, get some data into it, and start looking at basic reading and writing functionality via the REST API.
You can read the other articles in this series here.
Tom Ewer is the founder of Leaving Work Behind and WordCandy. He has been obsessed with WordPress since he first laid eyes on it, and has been writing educational and informative content for WordPress users since 2011. When he's not running his businesses, you're likely to find him outdoors somewhere – as far away from a screen as possible!
Your First Year in Code
Visual Studio Code: End-to-End Editing and Debugging Tools for Web Developers
Jump Start Git, 2nd Edition