SlideShare a Scribd company logo
1 of 24
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

Spring HATEOAS
Spring HATEOASSpring HATEOAS
Spring HATEOASYoann Buch
 
Representational State Transfer (REST)
Representational State Transfer (REST)Representational State Transfer (REST)
Representational State Transfer (REST)Abhay Ananda Shukla
 
CSS Architecture: Writing Maintainable CSS
CSS Architecture: Writing Maintainable CSSCSS Architecture: Writing Maintainable CSS
CSS Architecture: Writing Maintainable CSSAlexei Skachykhin
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - APIChetan Gadodia
 
Restful web-services
Restful web-servicesRestful web-services
Restful web-servicesrporwal
 
Approaches to machine actionable links
Approaches to machine actionable linksApproaches to machine actionable links
Approaches to machine actionable linksStephen Richard
 
Building Self Documenting HTTP APIs with CQRS
Building Self Documenting HTTP APIs with CQRSBuilding Self Documenting HTTP APIs with CQRS
Building Self Documenting HTTP APIs with CQRSDerek Comartin
 
REST-API overview / concepts
REST-API overview / conceptsREST-API overview / concepts
REST-API overview / conceptsPatrick Savalle
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful FundamentalsSuresh Madhra
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUDPrem Sanil
 
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...Codemotion
 

What's hot (20)

REST API
REST APIREST API
REST API
 
Hypermedia APIs
Hypermedia APIsHypermedia APIs
Hypermedia APIs
 
Spring HATEOAS
Spring HATEOASSpring HATEOAS
Spring HATEOAS
 
Representational State Transfer (REST)
Representational State Transfer (REST)Representational State Transfer (REST)
Representational State Transfer (REST)
 
CSS Architecture: Writing Maintainable CSS
CSS Architecture: Writing Maintainable CSSCSS Architecture: Writing Maintainable CSS
CSS Architecture: Writing Maintainable CSS
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
 
Restful web-services
Restful web-servicesRestful web-services
Restful web-services
 
Approaches to machine actionable links
Approaches to machine actionable linksApproaches to machine actionable links
Approaches to machine actionable links
 
Rest api-basic
Rest api-basicRest api-basic
Rest api-basic
 
Benefits of Hypermedia API
Benefits of Hypermedia APIBenefits of Hypermedia API
Benefits of Hypermedia API
 
Introduction to Hydra
Introduction to HydraIntroduction to Hydra
Introduction to Hydra
 
Building Self Documenting HTTP APIs with CQRS
Building Self Documenting HTTP APIs with CQRSBuilding Self Documenting HTTP APIs with CQRS
Building Self Documenting HTTP APIs with CQRS
 
REST-API overview / concepts
REST-API overview / conceptsREST-API overview / concepts
REST-API overview / concepts
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
Rest http basics
Rest http basicsRest http basics
Rest http basics
 
Standards of rest api
Standards of rest apiStandards of rest api
Standards of rest api
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful Fundamentals
 
Rest Webservice
Rest WebserviceRest Webservice
Rest Webservice
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
 

Viewers also liked

SLICP Newsletter Supplement February 2017
SLICP Newsletter Supplement February 2017SLICP Newsletter Supplement February 2017
SLICP Newsletter Supplement February 2017David Hains
 
Expansion en Bucaramanga
Expansion en BucaramangaExpansion en Bucaramanga
Expansion en Bucaramangajaideramador
 
Reto 2 - Propuesta narración digital
Reto 2 - Propuesta narración digital Reto 2 - Propuesta narración digital
Reto 2 - Propuesta narración digital Mari Rodriguez
 
The Morthwest Ordinance
The Morthwest OrdinanceThe Morthwest Ordinance
The Morthwest Ordinancereach
 
How to Successfully Work With a Recruiter
How to Successfully Work With a RecruiterHow to Successfully Work With a Recruiter
How to Successfully Work With a RecruiterElyse Turner
 
Gestión de-proyectos-informáticos
Gestión de-proyectos-informáticosGestión de-proyectos-informáticos
Gestión de-proyectos-informáticosVíctor Gerardo
 
Microalgae cultivation in different pH, Temperature and Media
Microalgae cultivation in different pH, Temperature and MediaMicroalgae cultivation in different pH, Temperature and Media
Microalgae cultivation in different pH, Temperature and MediaBir Bahadur Thapa
 
0004. blago crvene planine
0004. blago crvene planine0004. blago crvene planine
0004. blago crvene planinezoran radovic
 
CompTIA Perks
CompTIA PerksCompTIA Perks
CompTIA PerksCompTIA
 
Nombres de dominio de internet
Nombres de dominio de internetNombres de dominio de internet
Nombres de dominio de internetJoha Paguay
 
Office365 education transformation collaboration using office 365
Office365 education transformation collaboration using office 365Office365 education transformation collaboration using office 365
Office365 education transformation collaboration using office 365Sachin. Jung
 

Viewers also liked (16)

Mamiferos
MamiferosMamiferos
Mamiferos
 
