An absolute beginners guide to the WordPress REST API

Tonight I gave a presentation at the Tunbridge Wells WordPress Meetup about the WordPress REST API. I called it an “absolute beginners guide” because before looking at it for the presentation I had never looked at it previously, so I was an “absolute beginner” with it.

The WordPress REST API was included in the WordPress core in version 4.7, meaning the WordPress development team consider it complete and stable and ready for production use. 

Here is the slidedeck from the presentation:

Slide Notes

Slide 2

  • Been using WordPress for around 6 months.
  • I never used the WordPress REST API.
  • Do however have 17+ years of development experience.

Slide 3

  • The WordPress REST API was added to core in version 4.7.
  • Previously available as a plugin, but now considered complete and stable.

Slide 4

  • Full documentation available at

Slide 5

  • Requests to the REST API go to URLs under this location.

Slide 6

Slide 7

  • You can add additional parameters to filter the responses.

Slide 8

  • Get posts with the terms “awesome” in them.
  • Limit to pages and posts per page.

Slide 9

  • This will get just one post using the Post ID.

Slide 10

  • To make other types of requests, e.g. create posts, delete posts, etc…you need to be authenticated.
  • There are three types of authentication available:
    • Cookie – Used for plugin and theme developers, as you need to have a logged in user.
    • OAuth – Used by external applications
    • Password – Strongly discourage for production use, but can be useful in developments (and demos)
  • OAuth and Password require an additional plugin

Slide 11

  • An HTTP POST request to the same address will create a new post, but you have to be authenticated and pass the correct post fields.

Slide 12

  • An HTTP POST request with a Post ID specified will update the existing post with the data that is passed.

Slide 13

  • A DELETE HTTP request with a Post ID specified will delete the post.
  • Optionally you can specify “force=true” to delete the post completely and not just move it to the bin.

Slide 14

  • Via the REST API you can do pretty much anything you can do via the normal WP Admin.

Slide 15

  • Plugins can extend the REST API and add data to it or additional endpoints so you can access their data and functions.

Slide 16

  • There are many use cases, but this brings WordPress into the realm of a fully fledged enterprise level Content Management System.

Leave a Reply

Your email address will not be published. Required fields are marked *