JSON REST API: Version 0.9

Hi everyone! I’m happy to announce that version 0.9 of the JSONJSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. REST APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/. is finally available.

Apologies for the extremely long delay here. I would have liked to ship OAuth authentication with 0.9, and the releaseRelease A release is the distribution of the final version of an application. A software release may be either public or private and generally constitutes the initial or new generation of a new or upgraded application. A release is preceded by the distribution of alpha and then beta versions of the software. was delayed due to that. However, it’s still not in a shippable state, and we’re well overdue for a release.

Important note: There are backwards compatibility breaks and deprecations in this release. These are all listed before, but exercise caution in upgrading. Backwards compatibility will be maintained from 1.0 onwards only.

Here’s the big changes:

  • Move from wp-json.php/ to wp-json/

    This breaks backwards compatibility and requires any clients to now use wp-json/, or preferably the new RSD/Link headers.

    (props @rmccue, @matrixik, #46, #96, #106)

  • Move filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. registration out of CPT constructor. CPT subclasses now require you to call $myobject->register_filters(), in order to move global state out of the constructor.

    This breaks backwards compatibility and requires any subclassing to now call $myobject->register_filters()

    (props @rmccue, @thenbrent, #42, #126)

  • Introduce Response/ResponseInterface

    Endpoints that need to set headers or response codes should now return a WP_JSON_Response rather than using the server methods. WP_JSON_ResponseInterface may also be used for more flexible use of the response methods.

    Deprecation warning: Calling WP_JSON_Server::header, WP_JSON_Server::link_header and WP_JSON_Server::query_navigation_headers is now deprecated. This will be removed in 1.0.

    (props @rmccue, #33)

  • Change all semiCamelCase names to underscore_case.

    Deprecation warning: Any calls to semiCamelCase methods require any subclassing to update method references. This will be removed in 1.0.

    (props @osiux, #36, #82)

  • Add multisitemultisite Used to describe a WordPress installation with a network of multiple blogs, grouped by sites. This installation type has shared users tables, and creates separate database tables for each blog (wp_posts becomes wp_0_posts). See also network, blog, site compatibility. If the pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party is networknetwork (versus site, blog) activated, the plugin is now activated once-per-site, so wp-json/ is always site-local.

    (props @rachelbaker, #48, #49)

  • Add RSD and Link headers for discovery

    (props @rmccue, #40)

  • WP_JSON_Posts->prepare_author() now verifies the $user object is set.

    (props @rachelbaker, #51, #54)

  • Added unit testing framework. Currently only a smaller number of tests, but we plan to increase this significantly as soon as possible.

    (props @tierra, @osiux, #65, #76, #84)

As always, you can view all changes on GitHub as well as view all closed tickets.

For those interested, here’s the list of contributors to this release:

$ git shortlog 0.8... --summary
     1  Aaron Jorbin
     1  Anders Lisspers
     6  Bryan Petty
     1  Dobrosław Żybort
     7  Eduardo Reveles
     1  K.Adam White
    10  Rachel Baker
    41  Ryan McCue
     2  Taylor Lovett

I’m still desperately seeking feedback on our OAuth implementation. This is a hugely important part of the APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways., and we need to get this nailed down as soon as possible.

General comments and posts are always welcome on our team o2.

#json-api, #rest-api