With what is expected to be the final release before work begins on integration into WordPress core, version 1.2 of the REST API development plugin has been announced. Like many new features planned for eventual inclusion into WordPress, the new API has been developed outside of the mainline of WordPress development, freeing its developers to experiment and make changes unhindered by being tied to the development goalsl and schedules of the core WordPress team.
But what exactly is the WordPress REST API, and why should you care about it?
An API (application programming interface) is a simple way to communicate with an application. Through a set of well-defined endpoints, developers can make their programs and scripts interact with the application.
We needn’t get too much into the details of what REST means, but in the case of WordPress the REST API provides a set of endpoints that can be accessed over HTTP, the protocol that underlies the web. In effect, it allows developers to control WordPress by visiting specifically crafted web addresses.
WordPress already has an API of sorts that uses the XMLRPC protocol. Unfortunately, XMLRPC can be extremely complex to deal with for developers, and it poses a number of security problems. The WordPress REST API is accessed over HTTP and returns data in the common JSON format — both are well understood by web developers, are easy to use, and all major programming languages have libraries that make it straightforward to write code that uses HTTP and JSON.
The creators of the REST API see a couple of major use cases. Firstly, the REST API will make it much easier to build applications that interact with WordPress. The obvious example is mobile applications. There are already a number of mobile and desktop applications that allow WordPress users to publish content and manage a WordPress blog, but they are complex to create and have limited functionality. The REST API will allow developers to more easily build applications that hook into a WordPress site’s data and functionality.
The second major use case is related but distinct. Many publishers want to use WordPress for content management, but build their own front end. Sites like Quartz and Wired are already using WordPress in this way. The new API will provide a standard, flexible interface for more easily creating this sort of integration.
From a WordPress user’s perspective, the REST API won’t be visible, but after it’s integrated it’s likely that developers will begin to create interesting products that will impact the WordPress ecosystem. Better mobile clients and integrations with existing tools are reason enough to be excited.
Hopefully, we’ll see the API integrated into WordPress core some time this year, but you can, of course, play with it now by installing the development plugin, although the usual caveats apply — it’s under heavy development and it probably shouldn’t be installed on a production server unless you really know what you’re doing.Posted in: WordPress