[wp-hackers] GSoC Proposal: JSON REST API

Ryan McCue lists at rotorised.com
Wed Apr 10 09:19:13 UTC 2013

Hi hackers,

There's at least a few of you out there who know me, but for those who 
don't: I'm Ryan McCue, a second year student at the University of 
Queensland, Australia. I'm currently studying Bachelors of Engineering 
(Electrical) and Science (Mathematics). Most of you will know me already 
via SimplePie, the feed parsing library included in WordPress, or my 
contributions to core.

For this year's GSoC, I'd like to propose a JSON API for WordPress. I've 
mentioned this project previously and have already outlaid part of the 
code to do this: https://gist.github.com/rmccue/5022591d312952d1245a

The scope of this project under GSoC would be the following:

 1. Develop the critical infrastructure to power a JSON-based REST API

    This is the most basic pieces of the REST API. This includes routing
    URLs to methods, handling JSON serialisation/unserialisation,
    ensuring compatibility with various servers/proxies, etc

 2. Create a REST interface for generic post types

    This involves creating a generic infrastructure to turn an internal
    representation of a post into exportable data (including
    normalisation) and vice versa.

 3. Building off the generic interface, create more specific interfaces
    for built-in types

    For example, posts should expose their comments in a nicer way,
    attachments should expose metadata relevant to their content, etc

 4. Ensuring that the API works well with clients

    Unless the API can work well with clients, it isn't of much use to
    anyone. This part of the project would involve creating new clients
    (for example, a Backbone-powered interface) as well as working with
    the mobile teams to gain support for the new API.

An important part of the project would be ensuring that a) all WP APIs 
can be expected to behave in a similar manner; and b) plugins can easily 
extend the API and create their own more specific APIs. To this extent, 
the project would also involve creating a proof-of-concept extension of 
the API for a specific plugin.

Why a REST API? At the moment, the only real API to access WP content is 
the XML-RPC API. This requires a full suite of parsing tools and is less 
than optimal for most users. In the past, XML parsing (usually with 
libxml) has caused problems on mobile platforms, which are the main 
consumers of the API. A JSON REST API removes much of this complexity by 
using a simpler serialisation format (JSON) with a protocol usable by 
most of the web via standard HTTP verbs.

Why am I qualified? I'm the lead developer of SimplePie, which is 
roughly 10% of the WP codebase, and is a fairly complex piece of 
software to maintain. I have previous experience with working with 
nuances of HTTP clients and servers, via my Requests project (a PHP HTTP 
client, similar to WP_Http). I've also already made a start on this due 
to personal interest, and although it has taken a back seat, I've 
already been able to create clients that use the primitive start I've 
created. I also have a fairly intimate knowledge of WordPress and have 
contributed many patches in the past.

I'd love for comments and questions on this.

Note on mentors: Marko has indicated previously that he'd like to work 
on such a project, and has also applied to be a mentor. While GSoC 
requires that students create most of the code, the project could be 
structured in such a way that we can work on separate parts of the API 
together. Brian Petty and Eric Mann have also indicated they'd like to 
mentor such a project, and both would be great choices as well.


Ryan McCue

More information about the wp-hackers mailing list