Categories
WordPress

REST API

REST API
An answer from the REST API. It’s a Json object, that was send to a Linux terminal via curl ( it’s a tool to transfer data from or to a server).

“WordPress 4.7 comes with REST API endpoints for posts, comments, terms, users, meta, and settings.” (Source: WordPress’ text about the API).

One of the great news in WordPress 4.7 is the REST API. Now it is possible to exchange data in the form of Json Objects.

Let’s try out the REST API in a simple terminal. In bash try this:

curl http://research-wordpress.dk/wp-json/wp/v2/categories

Perhaps the result above seems like gibberish to the uninitiated. But if we use a Json parser online, you’ll get a human readable result.

The Json object unfolded. You can see one category.
The Json object unfolded. You can see one category.

If you’re eyes are in top condition, you can see:

  • name: “Book Review”
  • description: “As a researcher I read a lot of books … etc.”

So a standard WordPress installation is able to exchange data between a behemoth of platforms, such as apps on mobile devices, and any kind of code that’s able to process Json, such as:

  • Ajax
  • Python
  • Bash
  • PHP
  • Ruby
  • Nodejs
  • etc.

The possibilities are virtually endless. REST API marks a huge step foreward.

Read more: REST API Reference.

By Per Thykjaer Jensen

Per is the WordPress expert at Business Academy Aarhus. Senior Lecturer at the Multimedia Design Programme. His background is in the Arts: MA Literature History and BA Art History. Later he added a MA in IT, interaction and Multimedia. And he is a wicked Linux user.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.