Blogs

MySAMi > News > What is REST API? > What is REST API?

SAMi

22 August 2022

Written By:
Ainara Vergara

What is REST API?

REST API

Representational State Transfer (REST) API is a set of rules that makes accessing web services simple and flexible. Any API that conforms to the design principle of REST is called a REST API. This architectural style was first defined by Roy Fielding in the year 2000 in his doctoral dissertation.

They are mostly referred to as RESTful APIs. They can be developed using any programming language and they can support a variety of data formats. This is unlike other protocols of API like SOAP or XML-RPC which have a strict framework. The flexibility this style offers is one major reason it is the most widely used API. 

 

Principle of REST APIs

Though they are known for their flexibility, REST APIs have a set of principles that the client needs to abide by before requesting access.

  1. Uniform Interface: REST API should make sure that the data that is being requested must belong to one uniform resource identifier. The consumers should have the same uniform representation to alter the resources state in the server. The resources should contain every piece of information that the client might need without being large in size.
  2. Client and Server: The application requesting the data i.e., the client, and the application possessing the data i.e., the server should be independent of each other. The interaction needs to be limited and the URI of the server is the only thing the client needs to know. In the same way, the server cannot modify the client’s application while transferring the request to the data source using HTTP.
  3. Cacheable: The responses from the server need to contain information about its cache-ability. If the response is cacheable the client can reuse the data multiple times for similar requirements and for a particular period of time. This is to improve the performance of the client and the scalability of the server.
  4. Stateless: This requires the client to provide complete information on the requested data for better understanding. The server cannot make use of previously given information as it cannot store any data for later use.
  5. Layered System: This protocol has different hierarchical layers to communicate within the loop. The client and the server do not interact with each other directly. The design of the layers is such that the client and the server cannot tell who they are communicating with. They could be exchanging information with the end application or an intermediary.
  6. Code on Demand:  The exchange of information between the client and the server happens in the form of static resources or executable code. The server sometimes sends a part of the requested information in an executable code that the client needs to download and execute. 

 

How does REST API work?

REST APIs have standardized functions; the acronym is called CRUD.

Creating

Reading

Updating

Deleting

These functions are performed by communicating via HTTP requests. An efficiently designed REST API is similar to a website running on a web browser. 

The data requested by the client is delivered by the server in many different languages, of which JASON is the most widely used one. This language can be read by both machines and humans. 

 

Wrap Up

Simply put REST APIs exchange data and information using Unified Resource Identifiers (URI). This protocol or architectural style is simple yet well defined which makes it easy to use for both clients and servers. This lightweight, fast, and simplicity of this protocol make it the most popular one.

Request A Demo