Themergency

WordPress REST API

I love how all new major additions to WordPress core are being developed as plugins first, so that they can be tested and put through their paces. One of these plugins is WP-API, which gives your WordPress site a REST API. If you are unsure what REST is, then I suggest you read up on the topic first:

  • A Beginner’s Guide to HTTP and REST
  • What exactly is RESTful programming?

Make WordPress RESTful

To give this new feature a spin, this is what you need to do:

  1. Download the WP-API plugin and activate it on a local WP install.
  2. Make sure your permalinks are set to “post name”.
  3. Install the best API testing tool available : PostMan (this is a chrome extension).

Make Your First RESTful Request

Now that it is installed and running, open up Postman and do a GET request to:

Now this is only the tip of the iceberg, and you can do a whole lot more with the API. For more detailed documentation, check out:

  • The Getting Started guide.
  • Working with Posts - how to retrieve, save, update and delete posts via the API.
  • Extending the API - really interesting for plugin authors.