What is Rest API ?


  • An API, or Application Programming Interface , is a set of rules that define how applications or devices can connect to and communicate with each other.
  • It is a mechanism that enables an application or service to access a resource within another application or service.
  • The application or service accessing the resource is called the client, and the application or service containing the resource is called the server.


A REST API is an API that conforms to the design principles of the REST, or Representational State Transfer architectural style. For this reason, REST APIs are sometimes referred to RESTful APIs. REST APIs provides a flexible, lightweight way to integrate applications, and have emerged as the most common method for connecting components in microservices architectures.

REST APIs can be developed using virtually any programming language and support a variety of data formats. The only requirement is that they align to the following six REST design principles - also known as architectural constraints :

  • Uniform interface :

    All API requests for the same resource should look the same, no matter where the request comes from.Resources shouldn’t be too large but should contain every piece of information that the client might need.

  • Client-server decoupling :

    In REST API design, client and server applications must be completely independent of each other. The only information the client application should know is the URI of the requested resource

  • Statelessness :

    REST APIs are stateless, meaning that each request needs to include all the information necessary for processing it. In other words, REST APIs do not require any server-side sessions. Server applications aren’t allowed to store any data related to a client request.

  • Cacheability :

    When possible, resources should be cacheable on the client or server side.The goal is to improve performance on the client side, while increasing scalability on the server side.

  • Layered system architecture :

    In REST APIs, the calls and responses go through different layers. As a rule of thumb, don’t assume that the client and server applications connect directly to each other.

  • Code on demand (optional) :

    REST APIs usually send static resources, but in certain cases, responses can also contain executable code (such as Java applets). In these cases, the code should only run on-demand.

How REST APIs work :

REST APIs communicate via HTTP requests to perform any function on database like creating, reading, updating, and deleting records (also known as CRUD) within a resource. For example, a REST API would use a GET request to retrieve a record, a POST request to create one, a PUT request to update a record, and a DELETE request to delete one. All HTTP methods can be used in API calls. A well-designed REST API is similar to a website running in a web browser with built-in HTTP functionality.

Request headers and parameters are important in REST API calls because they include important identifier information such as metadata, authorizations, uniform resource identifiers (URIs), caching, cookies and more. Request headers and response headers, along with conventional HTTP status codes, are used within well-designed REST APIs.