WordPress is a fast and highly effective platform for hosting a REST API for a variety of use cases, especially if your API endpoints serve content like images or filterable, categorized blocks of text. This step-by-step guide demonstrates how to implement a production-ready REST API in only a few hours, and with no custom coding required.


Why build a REST API with WordPress?” great question! Even though my own vanity and technology stack preferences tend towards, well, any other option besides WordPress, I nonetheless recognize that it is a pragmatic and robust solution for many use cases. A WordPress REST API implementation is best explained by way of example, and as it happens, I implemented a REST API for my ReactJS-based personal web site in mid-summer of 2020 and I’m quite satisfied with it in terms of usability, customizability, performance, reliability, cost, and maintainability. Incidentally, I’ve since come to realize that a WordPress-based REST API is also horizontally scalable, even more so than a typical WordPress web site.

The WordPress build itself is surprisingly simple. No custom PHP programming is required. You can refer to this blog article, “Step by Step Guide to Setup WordPress on Amazon EC2 (AWS) Linux Instance“, for step-by-step instructions on creating a basic WordPress site on Ubuntu Linux. Since version 5.0, WordPress includes a full-featured REST API with a complete set of endpoints for managing WordPress posts, pages and media. However, you can greatly enhance these built-in capabilities with a pair of free WordPress plugins: Advanced Custom Fields, (or Advanced Custom Fields PRO if you use an Avada Theme) and ACF to REST API. This in a nutshell is the basic installation that is needed in order to implement full-featured REST API basic entity-relationships, but in the interest of being thorough, following is the complete set of WordPress Plugins that I am using on the site.

You can inspect the following endpoints from my production REST API to get an idea of the breadth and sophistication that is achievable from a REST API implemented with nothing more than WordPress and these two plugins:

Why I Built My REST API With WordPress

Prior to deciding on WordPress I evaluated several alternatives including Django REST Framework, NodeJS, AWS API Gateway, and Ruby on Rails. Each of these alternatives are fine technologies, and in point of fact I do spend considerable time working with some of them. Importantly, WordPress offers excellent infrastructure for basic text and media content management simply by virtue of its maturity, expansive ecosystem and its rich catalogue of mostly-free plugins. As of Aug-2021 around 455 million web sites on the Internet were running on WordPress. This was a major consideration in my case due to the extensive use of still images on my personal web site as well as the simple structures of the site’s text content.

Conversely, the achilles’ heel with most of these alternatives regards their comparative shortcomings related to basic content management. Secondarily, I think all of these alternatives are comparatively more complicated to use for modeling a basic API endpoint. Thus, it would have taken me more time and effort to achieve, at best, the same end result with any of these competing alternatives. Lastly, and speaking from first-hand experience, managing any of these other technologies in a production environment where you need to consider data backups, scaling, security and code updates is more complicated and usually more maintenance intensive.

A more thorough, prioritized explanation of my selection criteria follows.