SlideShare a Scribd company logo
REST(Representational State Transfer)
- SHAILESH SINGH
1. Why so REST FUL?
 Life before REST
 Challenges of HTTP ?
 RMI , SOAP , RPC and HTTP different famous technique to develop web services
2. What is REST? Defined in 2000
 Architects are Made, Not Born
 What REST father Roy Fielding says
 An architecture style is a coordinated set of architectural constraints that restricts the
roles and features of architectural elements . E.g. : UI layer and data layer segregation ,
statelessness , cacheability
 Uniform Interface : Overall system architecture is simplified and the visibility of
interactions is improved
Tradeoff : Degrades efficiency since Information is transferred in a standardised form
rather than one which is specific to application's needs
a. Uniform Interface
 Four interface constraints
● Identification of resources
● Manipulation of resources through representations
● Self descriptive messages
● Hypermedia as the engine of application state (HATEOAS)
b. What is resources
Another way to describe REST is ROA : Resource Oriented Architecture
 Any information that can be named is a resource
 A resource is a conceptual mapping to a set of entities not the entity itself. Such a
mapping can change over time.
 A resource can be a collection of entities too.
 Every resource has a name that uniquely identifies it – the URI
 Think of it like a primary key for each row in a database
 REST doesn't dictate URI choice. Leaves it to the application author.
c.What If?
/getAccount
/getAllAccounts
/searchAccounts
/createDirectory
/updateGroup
/updateGroupName
/findGroupsByDirectory
/verifyAccountEmailAddress
As you move from an action oriented design towards resource oriented design,
thinking of everything as nouns is one of the early challenges to overcome
Identification of Resources
Identification of Resources
d.The Answer
Fundamentally two types of resources:
Collection Resource
/applications
/books
/orders
Instance Resource
/applications/a1b2c3
/books/1235
/orders/abcdef
Question :
Guess REST equivalent for : Transaction.approve and Account.pay
TransactionApproval and AccountPayment
e.Behavior
POST, GET, PUT, DELETE
≠ 1:1
Create, Read, Update, Delete
f. PUT for Create
Identifier is known by the client:
PUT:
Used to create a resource, or overwrite it. While you specify the resources new URL.
For a new resource:
PUT /questions/<new_question> HTTP/1.1
Host: www.example.com/
To overwrite an existing resource:
PUT /questions/<existing_question> HTTP/1.1
Host: www.example.com/
PUT is Idempotent
g.POST as Create
 POST:
Used to modify and update a resource
POST /questions/<existing_question> HTTP/1.1
Host: www.example.com/
Note that the following is an error:
POST /questions/<new_question> HTTP/1.1
Host: www.example.com/
If the URL is not yet created, you should not be using POST to create it while specifying the name. This should result in a 'resource not found'
error because <new question> does not exist yet. You should PUT the <new question> resource on the server first.
You could though do something like this to create a resources using POST:
POST /applications
{
“name”: “Best App Ever”
}
Response:
201 Created
Location: https://api.singh.com/applications/a1b2c3
POST NOT Idempotent -> x++ vs. x=4
4.a. Example/case Studies
 Fine grained CRUD resources Vs Coarse Grained resources:
Like Operation on blog post (“/posts/{post_id}/likes”)
Comment Operation on blog post (“/posts/{post_id}/comments”)
vs
The single coarse grained resource “Post”(/posts/{post_id}” for “liking” or
“commenting”
4.b. Example/case Studies
 Change the Address:
We can update “Customer” address via “Customers/001/Address/KA001/” or
“Address/KA001/”
VS
Design the API around the resources that are based on the business processes and domain events . To
update an existing bank customer’s address, a POST request can be made to “ChangeOfAddress” resource.
Very important to distinguish between resources in REST API and domain entities in a
domain driven design.
4.c HATEOAS
 HATEOAS=Hypermedia As The Engine Of Application State
Path is the hierarchical and the query is the non-hierarchical part of the URIs.
! Magic awesome sauce to improve REST!
According to the HATEOAS constraint your client has to follow hyperlinks sent by
the service. Those hyperlinks must be annotated with metadata regarding the
semantics of them
HATEOAS constrain
 A REST client enters a REST application through a simple fixed URL. All future actions the client may take are discovered within resource representations
returned from the server.
 E.g:
Request
GET /account/12345
HTTP/1.1 Host: somebank.org
Accept: application/xml
Response:
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: ...
<?xml version="1.0"?>
<account>
<account_number>12345</account_number>
<balance currency="usd">100.00</balance>
<link rel="deposit" href="https://somebank.org/account/12345/deposit" />
<link rel="withdraw" href="https://somebank.org/account/12345/withdraw" />
<link rel="transfer" href="https://somebank.org/account/12345/transfer" />
<link rel="close" href="https://somebank.org/account/12345/close" />
</account>
Later Response:
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: ...
<?xml version="1.0"?>
<account>
<account_number>12345</account_number>
<balance currency="usd">-25.00</balance>
<link rel="deposit" href="https://somebank.org/account/12345/deposit" />
</account>
Book Flight Ticket
Get Flight Search Result
Confirm a Flight
Payment still Pending
Payment
Fetch E-Ticket
Worked examples
How to GET a Cup of Coffee by Jim Webber, Savas
Parastatidis & Ian Robinson Oct 02, 2008
http://www.infoq.com/articles/webber-rest-workflow
Questions
http://petstore.swagger.io/
http://start.spring.io/

More Related Content

What's hot (20)

PPTX
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
Geert Pante
 
PDF
HTML5 and the dawn of rich mobile web applications
James Pearce
 
PPT
Java EE 6 & Spring: A Lover's Quarrel
Mauricio "Maltron" Leal
 
PPTX
Best practices for RESTful web service design
Ramin Orujov
 
PPTX
Hypermedia APIs
Paulo Gandra de Sousa
 
PPT
Understanding REST
Nitin Pande
 
PPTX
Sherlock Homepage - A detective story about running large web services (VISUG...
Maarten Balliauw
 
PPTX
Benefits of Hypermedia API
Paulo Gandra de Sousa
 
PPT
The RESTful Soa Datagrid with Oracle
Emiliano Pecis
 
PDF
Indic threads delhi13-rest-anirudh
Anirudh Bhatnagar
 
PDF
Spring 4.3-component-design
Grzegorz Duda
 
PDF
Java Web Application Security with Java EE, Spring Security and Apache Shiro ...
Matt Raible
 
PDF
Reactjs Basics
Hamid Ghorbani
 
PDF
StrongLoop Node.js API Security & Customization
jguerrero999
 
PDF
What the Heck is OAuth and OpenID Connect? Connect.Tech 2017
Matt Raible
 
PDF
Remote code-with-expression-language-injection
Mickey Jack
 
PDF
Introduction to rest.li
Joe Betz
 
PDF
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
Java User Group Latvia
 
PDF
Getting Started with WebSocket and Server-Sent Events in Java
Arun Gupta
 
PDF
Spring boot jpa
Hamid Ghorbani
 
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
Geert Pante
 
HTML5 and the dawn of rich mobile web applications
James Pearce
 
Java EE 6 & Spring: A Lover's Quarrel
Mauricio "Maltron" Leal
 
Best practices for RESTful web service design
Ramin Orujov
 
Hypermedia APIs
Paulo Gandra de Sousa
 
Understanding REST
Nitin Pande
 
Sherlock Homepage - A detective story about running large web services (VISUG...
Maarten Balliauw
 
Benefits of Hypermedia API
Paulo Gandra de Sousa
 
The RESTful Soa Datagrid with Oracle
Emiliano Pecis
 
Indic threads delhi13-rest-anirudh
Anirudh Bhatnagar
 
Spring 4.3-component-design
Grzegorz Duda
 
Java Web Application Security with Java EE, Spring Security and Apache Shiro ...
Matt Raible
 
Reactjs Basics
Hamid Ghorbani
 
StrongLoop Node.js API Security & Customization
jguerrero999
 
What the Heck is OAuth and OpenID Connect? Connect.Tech 2017
Matt Raible
 
Remote code-with-expression-language-injection
Mickey Jack
 
Introduction to rest.li
Joe Betz
 
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
Java User Group Latvia
 
Getting Started with WebSocket and Server-Sent Events in Java
Arun Gupta
 
Spring boot jpa
Hamid Ghorbani
 

Viewers also liked (20)

PPTX
Why Use “REST” Architecture for Web Services?
Arinto Murdopo
 
PDF
JavaEE and RESTful development - WSO2 Colombo Meetup
Sagara Gunathunga
 
DOCX
42121093
andres castillo
 
DOCX
ประวัติ
Thitipa Chaloey-ot
 
PDF
Sweet vengeance script
Taha Khan
 
PPTX
Plan clase
mafoa
 
DOCX
ซื่อสัตย์
Pawarin Ja
 
DOCX
ประวัติส่วนตัว มล
Pawarin Ja
 
DOCX
กิจกรรม 59 2
Thitipa Chaloey-ot
 
PPTX
Portfolio
Fern Lamoonpak
 
PPT
Medios didáctic os tecnologico
Juan Mercedes
 
PDF
Dwi yustiani hapzi ali_strategi pemasaran_2017
Dwi Yustiani
 
PDF
Why HATEOAS
Lee Wayne
 
DOC
Resume
vivekaps
 
PPTX
Modul 3 kb 2 keperawatan bencana pada anak
Uwes Chaeruman
 
PPSX
Rest api standards and best practices
Ankita Mahajan
 
PDF
Henry gilbert robin hood
zoran radovic
 
PDF
No REST - Architecting Real-time Bulk Async APIs
C4Media
 
PPT
REST Presentation
Alexandros Marinos
 
Why Use “REST” Architecture for Web Services?
Arinto Murdopo
 
JavaEE and RESTful development - WSO2 Colombo Meetup
Sagara Gunathunga
 
42121093
andres castillo
 
ประวัติ
Thitipa Chaloey-ot
 
Sweet vengeance script
Taha Khan
 
Plan clase
mafoa
 
ซื่อสัตย์
Pawarin Ja
 
ประวัติส่วนตัว มล
Pawarin Ja
 
กิจกรรม 59 2
Thitipa Chaloey-ot
 
Portfolio
Fern Lamoonpak
 
Medios didáctic os tecnologico
Juan Mercedes
 
Dwi yustiani hapzi ali_strategi pemasaran_2017
Dwi Yustiani
 
Why HATEOAS
Lee Wayne
 
Resume
vivekaps
 
Modul 3 kb 2 keperawatan bencana pada anak
Uwes Chaeruman
 
Rest api standards and best practices
Ankita Mahajan
 
Henry gilbert robin hood
zoran radovic
 
No REST - Architecting Real-time Bulk Async APIs
C4Media
 
REST Presentation
Alexandros Marinos
 
Ad

Similar to REST Architecture with use case and example (20)

PPTX
A Deep Dive into RESTful API Design Part 1
VivekKrishna34
 
PDF
REST Basics
Ivano Malavolta
 
PPTX
REST and RESTful Services
Damian T. Gordon
 
PPTX
L18 REST API Design
Ólafur Andri Ragnarsson
 
PPTX
Overview of REST - Raihan Ullah
Cefalo
 
PPTX
RESTful services
Pedram Bashiri
 
PDF
[2015/2016] The REST architectural style
Ivano Malavolta
 
PDF
Java Web Services [5/5]: REST and JAX-RS
IMC Institute
 
PPTX
RESTful APIs
Adi Challa
 
PPT
Treinamento 1
Carlos Melo
 
PPTX
JAX-RS. Developing RESTful APIs with Java
Jerry Kurian
 
PDF
Rest
Ivano Malavolta
 
PPTX
RestfulDesignRules
Michael De Courci
 
PDF
Applications of the REST Principle
elliando dias
 
PDF
Rest web services
Paulo Gandra de Sousa
 
PDF
-overview of res tful architecture-2
JunHwan Huh
 
PPTX
RESTful Web Services
adeppathondur
 
PDF
Restful Services
SHAKIL AKHTAR
 
PPTX
REST & RESTful APIs: The State of Confusion
Glenn Antoine
 
PPTX
Lecture 12
vishal choudhary
 
A Deep Dive into RESTful API Design Part 1
VivekKrishna34
 
REST Basics
Ivano Malavolta
 
REST and RESTful Services
Damian T. Gordon
 
L18 REST API Design
Ólafur Andri Ragnarsson
 
Overview of REST - Raihan Ullah
Cefalo
 
RESTful services
Pedram Bashiri
 
[2015/2016] The REST architectural style
Ivano Malavolta
 
Java Web Services [5/5]: REST and JAX-RS
IMC Institute
 
RESTful APIs
Adi Challa
 
Treinamento 1
Carlos Melo
 
JAX-RS. Developing RESTful APIs with Java
Jerry Kurian
 
RestfulDesignRules
Michael De Courci
 
Applications of the REST Principle
elliando dias
 
Rest web services
Paulo Gandra de Sousa
 
-overview of res tful architecture-2
JunHwan Huh
 
RESTful Web Services
adeppathondur
 
Restful Services
SHAKIL AKHTAR
 
REST & RESTful APIs: The State of Confusion
Glenn Antoine
 
Lecture 12
vishal choudhary
 
Ad

Recently uploaded (20)

PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
July Patch Tuesday
Ivanti
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
July Patch Tuesday
Ivanti
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 

REST Architecture with use case and example

  • 2. 1. Why so REST FUL?  Life before REST  Challenges of HTTP ?  RMI , SOAP , RPC and HTTP different famous technique to develop web services
  • 3. 2. What is REST? Defined in 2000  Architects are Made, Not Born  What REST father Roy Fielding says  An architecture style is a coordinated set of architectural constraints that restricts the roles and features of architectural elements . E.g. : UI layer and data layer segregation , statelessness , cacheability  Uniform Interface : Overall system architecture is simplified and the visibility of interactions is improved Tradeoff : Degrades efficiency since Information is transferred in a standardised form rather than one which is specific to application's needs
  • 4. a. Uniform Interface  Four interface constraints ● Identification of resources ● Manipulation of resources through representations ● Self descriptive messages ● Hypermedia as the engine of application state (HATEOAS)
  • 5. b. What is resources Another way to describe REST is ROA : Resource Oriented Architecture  Any information that can be named is a resource  A resource is a conceptual mapping to a set of entities not the entity itself. Such a mapping can change over time.  A resource can be a collection of entities too.  Every resource has a name that uniquely identifies it – the URI  Think of it like a primary key for each row in a database  REST doesn't dictate URI choice. Leaves it to the application author.
  • 6. c.What If? /getAccount /getAllAccounts /searchAccounts /createDirectory /updateGroup /updateGroupName /findGroupsByDirectory /verifyAccountEmailAddress As you move from an action oriented design towards resource oriented design, thinking of everything as nouns is one of the early challenges to overcome
  • 9. d.The Answer Fundamentally two types of resources: Collection Resource /applications /books /orders Instance Resource /applications/a1b2c3 /books/1235 /orders/abcdef Question : Guess REST equivalent for : Transaction.approve and Account.pay TransactionApproval and AccountPayment
  • 10. e.Behavior POST, GET, PUT, DELETE ≠ 1:1 Create, Read, Update, Delete
  • 11. f. PUT for Create Identifier is known by the client: PUT: Used to create a resource, or overwrite it. While you specify the resources new URL. For a new resource: PUT /questions/<new_question> HTTP/1.1 Host: www.example.com/ To overwrite an existing resource: PUT /questions/<existing_question> HTTP/1.1 Host: www.example.com/ PUT is Idempotent
  • 12. g.POST as Create  POST: Used to modify and update a resource POST /questions/<existing_question> HTTP/1.1 Host: www.example.com/ Note that the following is an error: POST /questions/<new_question> HTTP/1.1 Host: www.example.com/ If the URL is not yet created, you should not be using POST to create it while specifying the name. This should result in a 'resource not found' error because <new question> does not exist yet. You should PUT the <new question> resource on the server first. You could though do something like this to create a resources using POST: POST /applications { “name”: “Best App Ever” } Response: 201 Created Location: https://api.singh.com/applications/a1b2c3 POST NOT Idempotent -> x++ vs. x=4
  • 13. 4.a. Example/case Studies  Fine grained CRUD resources Vs Coarse Grained resources: Like Operation on blog post (“/posts/{post_id}/likes”) Comment Operation on blog post (“/posts/{post_id}/comments”) vs The single coarse grained resource “Post”(/posts/{post_id}” for “liking” or “commenting”
  • 14. 4.b. Example/case Studies  Change the Address: We can update “Customer” address via “Customers/001/Address/KA001/” or “Address/KA001/” VS Design the API around the resources that are based on the business processes and domain events . To update an existing bank customer’s address, a POST request can be made to “ChangeOfAddress” resource. Very important to distinguish between resources in REST API and domain entities in a domain driven design.
  • 15. 4.c HATEOAS  HATEOAS=Hypermedia As The Engine Of Application State Path is the hierarchical and the query is the non-hierarchical part of the URIs. ! Magic awesome sauce to improve REST! According to the HATEOAS constraint your client has to follow hyperlinks sent by the service. Those hyperlinks must be annotated with metadata regarding the semantics of them
  • 16. HATEOAS constrain  A REST client enters a REST application through a simple fixed URL. All future actions the client may take are discovered within resource representations returned from the server.  E.g: Request GET /account/12345 HTTP/1.1 Host: somebank.org Accept: application/xml Response: HTTP/1.1 200 OK Content-Type: application/xml Content-Length: ... <?xml version="1.0"?> <account> <account_number>12345</account_number> <balance currency="usd">100.00</balance> <link rel="deposit" href="https://somebank.org/account/12345/deposit" /> <link rel="withdraw" href="https://somebank.org/account/12345/withdraw" /> <link rel="transfer" href="https://somebank.org/account/12345/transfer" /> <link rel="close" href="https://somebank.org/account/12345/close" /> </account> Later Response: HTTP/1.1 200 OK Content-Type: application/xml Content-Length: ... <?xml version="1.0"?> <account> <account_number>12345</account_number> <balance currency="usd">-25.00</balance> <link rel="deposit" href="https://somebank.org/account/12345/deposit" /> </account>
  • 23. Worked examples How to GET a Cup of Coffee by Jim Webber, Savas Parastatidis & Ian Robinson Oct 02, 2008 http://www.infoq.com/articles/webber-rest-workflow