CV Zubair Aslam
CV Zubair AslamCV Zubair Aslam
CV Zubair Aslam
 
SLICP Newsletter Supplement February 2017
SLICP Newsletter Supplement February 2017SLICP Newsletter Supplement February 2017
SLICP Newsletter Supplement February 2017
 
Portfolio
PortfolioPortfolio
Portfolio
 
Expansion en Bucaramanga
Expansion en BucaramangaExpansion en Bucaramanga
Expansion en Bucaramanga
 
Reto 2 - Propuesta narración digital
Reto 2 - Propuesta narración digital Reto 2 - Propuesta narración digital
Reto 2 - Propuesta narración digital
 
The Morthwest Ordinance
The Morthwest OrdinanceThe Morthwest Ordinance
The Morthwest Ordinance
 
Kb 2
Kb 2Kb 2
Kb 2
 
How to Successfully Work With a Recruiter
How to Successfully Work With a RecruiterHow to Successfully Work With a Recruiter
How to Successfully Work With a Recruiter
 
Gestión de-proyectos-informáticos
Gestión de-proyectos-informáticosGestión de-proyectos-informáticos
Gestión de-proyectos-informáticos
 
CV
CVCV
CV
 
Microalgae cultivation in different pH, Temperature and Media
Microalgae cultivation in different pH, Temperature and MediaMicroalgae cultivation in different pH, Temperature and Media
Microalgae cultivation in different pH, Temperature and Media
 
0004. blago crvene planine
0004. blago crvene planine0004. blago crvene planine
0004. blago crvene planine
 
CompTIA Perks
CompTIA PerksCompTIA Perks
CompTIA Perks
 
Nombres de dominio de internet
Nombres de dominio de internetNombres de dominio de internet
Nombres de dominio de internet
 
Office365 education transformation collaboration using office 365
Office365 education transformation collaboration using office 365Office365 education transformation collaboration using office 365
Office365 education transformation collaboration using office 365
 

Similar to REST Architecture with use case and example

Rest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbookRest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbookKaty Slemon
 
Rest API Automation with REST Assured
Rest API Automation with REST AssuredRest API Automation with REST Assured
Rest API Automation with REST AssuredTO THE NEW Pvt. Ltd.
 
Building Restful Applications Using Php
Building Restful Applications Using PhpBuilding Restful Applications Using Php
Building Restful Applications Using PhpSudheer Satyanarayana
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful FundamentalsSuresh Madhra
 
Restful web services rule financial
Restful web services   rule financialRestful web services   rule financial
Restful web services rule financialRule_Financial
 
O reilly sacon2018nyc - restful api design - master - v1.0
O reilly sacon2018nyc - restful api design - master - v1.0O reilly sacon2018nyc - restful api design - master - v1.0
O reilly sacon2018nyc - restful api design - master - v1.0Tom Hofte
 
Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Gaurav Bhardwaj
 
Code-Camp-Rest-Principles
Code-Camp-Rest-PrinciplesCode-Camp-Rest-Principles
Code-Camp-Rest-PrinciplesKnoldus Inc.
 
What are restful web services?
What are restful web services?What are restful web services?
What are restful web services?Aparna Sharma
 
REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)Sascha Wenninger
 
Together Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaTogether Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaVladimir Tsukur
 

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

Rest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbookRest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbook
 
Rest API Automation with REST Assured
Rest API Automation with REST AssuredRest API Automation with REST Assured
Rest API Automation with REST Assured
 
WebApp #3 : API
WebApp #3 : APIWebApp #3 : API
WebApp #3 : API
 
Building Restful Applications Using Php
Building Restful Applications Using PhpBuilding Restful Applications Using Php
Building Restful Applications Using Php
 
Salesforce REST API
Salesforce  REST API Salesforce  REST API
Salesforce REST API
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful Fundamentals
 
Apitesting.pptx
Apitesting.pptxApitesting.pptx
Apitesting.pptx
 
Restful web services rule financial
Restful web services   rule financialRestful web services   rule financial
Restful web services rule financial
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
O reilly sacon2018nyc - restful api design - master - v1.0
O reilly sacon2018nyc - restful api design - master - v1.0O reilly sacon2018nyc - restful api design - master - v1.0
O reilly sacon2018nyc - restful api design - master - v1.0
 
Modified REST Presentation
Modified REST PresentationModified REST Presentation
Modified REST Presentation
 
Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle
 
REST full API Design
REST full API DesignREST full API Design
REST full API Design
 
Code-Camp-Rest-Principles
Code-Camp-Rest-PrinciplesCode-Camp-Rest-Principles
Code-Camp-Rest-Principles
 
What are restful web services?
What are restful web services?What are restful web services?
What are restful web services?
 
REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)
 
Together Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaTogether Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with Hypermedia
 
Web 13 | REST API
Web 13 | REST APIWeb 13 | REST API
Web 13 | REST API
 
C# REST API
C# REST APIC# REST API
C# REST API
 
Rest and Rails
Rest and RailsRest and Rails
Rest and Rails
 

Recently uploaded

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

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