A Day of REST with the Wordpress Community

Eduardo Romero
9 min readMar 14, 2017

--

A Day of REST boston #feelingRESTful

I just got back from A day of REST Boston. And let me tell you, I got back All pumped up about it. It was an amazing couple of days in the beautiful city of Boston surrounded by very talented people.

The thing that I liked the most about the event was the community. All presenters and attendees made clear that everybody should look to contribute to the Wordpress REST API and the ecosystem of projects around it.

The REST API is young. Added to the core in 4.7. The projects around it are also young and consolidating:

The possibilities are now endless. I came back from the conference seeing Wordpress as another Microservice in our tool belt that can be used to build more interesting things.

Wordpress has a vibrant, inviting, open, thriving community. They know that making Wordpress better makes the whole community better, and they’re opening Wordpress to the world.

Here are my notes and links to the slides:

Diving into the WP REST API by Joe Hoyle

Joe Hoyle from Human Made (via Instagram)

Joe Hoyle from Human Made started the talks. This talk is an excellent introduction to the Wordpress REST API. Joe starts with the most common endpoints, then talks about HAL/HATEOAS, the schema and the REST flow (and how to register a new Resource for your plugins, taxonomies, etc.) then Joe goes into the JavaScript clients for the API.

One of the highlights of the conference: The lead developers of all client libraries were at the conference 🎉

The talk has some real insight on all different Authentication methods that you can use to consume the REST API (depending on your intended use case). Joe gave a wonderful workshop on the subject.

API Tales of “Woe” and “Woah!” by Phil Sturgeon

Phil Sturgeon from WeWork (via Facebook).

Phil works at WeWork (Big co-working space brand). His chat was fun and enlightening. Mostly geared towards building decent APIs. Some of the things he pointed out were:

  • Don’t do slow stuff on the API. Defer long running tasks to a Job Queue. Try implementing things asynchronously, hook-based or even long-polling.
  • Whenever you do Async, make sure it is faster than your sync code.
  • Pagination is always a MUST. It can become a DDoS from your clients, don’t shoot yourself in the foot.
  • Limit what can be ?include/_embed on API requests.
  • Remember to use UUIDs instead of numeric IDs. That will make it hard for crawlers to get your whole content.
  • Make API errors understandable and easy to fix. Maybe even link to the documentation.
  • Retry failures, except 403/429 and try adding Retry-After to throttle requests.
  • Expect the worst from everyone (empty response, the response is not JSON, etc).

He’s also the author of Build APIs that you won’t hate, so definitely take a look at that.

Backbone ❤️ Wordpress REST API by Adam Silverstein

Adam Silverstein from 10Up — On the wp-api client.

Adam is Lead Web Engineer at 10up. He’s the guy behind the Backbone client for the WP API. The library already ships with Wordpress, just need to enqueue the script (wp-api) to use it.

It’s easy to use and is perfect for any front-side development, Especially a good fit for working with WP Plugins or Admin Panels.

He made some great points:

  • Wordpress and Backbone go way back (2012)
  • wp-api is good for Admin features, interactive features, data display/manipulation and extending core functionality.
  • Has already Models and Collections baked in. Because it’s using the WP REST API Schema it will get all the customized resources that you create and expose thru the API.

He showed me, in like five minutes, that you can use the same client to connect to different Wordpress instances. One could do some really impressive magic easily with it.

Reacting to Wordpress by Kelly Dwan

Kelly Dawn from Automattic on React + WP (via Facebook)

Kelly works at Automattic, and she walked us thru basic concepts of React and how we can use it to interact with the REST API. She also introduced things related to React development like Redux and Babel.

Some key things she mentioned:

  • Redux makes apps easy to test.
  • JetPack uses React for the Admin UI. Also talked about Calypso the React app that powers Wordpress.com and its desktop/mobile app.
  • React community is big on testing and linting.
  • She’s working on a beautiful React-based theme for Wordpress (geared towards blogging). Makes WP feel like a Single-Page App.
How the theme looks on the left. The request from where the page is built is shown on the right.
  • WMAU is using React. Notice how the player stays at the bottom of the page, and the music plays independently of navigating on different content.
WAMU.org React front-end. On the right, the JSON response on that is used to build the page.
  • She shared a slide on the architecture of USTwo.com. A React Isomorphic SPA, Wordpress API as backend and some magic in-between (S3 + CDN, Node for SSR then app gets hydrated on the client-side).
The Architecture of UsTwo.com Isomorphic React App.

10 ReST API use cases in 10 mins by John Eckman

John Eckman from 10Up — 10 REST API Use Cases in 10 mins. (via Twitter)

John Eckman is the CEO at 10up. He walked us thru different scenarios that are perfect for Wordpress REST API. I found myself nodding each time he described a use case because they matched the ideas I have for Wordpress as a microservice in our architecture.

Please go thru each slide ;) I have notes on every slide, but there’s no point in going thru the full list here. A MUST READ for all things related to Wordpress as the backend for content.

Who is JSON and Why do I care how much REST he gets?! Awesome ;)

There are two very enlightening architecture diagrams on slides seven and eight. Take a good look at those for ideas. Again, this is a superb high-level glance at WordPress as a “Content as a Service” platform.

A Design Perspective on the REST API by Mel Choyce

