November 16, 2015
What is the WP-API?
What are RESTful APIs and JSON?
REST is an acronym for REpresentational State Transfer and describes the software architecture of the web. A RESTful application is typically one that uses standard HTTP verbs like GET, POST, PUT and DELETE to retrieve and send data from and to a remote server. RESTful applications use resources – essentially URIs to interface with external systems such as a remote server and use the 4 HTTP verbs to perform operations on the server.
API is an acronym for Application Programming Interface and is a set of routines, protocols and tools for building applications and interfaces.
RESTful API is an application programming interface that uses resource URIs to perform operations on a remote server through HTTP verbs. We can send a URI to the server, and get pure data back. In the WP-API, data comes back as JSON.
In Summary, The WP-API is a RESTful API for WordPress that returns data objects in the JSON format when provided with a route and an endpoint.
Understanding routes and endpoints.
Interacting with the WP-API is done through accessing routes and endpoints. The WP-API has a wide variety of routes and endpoints.
An Endpoint is a function available through the API in the form of HTTP verbs GET, POST, PUT, and DELETE. An endpoint performs a specific function by taking one or more parameters and returning the resulting data to the client.
A Route is the “name” we use to access the available endpoints. In simple terms, the route is the URL, and the endpoint is the action performed on the URL.
GET wp/v2/posts/1234 => Retrieves the data from post 1234 as an object
PUT wp/v2/posts/1234 => Updates the database entry for the object with the ID 1234
DELETE wp/v2/posts/1234 => Deletes the database entry for the object with the ID 1234
In the above example, GET, PUT and DELETE are the endpoints whereas wp/v2/posts/1234 is the route.
Information about the WP-API can be found at