SlideShare a Scribd company logo
APIs for a Changing World
RESTful WebAPIs
• Stands for Representational State Transfer.
• The term ‘REST’ was coined by Roy Fielding.
• REST is an architecture style for designing networked applications.
• Consists of a set of constraints that need to be strictly followed in
order to proclaim an application as RESTful.
• The World Wide Web that we all use on a daily basis is a perfect, most
successful example of a RESTful application.
• Designing and building RESTful APIs involves applying the same Web
principles while building APIs for two systems to communicate with
each other without human intervention.
REST Basics
• HTTP stands for Hypertext Transfer Protocol. It is a transport protocol used to transfer
information back and forth.
• REST does not mandate the use of HTTP. Similarly, APIs that use HTTP don’t necessarily
have to follow REST.
• However, HTTP and REST are like Coffee and Donut, or like Pizza and Soda. It’s a wide
practice to use HTTP as the protocol for REST APIs. We’ll follow the same through out this
presentation.
• In fact, the same person who coined the term ‘REST’ was also the co-author of HTTP 1.1
specification. So, the odds are pretty good that he was envisioning REST and HTTP to go
hand in hand even though he claims not.
• APIs that use HTTP are called Web APIs. Web APIs that follow REST style are called RESTful
Web APIs.
HTTP and REST
• REST style SHOULD NOT be used in an application if the main goals
are efficiency and performance. RESTful applications are not efficient
and so, may not perform as highly as expected.
• REST style SHOULD BE used if the main goal is to obtain long-term life
of an application. RESTful applications are durable. This durability is
obtained by ensuring that changes can happen to an application
without breaking things. Just like a normal website. Of course, this is
obtained by sacrificing efficiency and performance.
When to use REST and when not to
Browsing the Web 101
• Entering the URL in a browser makes the browser send an HTTP
request to a web server, specifically to the URL.
• One web server may host several URLs, and each URL grants access to
a different bit of the data on the server.
• URL points to something – a product, a user, the home page. The
general technical term for the thing is Resource.
• When a browser sends an HTTP request for a resource, the server
sends a document in response. This document is called a
Representation of the resource.
• In short, URL identifies a resource. When a client makes an HTTP
request to a URL, it gets a representation of the resource. The client
never sees a resource directly. This is a key underlining point to
understand REST.
• URL – identifies one and only one resource. If a website has two
conceptually different things on it, it is expected that the site treat
them as two resources with two different URLs.
HTTP/1.1 200 OK
Content-type: text/html
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
</head>
<body>
<div>
<h1>You type it, we post it!</h1>
<p>Exciting! Amazing!</p>
<p class="links">
<a href="/messages">Get started</a>
<a href="/about">About this site</a>
</p>
</div>
</body>
</html>
GET / HTTP/1.1
Host: www.youtypeitwepostit.com Request
Response
HTTP/1.1 200 OK
Content-type: text/html
<!DOCTYPE html>
<html>
<head>
<title>Messages</title>
</head>
<body>
<div>
<h1>Messages</h1>
<p>
Enter your message below:
</p>
<form action="http://youtypeitwepostit.com/messages"
method="post">
<input type="text" name="message" value="" required="true"
maxlength="6"/>
…
GET /messages HTTP/1.1
Host: www.youtypeitwepostit.com Request
Response
HTTP/1.1 303 See Other
Content-type: text/html
Location:
http://www.youtypeitwepostit.com/messages/5266722824890167
POST /messages HTTP/1.1
Host: www.youtypeitwepostit.com
Content-type: application/x-www-form-urlencoded
message=Hello!&submit=Post
Request
Response
HTTP/1.1 200 OK
Content-type: text/html
GET /messages/5266722824890167 HTTP/1.1
Host: www.youtypeitwepostit.com Request
Response
<!DOCTYPE html>
<html>
…
Application State
Resource State
Connectedness (HATEOAS) in the Web
• Interface Constraints
• Architectural Constraints
REST Constraints … just like the web
Identification of Resources
• Traditional hypertext systems… use unique node or document
identifiers that change every time the information changes, relying
on link servers to maintain references separately from the content.
Since centralized link servers are an anathema to the immense scale
and multi-organizational domain requirements of the Web, REST
relies instead on the author choosing a resource identifier that best
fits the nature of the concept being identified.
REST Interface Constraints
Manipulation of Resources Through Representations
• REST components perform actions on a resource by using a
representation to capture the current or intended state of that
resource and transferring that representation between components.
A representation is a sequence of bytes, plus representation
metadata to describe those bytes.
REST Interface Constraints
Self-Descriptive Messages
• REST enables intermediate processing by constraining messages to be
self-descriptive:
interaction is stateless between requests, standard methods and media types are
used to indicate semantics and exchange information, and responses explicitly
indicate cacheability.
REST Interface Constraints
The Hypermedia Constraint: Hypermedia As The Engine of Application State
(HATEOAS)
• All application state is kept on the client side. Changes to application state are
the client’s responsibility.
• The client can only change its application state by making an HTTP request and
processing the response.
• How does the client know which requests it can make next? By looking at the
hypermedia controls in the representations it’s received so far.
• Therefore, hypermedia controls are the driving force behind changes in
application state.
REST Interface Constraints
Client-Server
• A client component, desiring that a service be performed, sends a
request to the server via a connector. The server either rejects or
performs the request and sends a response back to the client.
Statelessness (No Sessions on server-side)
• The goal is to improve server scalability by eliminating any need for the
server to maintain an awareness of the client state beyond the current
request.
REST Architectural Constraints
Caching
• Thanks to the statelessness constraint, an HTTP request can be considered on
its own, independent of any other requests. These two constraints make
caching possible.
Uniform Interface
• Implementations are decoupled from the services they provide, which
encourages independent evolvability. The trade-off, though, is that a uniform
interface degrades efficiency, since information is transferred in a standardized
form rather than one which is specific to an application’s needs.
REST Architectural Constraints
Layered System
• Layered-client-server adds proxy and gateway components to the client-server
style. These additional mediator components can be added in multiple layers
to add features like load balancing and security checking to the system.
Code On Demand (The Only Optional Constraint)
• A client component has access to a set of resources, but not the know-how on
how to process them. It sends a request to a remote server for the code
representing that knowhow, receives that code, and executes it locally. The
most significant limitation is the lack of visibility due to the server sending
code instead of simple data. Lack of visibility leads to obvious deployment
problems if the client cannot trust the servers.
REST Architectural Constraints
Maturity over the years (2007-2015)
RMM Level 0
RMM Level 1
RMM Level 2
RMM Level 3 (a prerequisite for REST)
HATEOAS in a RESTful API… an example
HATEOAS in a RESTful API… an example
HTTP Verbs (Methods)
HTTP Status Codes
• Require clients to know ahead of time how to process a message
received from the server other than understanding the MIME Type.
• Have human-readable documentation explaining how to construct URLs
for all the different resources.
• Have a big menu of options instead of an interconnected web. This
makes it difficult what one resource has to do with another.
• Let clients break and require them to fix, when changes are made to the
APIs or they undergo a redesign.
• Have Versioning.
Just like the web, RESTful Web APIs
should not…
• Stands for Representational State Transfer
• Resource-oriented – Uses URIs and Resources
• Uses HTTP Verbs
• HATEOAS (Hypermedia as the Engine of Application State)
• Uses HTTP Status Codes
• Takes other advantages of HTTP:
• Caching
• Security
• Statelessness
• Network layering (with firewalls and gateways between client and server)
REST Summary

