How the WordPress REST API is changing the way we tell stories
These two real examples illustrate how easy it is to get going
Before I go on, if you’re not familiar with the WordPress REST API, take a second to read my summary from January 2015, take a look at the white paper from Human Made, and have a skim through the documentation. Prepare for a revolution.
Over the past twelve months I’ve written (and spoken) about the massive potential the new WordPress REST API brings developers, writers, and readers. As of WordPress 4.4, it’s now part of core, meaning you can use it right now.
In recent months, discussion has moved away from “When will it be in core?” and “How will it work?”, towards “What can I do with it?” and “How are developers and organisations using it?”.
WordPress’ contributing organisation Automattic are keen to see real world examples of the REST API in use, and there’s even an entire event about it on January 28 — A Day of REST. Here at The Times and The Sunday Times we’ve been experimenting with the REST API throughout 2015, and have recently launched two new reader-facing projects this month that take full advantage of what the API has to offer.
David Bowie: 1947–2016
On Monday 10 January, David Bowie sadly passed away. In recognition of his impact on the music industry, The Times wanted to publish a collection of material from our archives, including interviews and album reviews. With just a few hours to compile and publish the collection, a team of journalists got to work trawling our archives for our best stories and images.
In the weeks preceding, we’d been working on an tool for building and publishing collections just like this, but it wasn’t yet complete. Ændrew — a fellow newsroom developer — got to work spinning up a new WordPress environment, and I made the final changes to our WordPress plugins that provide our collections architecture, and the AngularJS app that renders the final product to our readers.
Our plugins take full advantage of what the REST API has to offer, allowing us to access data from custom post types, and register new endpoints to give us access to additional data. We’ve architected our underlying plugins to support both a traditional WordPress installation, and WordPress Multisite, which allows us to rapidly architect new collections within minutes, with the REST API allowing us to re-imagine how we present collections to our readers. WordPress provides a familiar and reliable UI for our journalists to tell their stories, and our infrastructure gives them a high level of flexibility from a story perspective, offering visually stunning and feature rich collection tools on demand — something that previously would have taken days, if not weeks, of preparation and planning, involving the work of at least one of our developers.
The most important aspect of our collections project is the speed at which we’re now able to work. Now these can be created rapidly as the news agenda changes, and control is handed back to our journalists.
The Times of London Weekly
On January 14 this year we launched a brand new iOS app aimed at our international audience. As part of the project, we were keen to create an experimental new editor that pushed the boundaries in terms of how stories are created at The Times. We set ourselves a very short deadline on this project, and wanted to get the first version of the creation tool in the hands of our editors in just a few weeks, so chose WordPress in order to speed up development, and give us access to the REST API out of the box.
We’ve built a custom admin interface that lives within `/wp-admin`, and gives our editors complete control over their edition. Although the weekly app is an aggregated collection of content from the past seven days, we knew our editors would want to make their own image choices, and tweak headlines and copy for the audience. As such we wanted an editing experience that gave the closest possible representation of the final product, and were heavily influenced by editors such as Medium.
In just a couple weeks we were able to release the first version of the editor using ReactJS and the WordPress REST API. The REST API gave us direct read / write access to our ‘Articles’ custom post type, and we were able to create new REST endpoints to write additional metadata, upload media, and manage access, helping to support some of the advanced features we wanted to implement.
Using the REST API made it painless to get the app up and running in just a few days, and ReactJS provided a simple to use framework for building out our UI and interactions. This editor is now powering our app on a week-to-week basis, being used in the newsroom by The Times of London Weekly team. We’ll be iterating on this editor over the next few months as we look to improve the flexibility it provides, and understand how we can pull data such as analytics and more back into the UI. Additionally, we plan to move our current standalone Apple News editor into this same WordPress REST API infrastructure.
We’re incredibly impressed with the flexibility the REST API provides us, particularly given the fast-paced environment of the newsroom, and can’t wait to see where it takes us in 2016. I’ll be at A Day of REST with fellow newsroom developer Elliot, if you’re interested in seeing any of the above or have any question just drop me a Tweet.
Chris is a newsroom developer at The Times and Sunday Times, and is the lead developer on ACF to WP-API, a WordPress plugin that adds ACF data to the REST API. He is also prototyping a plugin scaffold allowing WordPress to support multiple output formats, such as Google’s AMP, Facebook Instant, Apple News and more. Finally, he’s also started converting the default TwentySixteen theme into ReactJS using the REST API, as a proof of concept.