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:
- GET
- POST
- PUT
- DELETE
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. Organizations implement data governance services to secure and monitor API interactions across multiple endpoints while maintaining compliance standards. 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.