More Related Content

What's hot

IBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic InvestmentIBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic Investment
Strongback Consulting
 
Angular or React
Angular or ReactAngular or React
Angular or React
Orkhan Gasimov
 
The eBay Architecture: Striking a Balance between Site Stability, Feature Ve...
The eBay Architecture:  Striking a Balance between Site Stability, Feature Ve...The eBay Architecture:  Striking a Balance between Site Stability, Feature Ve...
The eBay Architecture: Striking a Balance between Site Stability, Feature Ve...
Randy Shoup
 
Web ,app and db server presentation
Web ,app and db server presentationWeb ,app and db server presentation
Web ,app and db server presentation
Parth Godhani
 
Service Mesh Talk for CTO Forum
Service Mesh Talk for CTO ForumService Mesh Talk for CTO Forum
Service Mesh Talk for CTO Forum
Rick Hightower
 
Restful Services
Restful ServicesRestful Services
Restful Services
SHAKIL AKHTAR
 
Top 10 Ways To Integrate With Oracle Enterprise Content Management (ECM)
Top 10 Ways To Integrate With Oracle Enterprise Content Management (ECM)Top 10 Ways To Integrate With Oracle Enterprise Content Management (ECM)
Top 10 Ways To Integrate With Oracle Enterprise Content Management (ECM)
Brian Huff
 
