WP REST API In Action

3 practical use cases for the WP REST API

WebsitesCategory
5 min read
Tom Ewer

While the WP REST API promises many possibilities, imagining its potential without concrete examples can be tough.

Fortunately, the plugin version of the REST API has been around for a while and some folks are already using it to great effect. As a consequence, we have live examples at our disposal that can help us better understand what this latest addition to WordPress will enable us to do.

To that end, this article will introduce you to use cases for the WP REST API in existing websites and applications, and make an educated guess as to what we can expect further down the line.

Let’s get cracking!

Use Case #1: Connecting WordPress to a JavaScript frontend

Currently, the most common application of the API is to power a JavaScript frontend with WordPress operating in the background. We happen to have a very prominent example for this particular use case.

The New York Times

NY Times Uses WP REST API

The New York Times is the second largest newspaper in the United States; it was an early adopter of WordPress and was among the first investors in Automattic, too. For those reasons, it should come as no surprise that they are also at the forefront WP REST API usage.

The New York Times is at the forefront of WP REST API usage.

WordPress serves as the backend for their live-blogging environment, with a custom-built, Backbone-based editor. Content created this way is served to a WordPress frontend that is rendered via React.js. According to NY Times developer Scott Taylor, this setup is “now the de facto platform for breaking news at The New York Times.”

For additional details and a lot more useful information, I recommend watching Taylor’s entire talk from WordCamp US 2015:


Other practical use cases

However, the Times is far from the only example for this use case. Here are a few more:

Nomadbase: A real-time map for digital nomads, with live location updates running on WordPress and a JavaScript frontend.

Fashion4Me: This PHP-based fashion directory for shopping centers is powered by React.js.

HumanMade: One of the biggest WordPress agencies is working on several client projects that involve connecting the WordPress admin to JavaScript frontends via the API.

Use Case #2: Building mobile apps with WordPress

As already mentioned in my REST API introductory article, mobile apps powered by WordPress and the new API are likely to become a big thing, and we are currently seeing the first wave hit the web.

StoryCorps

StoryCorps Uses WP REST API

StoryCorps is a service that enables anyone to create and share stories through their website and mobile applications. The site itself is built on WordPress and uses the API to sync data with mobile clients.

StoryCorps won the TED Prize 2015 and was featured on the home page of Google. As Matt Mullenweg said at last year’s WordCamp US:

“So, for those who are wondering if the REST API and WordPress can scale, only high enough to be linked from the home page of Google.”

You can find more detailed information about StoryCorps’ use of WordPress in this article. If you are interested in building your own WordPress- and API-based mobile app, check out AppPresser’s tutorial on the matter.

Use Case #3: Powering WordPress plugins

The API doesn’t always have to connect WordPress to external services — it can also streamline internal processes.

WP Live Search

WP Live Search Uses WP REST API

With WP Live Search we have one of the first plugins that utilizes the new WordPress API. It provides users with live search results while typing in queries into a WordPress website.

WP Live Search is based on Backbone.js and Underscore.js. It uses the API to move the search process to the client side, in order to make it faster and more lightweight than classic database queries.

While more of a working prototype at this moment, WP Tavern has already taken the plugin for a spin and found it to be quite functional.

Another example in this category is Ingot, a WordPress plugin that recently had its admin screen rebuilt with AngularJS and connected to the WordPress backend via the WP REST API.

Use Case #4: Making data available for external sites and apps

As we have seen in the quick start guide, the WordPress API is perfect for sharing data between different sites and apps. However, this doesn’t always have to be post data.

Event Espresso

Event Espresso Uses WP REST API

The WordPress event management plugin Event Espresso enables its users to provide event registration, management and ticketing to their clients. Last year they published a REST API add-on for their service, which is — unsurprisingly — built with the WP REST API.

The extension can feed event and attendee data directly into other applications. That way, it can be used by event calendars, external websites, mobile and JavaScript apps, as well as programs in other programming languages.

Future outlook

Without seeing real-life examples, the WP REST API can easily stay a theoretical concept with fuzzy areas of application. Fortunately, we already have use cases at hand to see it in action.

As is obvious from the above, at the moment the WP REST API is mainly being used to create JavaScript frontends and build mobile apps. Some people are also utilizing it to modify the WordPress backend or open their website data to third parties.

We are likely to see more of this in the future; however, there are also first examples of really creative applications. For example, Fusion is working on using its JSON data to improve site analytics and automatically add SEO features to Fusion content.

I’m excited to see more of these outside-the-box use cases and what else the future brings. What are you most excited about? Do you have concrete plans for using the WP REST API? Tell us your thoughts and plans in the comments below!