Explore the WordPress REST API with the New Interactive Console Plugin

wp-rest-api

WordPress REST API project lead Ryan McCue, in cooperation with Automattic’s Engineering team, released a REST API Console plugin on WordPress.org today. It’s a basic console that fits right into the WordPress admin and allows you to explore the API, make small changes, and find out what your site is exposing.

“This is a forked version of the WP.com console that myself and members of the Apollo team at Automattic worked on,” McCue told the Tavern. The console was converted in approximately four casual days, and McCue credits Beau Collins for this, as he originally wrote the majority of the console for developers working on WordPress.com.

“It’s pretty useful for exploring the API as a learning tool, but also for developers who are extending the API to get a sense of how their stuff fits in,” he said.

The REST API Console plugin requires the WP REST API plugin version 2.0 or later. You can find this on the GitHub project page and version 2 should be up on WordPress.org within the next day or two. Once you have both plugins installed, the console is visible in the admin under Tools > Rest API Console.

wp-rest-api-console-demo

You can actually make changes to your site using the console, so it’s advisable to install it on a local site and play with it there. While the GET requests can’t change anything, the other types can edit or delete posts (which would end up in your trash).

The plugin can only connect to the local site you’re currently on and cannot access remote WordPress sites. McCue recommends using something like Postman or Paw if you want to play around with remote sites.

In the future, he hopes to add more features and improve the plugin’s parameter documentation.

“The older WordPress.com console had the ability to click through to links, so I’d like to re-add that at some point,” he said. “The parameter documentation and tooling hasn’t been fleshed out yet, but the plan is to do it eventually – we’re working on exposing more from the API itself, too.”

If you want to tinker with the API but don’t have a local testing site handy, check out the live demo at demo.wp-api.org where you can click around to explore. This will save you the trouble of installing the plugin, if you just want to try it out. Also, you can’t perform any destructive changes there. Version 2 of the WP REST API plugin should be available on WordPress.org within 24-48 hours.

5

5 responses to “Explore the WordPress REST API with the New Interactive Console Plugin”

    • I would add that this decision by Ryan McCue is contrary to all previous statements. In those they had always said that this version would appear only as a core feature. The problem was that, without adoption by a lot of users, it would never be allowed into core. Develop first as a feature plugin is their preferred method, and WP REST API V2 was not not be a plugin.

      This decision was news to the WP-API team, for example Rachel Baker has tweeted her surprise, but I think it was the right decision to make. I am closely associated with a development team that has been sitting with idle hands, halfway through a project. The front end has been made, at least in module form, and the back end controls are ready, all we needed was the the API itself. Now we can go full steam ahead, knowing that we will find bugs, report them and see them fixed, by the API team or by ourselves, and we can give ourselves a timescale to full release by the release of WP4.4 in late December.

      Until now, the lack of a planned plugin has worried us. It would have delayed us by 6 months, and we would have been less confident of a stable API. By being able to develop with the new API, we can cut the development time by 6 months AND see it stable.

Newsletter

Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.