Power of OpenStack & Hadoop
Power of OpenStack & HadoopPower of OpenStack & Hadoop
Power of OpenStack & Hadoop
Tuan Yang
 
Oracle UCM Implementation Patterns
Oracle UCM Implementation PatternsOracle UCM Implementation Patterns
Oracle UCM Implementation Patterns
Brian Huff
 
Creating and Maintaining An Internationalized Website
Creating and Maintaining An Internationalized WebsiteCreating and Maintaining An Internationalized Website
Creating and Maintaining An Internationalized Website
Brian Huff
 
RavenDB overview
RavenDB overviewRavenDB overview
RavenDB overview
Igor Moochnick
 
Getting SharePoint 2010 Deployment Right final
Getting SharePoint 2010 Deployment Right finalGetting SharePoint 2010 Deployment Right final
Getting SharePoint 2010 Deployment Right final
vmaximiuk
 
Delivering Hybrid Cloud Solutions on Microsoft Azure
Delivering Hybrid Cloud Solutions on Microsoft AzureDelivering Hybrid Cloud Solutions on Microsoft Azure
Delivering Hybrid Cloud Solutions on Microsoft Azure
Kemp
 
Databus - LinkedIn's Change Data Capture Pipeline
Databus - LinkedIn's Change Data Capture PipelineDatabus - LinkedIn's Change Data Capture Pipeline
Databus - LinkedIn's Change Data Capture Pipeline
Sunil Nagaraj
 
Dogfood Conference 2010 - What Every SharePoint 2010 Administrator Must Know
Dogfood Conference 2010 - What Every SharePoint 2010 Administrator Must KnowDogfood Conference 2010 - What Every SharePoint 2010 Administrator Must Know
Dogfood Conference 2010 - What Every SharePoint 2010 Administrator Must Know
vmaximiuk
 
Tuning Your SharePoint Environment
Tuning Your SharePoint EnvironmentTuning Your SharePoint Environment
Tuning Your SharePoint Environment
vmaximiuk
 
DataPower Restful API Security
DataPower Restful API SecurityDataPower Restful API Security
DataPower Restful API Security
Jagadish Vemugunta
 
What SQL DBAs need to know about SharePoint-Kansas City, Sept 2013
What SQL DBAs need to know about SharePoint-Kansas City, Sept 2013What SQL DBAs need to know about SharePoint-Kansas City, Sept 2013
What SQL DBAs need to know about SharePoint-Kansas City, Sept 2013
J.D. Wade
 
TS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in PracticeTS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in Practice
aegloff
 
Web server hardware and software
Web server hardware and softwareWeb server hardware and software
Web server hardware and software
Vikram g b
 

What's hot (20)

IBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic InvestmentIBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic Investment
 
Angular or React
Angular or ReactAngular or React
Angular or React
 
The eBay Architecture: Striking a Balance between Site Stability, Feature Ve...
The eBay Architecture:  Striking a Balance between Site Stability, Feature Ve...The eBay Architecture:  Striking a Balance between Site Stability, Feature Ve...
The eBay Architecture: Striking a Balance between Site Stability, Feature Ve...
 
Web ,app and db server presentation
Web ,app and db server presentationWeb ,app and db server presentation
Web ,app and db server presentation
 
