This post is a high-level overview of the REST protocol used in many APIs.
What is REST?
Representation State Transfer (REST), as defined by Wikipedia, is the software architectural style of the World Wide Web that uses a coordinated set of constraints, applied to the design of components in a distributed hypermedia system, which can lead to a higher-performing and more maintainable software architecture.
In short, REST or RESTful API is the web standard that was created to make HTTP requests easier and more powerful.
What Makes REST So Great?
Before the REST architecture became a standard in the development community other Web Services were used to pass data between machines. These Web Services, such as RPC and SOAP, are still widely used, but more and more developers have taken up the REST architecture to make things simpler and easy to maintain.
This simple interface makes using REST a breeze, which in turn helps developers to create applications that leverage APIs in a shorter period of time. The core WordPress team knew this and decided that the WordPress API should be a RESTful API :)
Using Default HTTP Request Verbs
Within every single HTTP request there can be a verb that determines the action of that request. REST uses the four main HTTP Requests verbs:
These four verbs are used with every REST API call and are used to determine the action of the request. For example, if you call an API endpoint
/users/1 with a
GET action then the API might return a user with the ID of 1. On the other hand, if you send the exact same request to the same endpoint with the
DELETE action then it might delete the user with the ID of 1. As you can see a RESTful API can perform two completely different functions based solely on the HTTP Request verb specified.
This is where the power of using HTTP verbs can be shown because you are able to perform 4 actions per endpoint instead of having to change endpoints for each different action. Overall this makes understanding RESTful APIs much easier.
Where is it Used?
Most APIs that function via HTTP Requests use this RESTful architecture. It is very easy for developers to follow and understand how the API works, and notable companies that use this RESTful architecture are:
- WordPress :)
- and many more
With the RESTful architecture APIs are more maintainable, scalable, and easier to user for internal and external developers. Continue reading our next post about the WordPress API and what it means to the WordPress community.