In the not too distant future, the WordPress core is going to incorporate a powerful new API that will open new doors for the platform to be part of the interactive web. Long time WordPress hacker, Ryan McCue is busily creating a JSON REST API that will pave the way for outside applications to be able to communicate more easily with WordPress.
A Quick Introduction to Ryan and JSON
Ryan first got involved contributing to the WordPress core about 6 years ago. Back in the day you could find him helping out in the #wordpress IRC channel and answering questions. This eventually led him to start making patches to core for issues. He’s now creating a JSON REST API for WordPress as part of his Google Summer of Code project.
You might be wondering, as I was, what in the world is a JSON REST API? As I’m not an engineer, I did not have the foggiest grasp of what this API can used for before chatting with Ryan over email. I asked him to school us in the basics and he obliged:
The project uses JSON as a format since basically every language can understand it, and it’s extremely easy to work with. The project additionally uses REST semantics, which is a way of building applications that make full use of the web and existing tools. The benefit of both of these is that any program which can access the web can use the API, leaving developers only the WordPress-specific code to write.
For comparison: the current mobile apps use the XML-RPC API, and up to 40% of their code is just to understand the XML properly, whereas JSON support is built-in to iOS and Android natively.
The JSON REST API Will Affect Everyone Who Works With WordPress
I asked Ryan how the JSON REST API will affect WordPress users and developers. It seems that while the API is not readily visible to users, they will experience the benefits of more interactive WordPress websites. Developers will also have an easier time creating this experience. He believes that it will impact everyone:
The JSON REST API is a simple but powerful way to interact with WordPress. Mobile, desktop and web applications can get data from WordPress and do anything you can do via the admin panel. It’s like the admin panel, minus the UI.
This project will affect everyone who works with WordPress. Mobile and desktop applications can move past restrictions on WordPress’ existing APIs and start working with WordPress in much deeper ways, while themes and plugins can become much more interactive. The availability of this as a core feature also means less time spent by developers creating something similar, and more time spent creating actual features.
In simple terms, for developers, this is going to be like upgrading all the old tools in your garage to be power tools, so you can focus on building. McCue calls it a whole new generation of tools:
As Matt noted in the recent State of the Word, WordPress is beginning to transition to a point where we’re building not just sites, but applications. Themes have taken us this far, but we’re moving to a web with much more user interactivity and we need a new generation of tools in WordPress to support these uses.
Practically speaking, what will the JSON REST API be used for?
I asked Ryan how he anticipates that developers will use the new API. He related a few practical use cases:
* The upcoming O2 theme by Automattic (intended as a replacement for P2) includes a similar API to power the live reloading, commenting, infinite scroll, frontend posting and other features. Once this plugin is in core, the O2 developers will be able to replace their custom code with this API (which I hear is a significant portion of their codebase)
* Mobile apps will be able to replace the clumsy XML-RPC-powered APIs with a much smaller set of tools for dealing with this API, enabling them to spend more time working on cool features and less time fixing issues
Overall this is going to be a giant step forward for developers who are having to try to create a similar API from scratch in an attempt to build interactive features.
JSON REST API Proposed for WordPress 3.8
McCue has proposed the API for 3.8, but the GSoC restrictions require that 100% of the code has to be written by him. These restrictions do not lend the project much collaboration at this point. Very soon the Summer of Code will conclude and McCue plans to form a team to work on the plugin and get it ready for
Although it may not be ready for WordPress 3.8 due to time constraints, McCue hopes to see it in the core in some form in one of the next few major releases. He’s very eager to get new contributors involved and would appreciate any feedback on the project.
Before talking with Ryan I was clueless about the importance of the project he’s working on but now I’m excited about the possibilities that the JSON REST API will open up for WordPress developers. Ryan’s work is currently housed within a plugin. If you’d like to test it and check it out, you can download it from github or wordpress.org. If you need help getting started, check out the docs Ryan has created or get in touch with him on Twitter.
This is fantastic. Having heavily extended the current WordPress XML-RPC API for Spokal’s WordPress integration, I can confirm that it is pretty archaic. Looking forward to having a modern API to work with!