[go: up one dir, main page]

0% found this document useful (0 votes)
23 views18 pages

Rest Architecture

REST, or REpresentational State Transfer, is an architectural style for distributed hypermedia systems that utilizes a stateless, client-server, cacheable communication protocol, primarily HTTP. It emphasizes a uniform interface, separation of concerns, and resource manipulation through standard HTTP methods. RESTful APIs are lightweight, simple to develop, scalable, and align closely with web architecture, making them widely adopted for web services.

Uploaded by

pranavmisra191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views18 pages

Rest Architecture

REST, or REpresentational State Transfer, is an architectural style for distributed hypermedia systems that utilizes a stateless, client-server, cacheable communication protocol, primarily HTTP. It emphasizes a uniform interface, separation of concerns, and resource manipulation through standard HTTP methods. RESTful APIs are lightweight, simple to develop, scalable, and align closely with web architecture, making them widely adopted for web services.

Uploaded by

pranavmisra191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

REST

Architecture
Introduction......
REST:
Roy Fielding (2000)

• REST is an acronym
for REpresentational State Tr
ansfer and an architectural style
for distributed hypermedia
systems.
• REST is not a protocol or a
standard, it is an architectural
style.
• It relies on a stateless, client-
server, cacheable
communications protocol — and
in virtually all cases, the HTTP
protocol is used.
• REST is an architecture
style for designing
networked applications.
The idea is that, rather than
using complex mechanisms
such as CORBA, RPC or
SOAP to connect between
machines, simple HTTP is
used to make calls between
machines.
REST API

• A Web API (or Web Service)


conforming to the REST
architectural style is called
a REST API (or RESTful API).
The Six Guiding Principles of REST
1.Uniform Interface
• REST defines a consistent and uniform interface for interactions between
clients and servers.
• Example :: HTTP-based REST APIs make use of the standard HTTP methods
(GET, POST, PUT, DELETE, etc.) and
• URIs (Uniform Resource Identifiers) to identify resources.
• The Uniform interface is achieving these four constraints:
• Identification of resources.
• Manipulation of resources through representations.
• Self-descriptive messages.
• Hypermedia as the engine of application state:
• The client should have only initial URI of the application, dynamically
drive all other resources and interactions with the use of hyperlinks.
2.Client-Server

• The client-server design pattern enforces the separation


of concerns, which helps the client and the server
components evolve independently.
• By separating the user interface concerns (client) from the
data storage concerns (server), we improve the portability
of the user interface across multiple platforms and
improve scalability by simplifying the server components.
3. Stateless

Statelessness
mandates that each The server
request from the client cannot take
to the server must advantage of
contain all of the any previously
information necessary stored context
to understand and information on
complete the request. the server.
4. Cacheable

If the response is
The cacheable
cacheable, the client
constraint requires that
application gets the
a response should
right to reuse the
implicitly or explicitly
response data later for
label itself as cacheable
equivalent requests and
or non-cacheable.
a specified period.
5. Layered System

The layered system style


allows an architecture to be A layman’s example of a
composed of hierarchical layered system is the MVC
layers by constraining pattern. The MVC pattern
component behavior. In a allows for a clear separation
layered system, each of concerns, making it easier
component cannot see to develop, maintain, and
beyond the immediate layer scale the application.
they are interacting with.
6. Code on Demand
(Optional)

• REST also allows client functionality


to extend by downloading and
executing code in the form of applets
or scripts.
What is a Resource?

For example, a REST


resource can be a
The key abstraction of
document or image, a
information in REST is
temporal service, a
a resource. Any
collection of other
information that we can
resources, or a non-
name can be a resource.
virtual object (e.g., a
person).
The state of the resource, at any particular time, is
known as the resource representation. The resource
representations consist of:

THE DATA THE METADATA DESCRIBING AND THE HYPERMEDIA


THE DATA LINKS THAT CAN HELP THE
CLIENTS TRANSITION TO THE
NEXT DESIRED STATE.

A REST API consists of an assembly of interlinked resources. This set of


resources is known as the REST API’s resource model.
More About Resource:
Resource Identifiers : REST uses resource identifiers to
identify each resource involved in the interactions between the
client and the server components.

Hypermedia: The data format of a representation is known as a


media type. The media type identifies a specification that defines
how a representation is to be processed.

Self-Descriptive:resource representations shall be self-


descriptive: the client does not need to know if a resource is an
employee or a device. It should act based on the media type
associated with the resource.
Resource Methods

Another important thing


associated with REST
If we are using REST with
is resource methods.
HTTP protocol than
These resource methods
resource methods(HTTP
are used to perform the
methods) (i.e.,
desired transition
GET/PUT/POST/DELETE)
between two states of
any resource.
Example

"id": 123,
"title": "What is REST",
"content": "REST is an architectural style for building web services...",
"published_at": "2023-11-04T14:30:00Z",
"author": { "id": 456, "name": "John Doe",
"profile_url": "https://example.com/authors/456" },
"comments": { "count": 5,
"comments_url": "https://example.com/posts/123/comments" },
"self": { "link": "https://example.com/posts/123" }
}
Benefits of using REST
Architecture

• RESTful as lightweight Web Services: The RESTful architecture was a


reaction to the more heavy-weight SOAP-based standards. In REST web
services, the emphasis is on simple point-to-point communication over HTTP
using plain XML. In addition, RESTful permits many different data formats
whereas SOAP only permits XML

• The simplicity of RESTful: The RESTful architecture is much simpler to


develop than SOAP. One of the main reasons for REST popularity is the
simplicity and ease of use, as it does an extension of native Web technologies
such as HTTP.
• RESTful architecture is closer in design to the Web: RESTful is
the architectural style of the web itself, so the developer with
knowledge in web architecture will naturally develop in the RESTful
architecture.
• Scalability: As RESTful forbids conversational state, which means
we can scale very wide by adding additional server nodes behind a
load balancer.
• Expose APIs as HTTP Services: When developers need the
universal presence with minimum efforts, given the fact that RESTful
APIs are exposed as HTTP Services, which is virtually present on
almost all the platforms.

You might also like