Mel Choyce Product Designer at Automattic — Talking from a Designer’s Point of View (via Facebook)

Mel Choyce is a Product Designer at Automattic. Mel approached the REST API possibilities from a whole different point of view — The things you can do when you detach Wordpress and the front-end.

She spoke from her perspective as Designer and how designers now have a whole new game at the front-end, without any of WPs restrictions.

  • You are not locked into blog-like sites anymore.
  • She mentioned how it’s now rather easy to implement “continuous reading” like the one that Quartz has. Think infinite scrolling for full articles and related content.
  • New areas of design to explore like Mobile (or Bots! 🤖) and there are no experts yet in this new space. It’s a new ballgame, and us (engineers) will work hand-to-hand with UXers and Designers to put together great new experiences.

She closed with one of the best quotes from the (un)conference:

When wordpress does well, we all do well.

That, by the way, synthesizes the whole feeling I get from hanging out with Wordpress contributors. They all truly want the community to thrive.

Great expectations by Petya Raykovska

Petya Raykovska Senior PjM @ Human Made — Talking about managing new expectations

Petya Raykovska is Senior Project Manager at Human Made. She was part of the team organizing the event. Petya’s talk was a fabulous complement of Mel’s as they both spoke from a different perspective (not Engineering focused).

With the hype behind the REST API and front-end/back-end decoupling, we need to re-introduce our clients, PjM’s, PO’s, other stakeholders and non-dev team members to Wordpress REST API Projects and manage their expectations.

  • We need to make sure everybody knows than on a decoupled implementation some of the Core functionality will not be present.
  • Previewing content might not be available, drafting and pre-publishing might not work as people expect.
  • Make sure you talk with clients up front whatever functionality is not available. You will need to replicate it, and that will add up to the cost (time and money).

Feel free to read the post linked above and the video of a related talk for WorldCamp US 2016.

John, Mel, and Petya were part of a panel. They made obvious to me that the reach of Wordpress vast. Being used by huge names in the Media industry.

The core value of Wordpress comes from people interacting and creating content. Either creating the content by hand or sourcing it from third parties and then doing the editorial process on Wordpress.

With the Content decoupled from the Presentation layer, there are new issues that will surface. Like how the different platforms consume and display that content (i.e. Mobile vs. App vs. Paper). That translates to new opportunities for us all.

Real Time REST APIs by Rachel Baker

Rachel Baker Director of Engineering at the Wirecutter (now NYT) — On Web hooks, Rest hooks and WP Actions

Rachel Baker is Director of Engineering at the Wirecutter (now part of the NYT family). She’s core contributor and led the merging of the REST API to the WP Core on 4.7 (So, Thank You!).

Hers was one of my favorite talks. I was so thrilled to hear about a real-time / events API for Wordpress. It fits my microservice-oriented mindset like a glove.

Having an events API baked into Wordpress means pushing data out as a response to an event on WP. Pure Genius.

  • Things like Updating headless front-ends when content changes (cache-invalidation)
  • Notifying a microservice of a content event (content is awaiting moderation, notifications to a slack-bot, updates a trello board, etc.).

Immediately I was thinking we could build a Microservice that has all the registered wordpress actions as events, and then dispatches and distributes those events to other clients that subscribe to it.

Wordpress Actions + Webhooks + REST Hooks = #winning 🎂

Then she talked about some gotchas:

  • Error handling, optionally with retries.
  • Not inlining the calls, but Queueing instead (like we should 😉).
  • Impact on payload size.
  • Security / Authentication
  • And having a new RPC/API/Microservice to maintain.

These are the same things that we’ve experienced when working with Microservices in Wizeline’s Bots platform.

API Client Design by K. Adam White

K. Adam White Open Web Engineer at Bocoup — About Good API Design by example ;)

K.Adam White from Bocoup (our hosts for the workshops) talk was about APIs in the general sense, not exclusively about the WP API. Adam built the NodeJS (Isomorphic) client for the Wordpress API.

He started with an excellent Quote:

Understanding how a tool works helps you use better.

The highlights to me were:

  • Wordpress is evolving into an application framework.
  • Scope creep is bad. Scope creep that makes you build a CMS is impossible.
  • In Bocoup is a common thing to release projects that are useful for the community as Open Source — A mindset that matched most of other companies at the event.
  • K.Adam built the NodeJS WP API client itself. Is beautiful and should be an awesome resource about to study when designing APIs.
  • He built the client as a Query/Transport utility. It creates the objects by reading the WP API Schema and then constructing them. It has access to all your custom types/posts/etc. It has auto-discovery, so it finds all routes you might have added thru plugins.
  • One could take his implementation as a guideline when implementing an API Client in any other language.

He pointed out that the Wordpress core contributors always try to lower the barrier to entry for new developers.

“Difficult readability of code means that you fear to change it or that you will need to rewrite it in the future.”

They aim to build tools that are scalable (in a developer sense) by making sure they are easy for others to learn and are helpful to the entire community.

All in all, it was a great conference from a great community. It made me want to become a contributor. Hope to write a post about that soon.

--

--

Eduardo Romero

Building software and high-performing teams at scale. Most recently, I built the platform that lets gamers play instantly on Luna, Amazon's Gaming in the cloud.