Service Mesh Talk for CTO Forum
Service Mesh Talk for CTO ForumService Mesh Talk for CTO Forum
Service Mesh Talk for CTO Forum
 
Restful Services
Restful ServicesRestful Services
Restful Services
 
Top 10 Ways To Integrate With Oracle Enterprise Content Management (ECM)
Top 10 Ways To Integrate With Oracle Enterprise Content Management (ECM)Top 10 Ways To Integrate With Oracle Enterprise Content Management (ECM)
Top 10 Ways To Integrate With Oracle Enterprise Content Management (ECM)
 
Power of OpenStack & Hadoop
Power of OpenStack & HadoopPower of OpenStack & Hadoop
Power of OpenStack & Hadoop
 
Oracle UCM Implementation Patterns
Oracle UCM Implementation PatternsOracle UCM Implementation Patterns
Oracle UCM Implementation Patterns
 
Creating and Maintaining An Internationalized Website
Creating and Maintaining An Internationalized WebsiteCreating and Maintaining An Internationalized Website
Creating and Maintaining An Internationalized Website
 
RavenDB overview
RavenDB overviewRavenDB overview
RavenDB overview
 
Getting SharePoint 2010 Deployment Right final
Getting SharePoint 2010 Deployment Right finalGetting SharePoint 2010 Deployment Right final
Getting SharePoint 2010 Deployment Right final
 
Delivering Hybrid Cloud Solutions on Microsoft Azure
Delivering Hybrid Cloud Solutions on Microsoft AzureDelivering Hybrid Cloud Solutions on Microsoft Azure
Delivering Hybrid Cloud Solutions on Microsoft Azure
 
Databus - LinkedIn's Change Data Capture Pipeline
Databus - LinkedIn's Change Data Capture PipelineDatabus - LinkedIn's Change Data Capture Pipeline
Databus - LinkedIn's Change Data Capture Pipeline
 
Dogfood Conference 2010 - What Every SharePoint 2010 Administrator Must Know
Dogfood Conference 2010 - What Every SharePoint 2010 Administrator Must KnowDogfood Conference 2010 - What Every SharePoint 2010 Administrator Must Know
Dogfood Conference 2010 - What Every SharePoint 2010 Administrator Must Know
 
Tuning Your SharePoint Environment
Tuning Your SharePoint EnvironmentTuning Your SharePoint Environment
Tuning Your SharePoint Environment
 
DataPower Restful API Security
DataPower Restful API SecurityDataPower Restful API Security
DataPower Restful API Security
 
What SQL DBAs need to know about SharePoint-Kansas City, Sept 2013
What SQL DBAs need to know about SharePoint-Kansas City, Sept 2013What SQL DBAs need to know about SharePoint-Kansas City, Sept 2013
What SQL DBAs need to know about SharePoint-Kansas City, Sept 2013
 
TS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in PracticeTS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in Practice
 
Web server hardware and software
Web server hardware and softwareWeb server hardware and software
Web server hardware and software
 

Viewers also liked

RESTFul WebApp Concept
RESTFul WebApp ConceptRESTFul WebApp Concept
RESTFul WebApp Concept
Dian Aditya
 
Caminante Proyecto Educativo and The Re...Dominican Republic - Global Ministr...
Caminante Proyecto Educativo and The Re...Dominican Republic - Global Ministr...Caminante Proyecto Educativo and The Re...Dominican Republic - Global Ministr...
Caminante Proyecto Educativo and The Re...Dominican Republic - Global Ministr...
Ashley Holst
 
NJ Wrestling Region 4 Champions
NJ Wrestling Region 4 ChampionsNJ Wrestling Region 4 Champions
NJ Wrestling Region 4 Champions
JIm Traxinger
 
Presentation 4
Presentation 4Presentation 4
Presentation 4
Meerwise Joya
 
CHURCH AND SOCIETY--Table and Intoduction
CHURCH AND SOCIETY--Table and IntoductionCHURCH AND SOCIETY--Table and Intoduction
CHURCH AND SOCIETY--Table and Intoduction
Rudi Maier
 
