DEV Community

CodeWithVed
CodeWithVed

Posted on

How would you consider your API to be Restful?

Before answering that question lets see what is REST API?
A REST API (also known as RESTful API) is an application programming interface that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. REST stands for Representational State Transfer and it was first introduced by Roy Fielding in the year 2000.

In REST API, the fundamental unit is a resource.
n order for an API to be considered RESTful, it has to conform to these architectural constraints:

  • Uniform Interface: There should be a uniform way of interacting with a given server.
  • Client-Server: A client-server architecture managed through HTTP.
  • Stateless: No client context shall be stored on the server between requests.
  • Cacheable: Every response should include whether the response is cacheable or not and for how much duration responses can be cached at the client-side.
  • Layered system: An application architecture needs to be composed of multiple layers.
  • Code on demand: Return executable code to support a part of your application. (optional)

Advantages of REST API

  • Simple and easy to understand.
  • Flexible and portable.
  • Good caching support.
  • Client and server are decoupled.

Disadvantages of REST API

  • Over-fetching of data.
  • Sometimes multiple round trips to the server are required.

Use cases:

REST APIs are pretty much used universally and are the default standard for designing APIs. Overall REST APIs are quite flexible and can fit almost all scenarios.

Top comments (0)