[wp-hackers] GSoC Proposal: JSON REST API

Ryan McCue lists at rotorised.com
Fri Apr 12 03:56:22 UTC 2013


Hey Bryan,

Bryan Petty wrote:
> All 4 main points you outlined and really great overall goals, and I
> agree on all counts.

Great to hear, thanks!

> I might also add that building off of #2 and #3, it's also important
> that the REST API offer a clean and simple internal API to extend it
> and offer additional REST routes for other functionality and
> information not just for additional core features (possibly even
> jumping into things on the admin side for managing menus for example),
> but also for plugins much like how the XML-RPC API can be easily
> extended by plugins.

Agreed.

What I'd absolutely love to do (and am part-way towards doing) is
separating the HTTP part of the API from the internal handlers.
Currently, no handler should need to access any of the superglobals nor
ever output anything, however headers are still handled in the handlers.

By ensuring a consistent API here, it means that e.g. a WooCommerce
endpoint could simply wrap around the existing method:

	function getProduct($id) {
		$data = WP_JSON_Server::getPost($id);
		$data->price = get_post_meta('_price', $id, true);
		return $data;
	}

> Additionally, since we've recently learned from our mistakes already
> in regards to this, it's important to make sure any new API that this
> project offers always consumes and delivers non-escaped, raw values
> (outside of JSON of course) where possible. Some available hooks and
> filters may make this difficult in many places. I haven't had time to
> fully review your proof-of-concept implementation yet to ensure it's
> following this guideline, but just wanted to make sure this was
> discussed.

Absolutely. There are indeed problems with this that will need to be
considered in depth to ensure that the API is always working with the
proper data.

> In regards to GSoC, this is definitely something that couldn't fit
> into the core release schedule, so I imagine an end goal for the GSoC
> deadline would be a usable (even if still alpha quality) plugin on
> WP.org. I know you know this already, but just re-iterating it for
> everyone else.

Yep, this would be tentatively slated for 3.9 or 4.0 at the earliest,
IMO. (I'd envision the process would be similar to Automattic Widgets'
integration.)

> Also, for GSoC, this is indeed something that additional people could
> help with during the program as long as the mentor(s) are only grading
> your code and performance, and that shouldn't be a problem. Although,
> while others can lend a hand in this, Google has been clear that two
> SoC students can not work on the same project. So we just can't have
> two students working on this at the same time (for any other students
> that thought this might be possible).

I spoke to Dion briefly about this, and he noted that it's probably best
that I'm responsible for the vast majority of it. This would probably
mean that I act as the project overseer with sole commit access, with
patches very welcome. This is more of a process thing though.

Thanks for the feedback!

-- 
Ryan McCue
<http://ryanmccue.info/>


More information about the wp-hackers mailing list