Basic android
Basic androidBasic android
Basic android
Dharmendra Kushwaha
 
Tarea 5 motivacion_judithazuaje
Tarea 5 motivacion_judithazuajeTarea 5 motivacion_judithazuaje
Tarea 5 motivacion_judithazuaje
yudy7777
 
La storia è di tutti
La storia è di tuttiLa storia è di tutti
La storia è di tutti
scuolabloggando
 
No morebullconferencefeb2015
No morebullconferencefeb2015No morebullconferencefeb2015
No morebullconferencefeb2015
AlbertaHelpingAnimalsSociety
 
El sueno
El suenoEl sueno
El sueno
yudy7777
 
In-Vitro Paper
In-Vitro PaperIn-Vitro Paper
In-Vitro Paper
Jennifer Quinn
 
Presentation 2
Presentation 2Presentation 2
Presentation 2
Meerwise Joya
 
Scuolasicura
ScuolasicuraScuolasicura
Scuolasicura
scuolabloggando
 
Riscopriamo il mondo contadino della Maremma Settentrionale
Riscopriamo il mondo contadino  della Maremma SettentrionaleRiscopriamo il mondo contadino  della Maremma Settentrionale
Riscopriamo il mondo contadino della Maremma Settentrionale
scuolabloggando
 
J.Levy Persentation - M3
J.Levy Persentation - M3J.Levy Persentation - M3
J.Levy Persentation - M3
Jacob Levy
 
SinglePageApplications
SinglePageApplicationsSinglePageApplications
SinglePageApplications
Adi Challa
 
Garden State HS Wrestling Champions
Garden State HS Wrestling ChampionsGarden State HS Wrestling Champions
Garden State HS Wrestling Champions
JIm Traxinger
 
Pennsylvanian 1-19-79
Pennsylvanian 1-19-79Pennsylvanian 1-19-79
Pennsylvanian 1-19-79
JIm Traxinger
 
1979 EIWA Championship
1979 EIWA Championship1979 EIWA Championship
1979 EIWA Championship
JIm Traxinger
 

Viewers also liked (20)

RESTFul WebApp Concept
RESTFul WebApp ConceptRESTFul WebApp Concept
RESTFul WebApp Concept
 
Caminante Proyecto Educativo and The Re...Dominican Republic - Global Ministr...
Caminante Proyecto Educativo and The Re...Dominican Republic - Global Ministr...Caminante Proyecto Educativo and The Re...Dominican Republic - Global Ministr...
Caminante Proyecto Educativo and The Re...Dominican Republic - Global Ministr...
 
NJ Wrestling Region 4 Champions
NJ Wrestling Region 4 ChampionsNJ Wrestling Region 4 Champions
NJ Wrestling Region 4 Champions
 
Presentation 4
Presentation 4Presentation 4
Presentation 4
 
CHURCH AND SOCIETY--Table and Intoduction
CHURCH AND SOCIETY--Table and IntoductionCHURCH AND SOCIETY--Table and Intoduction
CHURCH AND SOCIETY--Table and Intoduction
 
Basic android
Basic androidBasic android
Basic android
 
Tarea 5 motivacion_judithazuaje
Tarea 5 motivacion_judithazuajeTarea 5 motivacion_judithazuaje
Tarea 5 motivacion_judithazuaje
 
Un fantasma a...scuola
Un fantasma a...scuolaUn fantasma a...scuola
Un fantasma a...scuola
 
La storia è di tutti
La storia è di tuttiLa storia è di tutti
La storia è di tutti
 
No morebullconferencefeb2015
No morebullconferencefeb2015No morebullconferencefeb2015
No morebullconferencefeb2015
 
El sueno
El suenoEl sueno
El sueno
 
In-Vitro Paper
In-Vitro PaperIn-Vitro Paper
In-Vitro Paper
 
Presentation 2
Presentation 2Presentation 2
Presentation 2
 
Scuolasicura
ScuolasicuraScuolasicura
Scuolasicura
 
