Green Files

What is REST and RESTful?

Day: 05/31/2022 - Time: 14:30:53

It only makes sense to know what REST is, as RESTful is just the ability to do REST, that is, it's a grammatical issue. Representational State Transfer (REST) ​​is an abstraction of the World Wide Web architecture, more precisely, it is an architectural style that consists of a coordinated set of architectural constraints applied to components, connectors and data elements. within a distributed hypermedia system.

REST ignores component implementation details and protocol syntax in order to focus on the roles of components, restrictions on their interaction with other components, and their interpretation of significant data elements.

It was officially defined by the W3C.

Source: Wikipedia (in English)

It is often applied to web services providing APIs for accessing any service on the web. It fully uses HTTP messages to communicate through what is already defined in the protocol without having to "invent" new protocols specific to that application.

You essentially work with components, connectors and data.

It uses the HTTP protocol (verbs, accept headers, HTTP status codes, Content-Type) in an explicit and representative way to communicate. URIs are used to expose the structure of the service. Uses common notation for data transfer such as XML or JSON. There is no state between these communications, that is, each communication is independent and uniform (standardized) needing to pass all the necessary information.

It should make it easy to cache content on the client.

It must have a clear definition of what is part of the client and the server. The client doesn't need to know how the server stores data, for example. So each implementation does not depend on the other and becomes more scalable. It allows for tiered usage also facilitating scalability, reliability and security.

It is often created with some form of extensibility.

Failing one of the first five items, the architecture cannot formally be classified as RESTful. But not everyone clings to formalism.

Exemple:

http://example.com/apagar/produto/1234

Means you are asking to delete product ID 1234.

Some say this is wrong and since the emphasis is on resources and not operations. Should use like this:

http://example.com/produto/1234 (using the DELETE verb)

Let's face it, this can work for CRUD, but there are so many variations of what needs to be done that it's not possible to represent everything with HTTP verbs alone. Okay, it's possible to make everything look like CRUD, but it might require additional information in the name of formalism.

All this is designed to provide better performance, scalability, simplicity, flexibility, visibility, portability and reliability.

Everyone defines their API as they want, unlike SOAP where everything is officially defined.

References:

https://pt.stackoverflow.com/questions/45783/o-que-%c3%a9-rest-e-restful

http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm

https://github.com/maniero/SOpt/blob/master/JavaScript/Conceptual.md

GO UP
GO TO INDEX