FUNDAMENTALS OF REST API

API

According to Wikipedia, API (Application Programming Interface) is a computing interface which defines interactions between multiple software intermediaries.

REST

REST (Representational State Transfer) is a software architectural style that defines a set of constraints to be used for creating web services. It is a convention for building the HTTP services exposed by the server.

REST API (RESTful API)

Is an API that employs the use of the set of software architectural principles defined by REST. RESTful APIs are resource based, where the key abstraction of information is a Resource. A resource is identified by URI or URIs. Resources are manipulated via standard HTTP methods (GET, POST, PUT, DELETE etc). Request are made by clients by calling services exposed by the server. The type of HTTP request determines the type of operation or action done on the data by the server. A response contains a status line, headers and the body. Data transferred are representation of resource(s) in a particular form. RESTful API involves 6 key constraints. These are:

Client - Server

This involves the separation of concerns (clients and servers). A client initiates a request and a server which listening responds to the request in oreder to supply access to its services.

Stateless

This involves interactions between components (clients, servers) to be stateless. Each request must contain all the information required to understand the request. A typical request contains an endpoint URL, HTTP method, HTTP headers and body data.

Cacheable

This requires that data within a response to a request be implicitly or explicitly labeled as cacheable or non-cacheable. This can make a response reuseable and improve user-perceived performance.

Uniform Interface

This involves implementation being decoupled from the services they provide and the transfer of information in a standardized form.

Layered System

This enables abstraction of the system’s complexity through architecture composed of multiple layers and substrate independence.

Code on Demand

It involves allowing client functionality to be extended by downloading executing code in some forms.

Benefits

Some of the key benefits of RESTful API includes: better performance, scalability, reliability, separation of representation and the resource