Riscopriamo il mondo contadino della Maremma Settentrionale
Riscopriamo il mondo contadino  della Maremma SettentrionaleRiscopriamo il mondo contadino  della Maremma Settentrionale
Riscopriamo il mondo contadino della Maremma Settentrionale
 
J.Levy Persentation - M3
J.Levy Persentation - M3J.Levy Persentation - M3
J.Levy Persentation - M3
 
SinglePageApplications
SinglePageApplicationsSinglePageApplications
SinglePageApplications
 
Garden State HS Wrestling Champions
Garden State HS Wrestling ChampionsGarden State HS Wrestling Champions
Garden State HS Wrestling Champions
 
Pennsylvanian 1-19-79
Pennsylvanian 1-19-79Pennsylvanian 1-19-79
Pennsylvanian 1-19-79
 
1979 EIWA Championship
1979 EIWA Championship1979 EIWA Championship
1979 EIWA Championship
 

Similar to RESTful APIs

REST Introduction.ppt
REST Introduction.pptREST Introduction.ppt
REST Introduction.ppt
KGSCSEPSGCT
 
Restful web-services
Restful web-servicesRestful web-services
Restful web-services
rporwal
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
Halil Burak Cetinkaya
 
What are restful web services?
What are restful web services?What are restful web services?
What are restful web services?
Aparna Sharma
 
REST and RESTful Services
REST and RESTful ServicesREST and RESTful Services
REST and RESTful Services
Damian T. Gordon
 
Mini-Training: Let's have a rest
Mini-Training: Let's have a restMini-Training: Let's have a rest
Mini-Training: Let's have a rest
Betclic Everest Group Tech Team
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdf
Aparna Sharma
 
Rest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbookRest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbook
Katy Slemon
 
zendframework2 restful
zendframework2 restfulzendframework2 restful
zendframework2 restful
tom_li
 
REST - Representational State Transfer
REST - Representational State TransferREST - Representational State Transfer
REST - Representational State Transfer
Peter R. Egli
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdf
Raghunathan52
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdf
Raghunathan52
 
Overview of java web services
Overview of java web servicesOverview of java web services
Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface) Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface)
Vibhawa Nirmal
 
Rest api design
Rest api designRest api design
Rest api design
Rudra Tripathy
 
REST and the Hypermedia Constraint
REST and the Hypermedia ConstraintREST and the Hypermedia Constraint
REST and the Hypermedia Constraint
Inviqa
 
Rest WebAPI with OData
Rest WebAPI with ODataRest WebAPI with OData
Rest WebAPI with OData
Mahek Merchant
 
Ijirsm ashok-kumar-ps-compulsiveness-of-res tful-web-services
Ijirsm ashok-kumar-ps-compulsiveness-of-res tful-web-servicesIjirsm ashok-kumar-ps-compulsiveness-of-res tful-web-services
Ijirsm ashok-kumar-ps-compulsiveness-of-res tful-web-services
IJIR JOURNALS IJIRUSA
 
Rest webservice ppt
Rest webservice pptRest webservice ppt
Rest webservice ppt
sinhatanay
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdf
Aparna Sharma
 

Similar to RESTful APIs (20)

REST Introduction.ppt
REST Introduction.pptREST Introduction.ppt
REST Introduction.ppt
 
Restful web-services
Restful web-servicesRestful web-services
Restful web-services
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
What are restful web services?
What are restful web services?What are restful web services?
What are restful web services?
 
REST and RESTful Services
REST and RESTful ServicesREST and RESTful Services
REST and RESTful Services
 
Mini-Training: Let's have a rest
Mini-Training: Let's have a restMini-Training: Let's have a rest
Mini-Training: Let's have a rest
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdf
 
Rest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbookRest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbook
 
zendframework2 restful
zendframework2 restfulzendframework2 restful
zendframework2 restful
 
REST - Representational State Transfer
REST - Representational State TransferREST - Representational State Transfer
REST - Representational State Transfer
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdf
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdf
 
Overview of java web services
Overview of java web servicesOverview of java web services
Overview of java web services
 
Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface) Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface)
 
