0% found this document useful (0 votes)
50 views8 pages

Restful Key Elements

1. The document discusses the key elements of RESTful APIs, including resources, request verbs, headers, bodies, and response codes and bodies. 2. It provides examples of how RESTful requests work, such as GET to retrieve an employee record from a hypothetical API. 3. The reasons RESTful APIs became popular are that they allow applications built on different languages and platforms to communicate through a standard interface, and support cloud-based architectures which largely use REST principles.

Uploaded by

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

Restful Key Elements

1. The document discusses the key elements of RESTful APIs, including resources, request verbs, headers, bodies, and response codes and bodies. 2. It provides examples of how RESTful requests work, such as GET to retrieve an employee record from a hypothetical API. 3. The reasons RESTful APIs became popular are that they allow applications built on different languages and platforms to communicate through a standard interface, and support cloud-based architectures which largely use REST principles.

Uploaded by

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

RESTful Key Elements

Web services have really come a long way


since its inception. In 2002, the Web
consortium had released the definition of
WSDL and SOAP web services. This formed
the standard of how web services are
implemented.
In 2004, the web consortium also released the
definition of an additional standard called
RESTful. Over the past couple of years, this
standard has become quite popular. And is
being used by many of the popular websites
around the world which include Facebook and
Twitter.
REST is a way to access resources which lie
in a particular environment. For example, you
could have a server that could be hosting
important documents or pictures or videos. All
of these are an example of resources. If a
client, say a web browser needs any of these
resources, it has to send a request to the
server to access these resources. Now REST
defines a way on how these resources can be
accessed.
The key elements of a RESTful
implementation are as follows:
1. Resources – The first key element is
the resource itself. Let assume that a web
application on a server has records of
several employees. Let's assume the URL
of the web application
is http://demo.guru99.com. Now in order
to access an employee record resource via
REST, one can issue the
command http://demo.guru99.com/empl
oyee/1 - This command tells the web
server to please provide the details of the
employee whose employee number is 1.
2. Request Verbs - These describe what
you want to do with the resource. A
browser issues a GET verb to instruct the
endpoint it wants to get data. However,
there are many other verbs available
including things like POST, PUT, and
DELETE. So in the case of the
example http://demo.guru99.com/emplo
yee/1 , the web browser is actually issuing
a GET Verb because it wants to get the
details of the employee record.
3. Request Headers – These are
additional instructions sent with the
request. These might define the type of
response required or the authorization
details.
4. Request Body - Data is sent with the
request. Data is normally sent in the
request when a POST request is made to
the REST web service. In a POST call, the
client actually tells the web service that it
wants to add a resource to the server.
Hence, the request body would have the
details of the resource which is required to
be added to the server.
5. Response Body – This is the main
body of the response. So in our example, if
we were to query the web server via the
request http://demo.guru99.com/employ
ee/1 , the web server might return an XML
document with all the details of the
employee in the Response Body.
6. Response Status codes – These
codes are the general codes which are
returned along with the response from the
web server. An example is the code 200
which is normally returned if there is no
error when returning a response to the
client.

Restful Methods
The below diagram shows mostly all the verbs
(POST, GET, PUT, and DELETE) and an
example of what they would mean.
Let's assume that we have a RESTful web
service is defined at the
location. http://demo.guru99.com/employee
. When the client makes any request to this
web service, it can specify any of the normal
HTTP verbs of GET, POST, DELETE and
PUT. Below is what would happen If the
respective verbs were sent by the client.
1. POST – This would be used to create a
new employee using the RESTful web
service
2. GET - This would be used to get a list
of all employee using the RESTful web
service
3. PUT - This would be used to update all
employee using the RESTful web service
4. DELETE - This would be used to delete
all employee using the RESTful web
service
Let's take a look from a perspective of just a
single record. Let's say there was an
employee record with the employee number of
1.
The following actions would have their
respective meanings.
1. POST – This would not be applicable
since we are fetching data of employee 1
which is already created.
2. GET - This would be used to get the
details of the employee with Employee no
as 1 using the RESTful web service
3. PUT - This would be used to update
the details of the employee with Employee
no as 1 using the RESTful web service
4. DELETE - This is used to delete the
details of the employee with Employee no
as 1

Why Restful
Restful mostly came into popularity due to the
following reasons:
 Heterogeneous languages and
environments – This is one of the
fundamental reasons which is the same as
we It enables web applications that are
built on various programming languages to
communicate with each other
 With the help of Restful services, these
web applications can reside on different
environments, some could be on Windows,
and others could be on Linux.
But in the end, no matter what the environment
is, the end result should always be the same
that they should be able to talk to each other.
Restful web services offer this flexibility to
applications built on various programming
languages and platforms to talk to each other.
The below picture gives an example of a web
application which has a requirement to talk to
other applications such Facebook, Twitter, and
Google.
Now if a client application had to work with
sites such as Facebook, Twitter, etc. they
would probably have to know what is the
language Facebook, Google and Twitter are
built on, and also on what platform they are
built on.
Based on this, we can write the interfacing
code for our web application, but this could
prove to be a nightmare.
Facebook, Twitter, and Google expose their
functionality in the form of Restful web
services. This allows any client application to
call these web services via REST.

.
2. Finally is the event of the Cloud –
Everything is moving to the cloud.
Applications are slowly moving to cloud-
based systems such as in Azure or
Amazon. Azure and Amazon provide a lot
of API's based on the Restful architecture.
Hence, applications now need to be
developed in such a way that they are
made compatible with the Cloud. So since
all Cloud-based architectures work on the
REST principle, it makes more sense for
web services to be programmed on the
REST based architecture to make the best
use of Cloud-based services.

You might also like