WordPress WP-API Opens The Door To New Possibilities

   Raja Tamil • Jul 11 •


WP-API is a full-fledged application framework that allows us to create any application. There is no limit to the platform or the language. This opens the door to new possibilities!


If you have not had any experience with WordPress before, check out our Up and Running WordPress Website is Easy (Zero Code Required) post to get a basic idea.

What is Covered

1. Why we need WP-API along with descriptions of frequently used buzz words.

2. How to use WP API.


Why Do We Need WP-API?

Let’s assume I want to create and edit a post. Normally, I would login to access the WordPress Admin Panel, then I would create or edit my post. Initially, that was the only way to do that until WP-API arrived. You may be wondering how it works. Let assume another practical scenario, for example, that I want to create an iOS app that pulls all the blog posts from my WordPress website.   Additionally, I want to now add, edit or delete any of my posts from the app and have it automatically reflect on my WordPress site.  This is an example of how WP-API can be used. Nowadays, it is very common to have any web application created with an API (Application Programming Interface ) that extends the functionality and therefore reaching and providing additional services to more people.


WP-API is a RESTful (Representational State Transfer) API service that uses a simple HTTP Request (Hyper Text Transfer Protocol) in order to send or retrieve data  to/from the cloud or remote server in a JSON (Javascript Object Notation) format provided with a Route and an Endpoint.


Yes, there are a lot of buzz words you need to get familiar with in order to get the full picture of how WP-API works. The following buzz words are common to any API:


REST stands for Representational State Transfer which is a software architecture that uses GET, PUT, POST and DELETE keywords most often called end points to send or receive JSON data from or to the cloud server.


HTTP stands for Hyper Text Transfer Protocol that is sending and receiving information from a remote server.


JSON stands for JavaScript Object Notation which is used to send an object in key-value pairs for processing. JSON is typically used for asynchronous communication between your browser and server.


Endpoints are just API functions that are GET, POST, PUT, and  DELETE. For Example, they are the action you want to do when you send a request to the server.


Route is the name that is used to access Endpoint. Endpoints will vary based on routes that are determined by those who create the API.


Working With WP-API

If you do not know how to set up WordPress on your local machine, please check out my other blog How to Set Up a WordPress Site before reading further.


We need to install a plugin in order to work with WP-API as of the current date of creating this post.


Download the WP-API plugin to your computer. Then, go to the Plugin tab on your WordPress admin page. Click Add New and upload the downloaded zip file. Next, click Install and activate the WP-API plugin.


There are a lot of tools out there to test the API. I am using Postman Google Chrome Extension and I find it easy to work with. See the image below.


Screen Shot 2016-07-12 at 2.14.04 PM


I am going to show a few routes and endpoints and what you get in return.


Get All The Posts in a JSON Format

Example Route: https://localhost/wp-json/v2/posts
Example Endpoint: GET


This will bring all the posts in a JSON format. We could type this URL directly from the browser, however, browsers do not parse and format JSON data. You do not need to authenticate all the publicly available content, however, if you want to make any changes you would need to use authentication using Basic Auth or OAuth.


To Get a Specific Post

Example Route: https://localhost/wp-json/v2/posts/{postID}
Example Endpoints: GET, POST, PUT, DELETE


This will bring a specific post if you use the GET endpoint. You can also do other actions using different endpoints. This will work on WordPress pages, categories or tags too.


Once you have JSON Object, you can create any kind of application with it which could be a Mobile App, AngularJS App or any kind of application.



I am very excited to play around with WP-API and see what I can create with it. For more information about WP-API, check out their official website at https://v2.wp-api.org/.


Feel free to check out our online WordPress Courses course. Contact us for one FREE virtual online class from Anywhere.


Leave a comment if you have any questions or suggestions. If you like it, don’t forget to share it with your friends. Thanks for reading!



Sharing is caring!