The WordPress REST API will solve lots of problems and have more uses than we’ve even begun to explore just yet. But it’s no magic bullet and there will be times when you’re better off not using it at all.
There still isn’t a huge number of developers or agencies using the REST API for live sites, partly because the API is still under development and partly because it’s a new technology that people still need to learn and experiment with.
But there will be times – even once the API is well-established – when it really isn’t worth using.
In this post, I’m going to identify the circumstances and projects for which you might want to use the REST API, and those for which you won’t. I’ll cover this in three areas:
Platforms and technologies
Team and circumstances
Let’s start with platforms and technologies.
Platforms and Technologies
The WP-REST API is particularly useful when you want to link WordPress with APIs provided by other platforms, or you’re using it as the basis for an application written using a language other than PHP. There are some examples of real world sites already doing this.
Alternatively, if you want to take the data you’ve got stored in a WordPress database and use it to power another kind of app such as a mobile app, again the REST API makes it possible. So, for example, if you have an eCommerce site and you want to provide your customers with an app they can use to buy from you on their phones, the REST API could be used to link the two.
Plenty of WordPress sites currently interact with other APIs, displaying data provided by social media platforms such as Twitter or Facebook or providing maps on events sites by linking to Google Maps, for example. But this is a one-way relationship and the data from the external API is grabbed by your site and displayed there without interacting with your WordPress data. If you need your data to work harder, and if you want the data in your WordPress database to truly interact with data from another API, then the REST API is what you need to make this happen. If you just want to display data from outside WordPress you don’t need the REST API, but if you want interaction between the data from your site and the external source, then it’s a good idea to use the REST API.
A site that uses the REST API to link to an external API is technology new sites Wired, which uses it to send content to the Apple News app, converting posts created in their WordPress site to markdown and then outputting it using the Apple native format for its mobile app.
WordPress sites are currently built using PHP, with HTML and CSS added. If your site is built using a different language, or you have a site or app already created in another language which you want to link to WordPress, then the REST API will make that possible.
So if you’re working with external platforms and technologies, the REST API is probably the way to go. But there’s another way to look at it, which is according to the type of application you’re building. In other words, what your site or app is there to do (or for your visitors to do).
If you’re creating a simple blog, then you don’t need to concern yourself with the REST API. WordPress will continue to provide everything you need for blogging using PHP, either by installing third party themes and plugins or by building your own.
If your site is an eCommerce site, then you may or may not need the REST API. If all you need to do is use your site to sell goods or services from that one place, then the REST API won’t add anything. But there are a few circumstances when the REST API could make your store more powerful and help you reach out to a wider audience of buyers:
If your audience is using other sites such as eBay or Facebook for shopping, then the REST API could make it possible for you to link your online store to your store on those platforms. This way you can avoid duplicate stores, with associated efficiency when it comes to order management and stock-keeping. I’m not aware of any stores that do this yet (if you are, let me know in the comments below), but theoretically this could be an exciting use of the REST API.
If you want to customize or rebuild the admin interface for your users or clients, whether you need the REST API will depend on the degree of customization you need.
WordPress already provides lots of hooks you can use to drastically alter the admin interface, which is something I’ve done for clients, creating a completely new dashboard and custom admin screens.
However if you want to build an app-like admin interface, which is built from the ground up instead of being based on the existing admin screens, then you’ll need to use the REST API to do this.
Automattic’s Calypso admin platform has done this using the WordPress.com REST API, which is in the process of being merged with the REST API for self-hosted sites.
But a SPA like Calypso takes this further, giving users and app-like experience that’s quite different from a standard WordPress site. There’s no reason you couldn’t use WordPress and the REST API to power a SPA on the front end of your site.
If your site is highly reliant on geolocation, then the REST API will make it easier for you to link WordPress data with geographical data from external sources. A few years back a client asked my agency to create a mobile version of a site that served up different content dependent on the location of the person visiting the site: the client was a locksmith and they wanted to make it easy for customers to ring their local office. This is the kind of project I could imagine using the REST API for in future.
Team and Circumstances
Choosing which technologies to use for a web development project isn’t just about the technologies themselves; you also have to factor in the team, the client if there is one, and other circumstances surrounding the project. There will be some circumstances in which using the REST API is more appropriate than others.
The first set of circumstances to consider is the level of development of the REST API itself. Right now it isn’t as stable as you might want it to be for large, high-risk client projects.
It’s still under active development and the way it works is likely to change For example the form of the endpoints currently include the version number of the API, which doesn’t feel very sustainable to me.
If you’re working on a project that needs to be built quickly and/or with a minimal budget, I wouldn’t recommend using the REST API right now, unless you’ve already been using it and are familiar with it. Putting up a website in WordPress with a bespoke theme and a couple of custom plugins can be done in a matter of hours. I don’t know about you, but for me, building a site using the REST API would take significantly longer right now.
Conclusion: The REST API Works in Some Situations, Not in Others
The REST API is a great tool for use ins specific circumstances, but it won’t necessarily be the best approach for all projects.
This will change over time: as the API becomes more stable and the number of developers with experience using it grows (and also as more applications for it are explored), then the number of times when it’s an appropriate solution will increase, but I don’t believe that will ever represent 100% of WordPress website builds. So if you have no idea how to work with the REST API but want to stick with WordPress, don’t worry, you won’t be completely left behind.
Are you using the REST API? Are you thinking about using it for a project and aren’t sure whether to go ahead and do it? If you have a question about the REST API, ask away in the comment below.