REST API for WordPress: what does it mean for you?

in WordPress

If you follow WordPress news, you’ve probably heard about the REST API already. We’ve been talking about it for years, and it’s been presented as a revolution within WordPress. That’s all great, but what does it mean in practice?

The REST API is a new way to interact with a WordPress site. You can use that API to consume content from the site, or create content using something that is not your regular WordPress dashboard. This opens the door to new apps, tools, and websites.

Up until now, there were 3 ways to use the REST API:

  1. You could use the only route available in WordPress Core, oEmbed, to embed WordPress posts.
  2. You could build on top of the Rest API infrastructure that’s already available in Core. Jetpack, for example, uses that infrastructure and creates its own custom endpoints used all over its new admin interface.
  3. You could rely on the REST API plugin to create default endpoints for you, and then build on top of those endpoints.

Starting in WordPress 4.7, WordPress will ship with its own default endpoints:

  • Posts, allowing you to get information about any Post Type on your site;
  • Comments
  • Terms
  • Users
  • Meta
  • Settings

Everyone is now able build on top of that API, add more data to the default endpoints, or even create your own endpoints. All of this without needing an extra plugin.

In practice, on a site like mine you now have many new ways to interact (view, create, edit) with the data on my site. Here is a list of the routes that are currently available on my site:


What can you do?

Want some examples? Here are a few things you could do with the REST API:

You can display a list of posts from any WordPress site on your own site with a plugin, like so:

[jeherve_post_embed wpapi="true" url="" tag="rest-api" include_images="true" include_content="false" include_excerpt="false" include_credits="false" image_size="200,150" number="10" headline="All my posts about the REST API on this blog"]

Error in the response. We cannot load blog data at this time.

You can build a React or a Vue.js app to display posts from a site:

You can build a theme that uses the REST API. Here are some tools that can help you. Even Twenty Sixteen can be done in React!

You can add data to the default endpoints, and use that data in your apps. For example, my Color Posts plugin adds information about the post’s average color to each post:

Color Posts adds data to the REST API Post endpoint.

Jetpack, for example, adds information about Related Posts:

Related Posts in the REST API Post endpoint

But that’s only the beginning! Many websites and services already use the WP REST API for different projects:

You get it: the sky is the limit (almost)!

Want to play with the REST API yourself? The documentation is available here.

  1. This seems great. Can’t wait to play around with it, but I’m still a noob.

    I’d like to create a Q&A thing on my blog using Jetpack’s Feedback feature. Do you have a real example that I could use to get me started? I really do not understand how to do that.

    I’m familiar with wp_insert_post etc but the rest? I’m clueless… You’ve helped me so much before so I look forward to anything of use. Read my forum post here:

    Thanks in advance!

  2. By default the feedback emails aren’t publicly accessible via the WP REST API. You can, however, access that information after authenticating, via the /wp-json/wp/v2/feedback route.

    To authenticate with the WP REST API, you can check this support doc.

    Once you can access the posts, you can display them using the language of your choice. You could for example use React or Vue.js, like in the examples I posted in my article.

Comments are closed.