Saotn.org now provides the WordPress REST API (WP API), for you to use my posts to fill your website. How great is that?! :) But what is a REST API exactly, and what can I do with it?

The WordPress REST API is – currently – available as a plugin that allows applications to access the data produced by WordPress in JSON format. This opens up a whole new area for WordPress powered websites to share their contents, or incorperate content from others. Not to mention new possiblities in themes and plugins.

From the WP REST API website:

This plugin provides an easy to use REST API, available via HTTP. Grab your site’s data in simple JSON format, including users, posts, taxonomies and more. Retrieving or updating data is as simple as sending a HTTP request.

Want to get your site’s posts? Simply send a GET request to /wp-json/posts. Update user with ID 4? Send a POST request to /wp-json/users/4. Get all posts with the search term “awesome“? GET /wp-json/posts?filter[s]=awesome. It’s that easy.

WP API exposes a simple yet easy interface to WP Query, the posts API, post meta API, users API, revisions API and many more. Chances are, if you can do it with WordPress, WP API will let you do it.

WP API also includes an easy-to-use Javascript API based on Backbone models, allowing plugin and theme developers to get up and running without needing to know anything about the details of getting connected.

For update actions you need to be authenticated of course, so you only have read/GET access on my content. A PHP example:

<?php
$options  = array (
  'http' => 
  array (
    'ignore_errors' => true,
  ),
);
 
$context  = stream_context_create( $options );
$response = file_get_contents(
    'https://www.saotn.org/wp-json/posts?type=post',
    false,
    $context
);
$response = json_decode( $response );
?>

Or to grab a specific post ID (2037):

<?php
$options  = array (
  'http' => 
  array (
    'ignore_errors' => true,
  ),
);
 
$context  = stream_context_create( $options );
$response = file_get_contents(
    'https://www.saotn.org/wp-json/posts/2037',
    false,
    $context
);
$response = json_decode( $response );
?>

Developer resources can be found here: https://developer.wordpress.com/docs/api/.

This may interest you:   A plea for WordPress plugin developers to stop supporting legacy PHP versions

Various demo applications, plugins and articles are available for you to get more information and to build on. For example:

Have fun!
If you decide to let your app talk to my API URL I would appreciate a heads-up.