Book Image

Learning WordPress REST API

By : Sufyan bin Uzayr, Mathew Rooney
Book Image

Learning WordPress REST API

By: Sufyan bin Uzayr, Mathew Rooney

Overview of this book

The WordPress REST API is a recent innovation that has the potential to unlock several new opportunities for WordPress developers. It can help you integrate with technologies outside of WordPress, as well as offer great flexibility when developing themes and plugins for WordPress. As such, the REST API can make developers’ lives easier. The book begins by covering the basics of the REST API and how it can be used along with WordPress. Learn how the REST API interacts with WordPress, allowing you to copy posts and modify post metadata. Move on to get an understanding of taxonomies and user roles are in WordPress and how to use them with the WordPress REST API. Next, find out how to edit and process forms with AJAX and how to create custom routes and functions. You will create a fully-functional single page web app using a WordPress site and the REST API. Lastly, you will see how to deal with the REST API in future versions and will use it to interact it with third-party services. By the end of the book, you will be able to work with the WordPress REST API to build web applications.
Table of Contents (16 chapters)
Learning WordPress REST API
About the Authors
About the Reviewer

Using REST API in real-world applications

REST API has become the talk of the town in the WordPress community only fairly recently. However, it has been around for quite a long while, and RESTful services are, in fact, as old as the Internet itself.

We are aware that the Internet is made up of different computers and servers, speaking different languages and running different services and processes. As such, a common protocol has been evolved to enable such different services and processes to communicate with each other. Such protocols can be described as a set of given standards that allow for Internet communication in a given manner.

Now, REST API, in itself, sits on top of such protocols, and enables us to facilitate communication between different services and machines and helps us interpret the data exchange that might be ongoing between two different services. There are many other such services that do the same job as REST, but with a difference of their own. For instance, JMS is a similar technique exclusive to Java applications, whereas XML-RPC is a capable, popular, but slightly dated and less secure methodology that can facilitate communication between services, much like REST.

Advantages of REST services

So, what makes REST better? In simplest of terms, REST helps in data exchange with a set of well-established mechanisms and protocols and focuses more on minimum workload, unlike many other similar methods that are heavier and bulkier in terms of operation. As such, REST focuses more on efficiency and speed and offers cross-platform data exchange. This is, by far, the biggest advantage of using RESTful services.

Now, as the Internet expands, so do the devices and technologies associated with it. With more and more mobile devices coming to the fore and coding standards being curated to adhere to specific norms, REST APIs too are evolving in order to meet purer standards of implementation. Thus, while the implementation of REST API remains more or less uniform, the modus operandi of RESTful services coded in different languages or platforms can have some minor differences. This is obvious to some extent because REST is an architectural style and not an architectural standard, and unlike HTML5, you cannot expect a W3C compliant guideline for REST API.

Now that we have covered the basic details about REST API and its major benefits, it is time to actually get started with REST in practice. In the next section, I will now talk a bit about how REST requests and responses work across different platforms and languages. Plus, the coming section will also be discussing the basic functioning of REST, including how simple and complex requests work. This, of course, is more of a practical consideration and less of a puritan one, and you can skip the coming section and move straight on to WordPress REST API if you want, but for the sake of information and for those who might be interested in learning more about REST API across different services and platforms, let us discuss REST properly before heading toward its relation with WordPress.