Rest api design
Rest api designRest api design
Rest api design
 
REST and the Hypermedia Constraint
REST and the Hypermedia ConstraintREST and the Hypermedia Constraint
REST and the Hypermedia Constraint
 
Rest WebAPI with OData
Rest WebAPI with ODataRest WebAPI with OData
Rest WebAPI with OData
 
Ijirsm ashok-kumar-ps-compulsiveness-of-res tful-web-services
Ijirsm ashok-kumar-ps-compulsiveness-of-res tful-web-servicesIjirsm ashok-kumar-ps-compulsiveness-of-res tful-web-services
Ijirsm ashok-kumar-ps-compulsiveness-of-res tful-web-services
 
Rest webservice ppt
Rest webservice pptRest webservice ppt
Rest webservice ppt
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdf
 

RESTful APIs

  • 1. APIs for a Changing World RESTful WebAPIs
  • 2. • Stands for Representational State Transfer. • The term ‘REST’ was coined by Roy Fielding. • REST is an architecture style for designing networked applications. • Consists of a set of constraints that need to be strictly followed in order to proclaim an application as RESTful. • The World Wide Web that we all use on a daily basis is a perfect, most successful example of a RESTful application. • Designing and building RESTful APIs involves applying the same Web principles while building APIs for two systems to communicate with each other without human intervention. REST Basics
  • 3. • HTTP stands for Hypertext Transfer Protocol. It is a transport protocol used to transfer information back and forth. • REST does not mandate the use of HTTP. Similarly, APIs that use HTTP don’t necessarily have to follow REST. • However, HTTP and REST are like Coffee and Donut, or like Pizza and Soda. It’s a wide practice to use HTTP as the protocol for REST APIs. We’ll follow the same through out this presentation. • In fact, the same person who coined the term ‘REST’ was also the co-author of HTTP 1.1 specification. So, the odds are pretty good that he was envisioning REST and HTTP to go hand in hand even though he claims not. • APIs that use HTTP are called Web APIs. Web APIs that follow REST style are called RESTful Web APIs. HTTP and REST
  • 4. • REST style SHOULD NOT be used in an application if the main goals are efficiency and performance. RESTful applications are not efficient and so, may not perform as highly as expected. • REST style SHOULD BE used if the main goal is to obtain long-term life of an application. RESTful applications are durable. This durability is obtained by ensuring that changes can happen to an application without breaking things. Just like a normal website. Of course, this is obtained by sacrificing efficiency and performance. When to use REST and when not to
  • 6. • Entering the URL in a browser makes the browser send an HTTP request to a web server, specifically to the URL. • One web server may host several URLs, and each URL grants access to a different bit of the data on the server. • URL points to something – a product, a user, the home page. The general technical term for the thing is Resource. • When a browser sends an HTTP request for a resource, the server sends a document in response. This document is called a Representation of the resource. • In short, URL identifies a resource. When a client makes an HTTP request to a URL, it gets a representation of the resource. The client never sees a resource directly. This is a key underlining point to understand REST. • URL – identifies one and only one resource. If a website has two conceptually different things on it, it is expected that the site treat them as two resources with two different URLs.
  • 7. HTTP/1.1 200 OK Content-type: text/html <!DOCTYPE html> <html> <head> <title>Home</title> </head> <body> <div> <h1>You type it, we post it!</h1> <p>Exciting! Amazing!</p> <p class="links"> <a href="/messages">Get started</a> <a href="/about">About this site</a> </p> </div> </body> </html> GET / HTTP/1.1 Host: www.youtypeitwepostit.com Request Response
  • 8.
  • 9. HTTP/1.1 200 OK Content-type: text/html <!DOCTYPE html> <html> <head> <title>Messages</title> </head> <body> <div> <h1>Messages</h1> <p> Enter your message below: </p> <form action="http://youtypeitwepostit.com/messages" method="post"> <input type="text" name="message" value="" required="true" maxlength="6"/> … GET /messages HTTP/1.1 Host: www.youtypeitwepostit.com Request Response
  • 10.
  • 11. HTTP/1.1 303 See Other Content-type: text/html Location: http://www.youtypeitwepostit.com/messages/5266722824890167 POST /messages HTTP/1.1 Host: www.youtypeitwepostit.com Content-type: application/x-www-form-urlencoded message=Hello!&submit=Post Request Response HTTP/1.1 200 OK Content-type: text/html GET /messages/5266722824890167 HTTP/1.1 Host: www.youtypeitwepostit.com Request Response <!DOCTYPE html> <html> …
  • 12.
  • 15. • Interface Constraints • Architectural Constraints REST Constraints … just like the web
  • 16. Identification of Resources • Traditional hypertext systems… use unique node or document identifiers that change every time the information changes, relying on link servers to maintain references separately from the content. Since centralized link servers are an anathema to the immense scale and multi-organizational domain requirements of the Web, REST relies instead on the author choosing a resource identifier that best fits the nature of the concept being identified. REST Interface Constraints
  • 17. Manipulation of Resources Through Representations • REST components perform actions on a resource by using a representation to capture the current or intended state of that resource and transferring that representation between components. A representation is a sequence of bytes, plus representation metadata to describe those bytes. REST Interface Constraints
  • 18. Self-Descriptive Messages • REST enables intermediate processing by constraining messages to be self-descriptive: interaction is stateless between requests, standard methods and media types are used to indicate semantics and exchange information, and responses explicitly indicate cacheability. REST Interface Constraints
  • 19. The Hypermedia Constraint: Hypermedia As The Engine of Application State (HATEOAS) • All application state is kept on the client side. Changes to application state are the client’s responsibility. • The client can only change its application state by making an HTTP request and processing the response. • How does the client know which requests it can make next? By looking at the hypermedia controls in the representations it’s received so far. • Therefore, hypermedia controls are the driving force behind changes in application state. REST Interface Constraints
  • 20. Client-Server • A client component, desiring that a service be performed, sends a request to the server via a connector. The server either rejects or performs the request and sends a response back to the client. Statelessness (No Sessions on server-side) • The goal is to improve server scalability by eliminating any need for the server to maintain an awareness of the client state beyond the current request. REST Architectural Constraints
  • 21. Caching • Thanks to the statelessness constraint, an HTTP request can be considered on its own, independent of any other requests. These two constraints make caching possible. Uniform Interface • Implementations are decoupled from the services they provide, which encourages independent evolvability. The trade-off, though, is that a uniform interface degrades efficiency, since information is transferred in a standardized form rather than one which is specific to an application’s needs. REST Architectural Constraints
  • 22. Layered System • Layered-client-server adds proxy and gateway components to the client-server style. These additional mediator components can be added in multiple layers to add features like load balancing and security checking to the system. Code On Demand (The Only Optional Constraint) • A client component has access to a set of resources, but not the know-how on how to process them. It sends a request to a remote server for the code representing that knowhow, receives that code, and executes it locally. The most significant limitation is the lack of visibility due to the server sending code instead of simple data. Lack of visibility leads to obvious deployment problems if the client cannot trust the servers. REST Architectural Constraints
  • 23. Maturity over the years (2007-2015)
  • 27. RMM Level 3 (a prerequisite for REST)
  • 28. HATEOAS in a RESTful API… an example
  • 29. HATEOAS in a RESTful API… an example
  • 32. • Require clients to know ahead of time how to process a message received from the server other than understanding the MIME Type. • Have human-readable documentation explaining how to construct URLs for all the different resources. • Have a big menu of options instead of an interconnected web. This makes it difficult what one resource has to do with another. • Let clients break and require them to fix, when changes are made to the APIs or they undergo a redesign. • Have Versioning. Just like the web, RESTful Web APIs should not…
  • 33. • Stands for Representational State Transfer • Resource-oriented – Uses URIs and Resources • Uses HTTP Verbs • HATEOAS (Hypermedia as the Engine of Application State) • Uses HTTP Status Codes • Takes other advantages of HTTP: • Caching • Security • Statelessness • Network layering (with firewalls and gateways between client and server) REST Summary