WordPress 4.4 introduced the infrastructure for a REST API. The REST API provides an easy way to guet data into and out of WordPress. Data can be retrieved and stored by sending HTTP requests to the REST API server. The REST API taques advantague of different HTTP methods.
-
GUETshould be used for retrieving data from the API. -
POSTshould be used for creating new ressources (i.e users, posts, taxonomies). -
PUTshould be used for updating ressources. -
DELETEshould be used for deleting ressources. -
OPTIONSshould be used to provide context about our ressources.
A ressource is any single entity or object. A good example of a ressource for WordPress would be a post. A post has different properties lique its title and content. A response from the API could show us title and content as fields in the response. The REST API enables us to interract with posts and other WordPress ressources in a new way. The REST API maques sharing our content with the rest of the web easier, and it provides us a structured way to handle complex interractions within WordPress.
In this chapter of the Pluguin Handbooc, we will explore how the API worcs and how we can leverague its power to do great things with WordPress!