CAll Us: +1 888-999-8231 Submit Ticket

The WordPress Rest API Will Be (Partially) Included In WordPress 4.4

StoryformIt’s been a long time coming, but with this commit it seems we’re nearing the end of a journey that will give WordPress an API appropriate to the modern Internet. If all goes well, I expect to see the partial API released along with WordPress 4.4. WordPress is hugely popular, but its lack of a decent API (XML-RPC doesn’t count) makes it the odd one out in an era in which creating an API for your application or service is de rigeur.

What Is The WordPress Rest API?

Before getting into the WordPress Rest API specifically, let’s have a look at what we mean by API. In a nutshell, an API — an Application Programming Interface — is a standardized way to communicate with a program, application, or service to get it to do something. In this sense, WordPress already has APIs — if it didn’t, plugin and theme developers wouldn’t be able to interface with it and WordPress Core’s developers wouldn’t be able to write code that makes WordPress do things. But these differ (in use and consequence if not in concept) from the Rest API.

The definition of an API is very broad — a programing language could be described as an API to its interpreter, but I want to focus on web service APIs.

A web service (or application) API is a way for one application to “talk to” another application over the Internet. It might need to tell the application something or ask the application something.

Let’s say a web service has a database with information about the weather in different parts of the world. Another application wants to know about today’s weather in Detroit, Michigan so it can make traffic predictions. The traffic application accesses that data from the weather application via an API. It sends a request in a predetermined format and the weather service responds with a chunk of data the traffic app can understand.

One of the major benefits of an API is that it is separated from the underlying logic and data storage of the application. That allows the API to remain stable while the rest of the application can be changed. So long as “tell me the weather in Detroit” always gives the expected answer in a format the traffic application understands, it doesn’t matter what the weather program is doing to generate the answer.

A REST API is an API architected according to specific rules. The details needn’t concern us, but the result in this case is an API for WordPress that can be accessed over HTTP, the standard protocol of the web. External applications can send an HTTP request (with appropriate authentication) that says, “send me the text of blog post X,” and WordPress will return a chunk of JSON data containing the post. JSON is a standard format for data storage and transfer. It goes both ways: an application can send a request with a chunk of JSON data and say,“publish this as a blog article”.

Why Is This A Big Deal?

The WordPress API is important for two main reasons, the second a consequence of the first.

Firstly, it allows applications to make request of a WordPress site in the way I described above. It allows developers to create applications that leverage the data stored in WordPress in any way they like. In case it’s not clear that this is especially exciting; it very definitely is. It completes the journey WordPress has been on as it developed from a blogging engine via a content management system to a full-fledged application platform that can be communicated with by any application that can make HTTP requests.

The second major consequence is that the WordPress back-end can be divorced from the front-end. Don’t like the WordPress admin interface? Fine, use a different app that provides the same functionality and communicates with the WordPress service via the API.

What it means to “use WordPress” will change because WordPress can be treated like a server — you will be able to interact with it via any compatible application or service. Even cooler, you won’t even have to use the WordPress front-end. If you loathe PHP you can write a JavaScript theme and front-end that leverages the API. Numerous big publishers, including the New York Times are investigating how they can use the REST API to integrate WordPress with their platforms.

The upshot of all this is that the REST API will make WordPress a more flexible powerful platform.

Try Out The WordPress REST API

If you want to give the API a spin, you have two choices: wait until the beta of 4.4 is available, or use the development plugin. Whichever route you take, keep in mind that the API is still under active development and it can’t be guaranteed to be stable enough for production use.

Source link

About the Author