12REST API

CODE DOWNLOADS FOR THIS CHAPTER

The code downloads for this chapter are found at www.wiley.com/go/prowordpressdev2e on the Downloads tab.

It was June 2013 when the WordPress REST API project was first born as a plugin, and by 2015 it had been merged into WordPress Core, making it available to everyone without the need of a separate plugin. Since then, this API has been iterated on and improved, helping it become one of the most important things to understand for professional WordPress plugin development.

WHAT THE REST API IS

Representational State Transfer (REST) is a set of constraints that are useful for creating web services. These six fundamental constraints are as follows:

  • Uniform interface: The URLs used for access in the system need to be uniform, consistent, and accessible using a common approach such as GET.
  • Client‐server: Clients and servers may evolve separately without any dependency on each other as long as the interface between them is not altered.
  • Stateless: The server does not store anything about the latest HTTP request made by the client. Every request is treated as a new request.
  • Cacheable: All resources must be cacheable. Caching can be implemented on the server or client side.
  • Layered system: This system allows for a layered system ...

Get Professional WordPress Plugin Development, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.