REST APIs

A while ago, I introduced the concept of API in the information technology industry. In addition, there are 3 different types of Web Services APIs which are REST APIs, SOAP APIs, and RPC APIs. Among them, REST APIs is no doubt the most popular API currently. REST APIs, also known as RESTful APIs, stands for Representational State Transfer. It is based on four different HTTP commands which are GET, PUT, POST, and DELETE.

When a client request is made via a RESTful API, it transfers a representation of the state of the resource to the endpoint. Then the information is delivered in one of several formats via HTTP: JSON (Javascript Object Notation), HTML, XLT, Python, PHP, or plain text. JSON is the most generally popular due to its readability.

According to the RESTful API website, a service interface needs to apply these 6 guiding principles and constraints to be referred to as RESTful:

1. Uniform Interface

Multiple architectural constraints applying to the interface so that information is transferred in a standard form requiring:

Identification resources – resources requested are identifiable and unique from the representations sent to the client

Manipulation of resources through representations – clients can manipulate the resources via the representation

Self-descriptive messages – each resource representation should carry enough information that the client can manipulate.

Hypermedia as the engine of application state – after accessing a resource, the client should be able to use hyperlinks to find all other currently available actions.

2. Client – server

It is the architecture made up of clients, servers, and resources, with requests managed through HTTP.

3. Stateless

Statelessness means that no client information is stored between each request and that the server cannot take advantage of previously stored context information.

4. Cacheable

There are cacheable and non-cacheable responses. If the response is cacheable, the client can reuse the response data for later use.

5. Layered system

A layered system allows an architecture to be composed of hierarchical layers by constraining component behavior.

6. Code on demand (optional)

It is the ability to send executable code from the server to the client when requested, extending client functionality.

Although REST API has these criteria to conform to, it is still considered easier to use than SOAP (Simple Object Access Protocol). The reason is that while REST is a set of guidelines which is simple to implement and faster in response time, SOAP has specific requirements like XML messaging, and built-in security and transaction compliance that make it slower and heavier.

Overall, the point of this blog is to introduce you to REST API, REST is just a term indicating the constraints applying to the API. In order to understand the power of REST, I would suggest going to create one and see how simple and convenient it is.

Leave a comment

Design a site like this with WordPress.com
Get started