SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
Hypermedia API
      Pavel Mitin
   2012 Anadea Inc.
Why does it matter
API,   API,   API,   API,   API,   API,   API,   API,   API,   API,
API,   API,   API,   API,   API,   API,   API,   API,   API,   API,
API,   API,   API,   API,   API,   API,   API,   API,   API,   API,
API,   API,   API,   API,   API,   API,   API,   API,   API,   API,
API,   API,   API,   API,   API,   API,   API,   API,   API,   API,
API,   API,   API,   API,   API,   API,   API,   API,   API,   API,
API,   API,   API,   API,   API,   API,   API,   API,   API,   API,
API,   API,   API,   API,   API,   API,   API,   API,   API,   API,
API,   API,   API,   API,   API,   API,   API,   API,   API,   API,
API,   API,   API,   API,   API,   API,   API,   API,   API,   API..
Problem
Existing APIs are often:
● unclear
● fragile
● not extendable
Possible solution
“WWW is fundamentally a distributed
hypermedia application.” Richard Taylor
Possible solution
“WWW is fundamentally a distributed
hypermedia application.” Richard Taylor

And the application works!
How WEB works
Browsers know how to:
● deal with media types (text/html,
  image/png...)
● navigate via links and submit forms
How WEB works
Browsers know how to:
● deal with media types (text/html,
  image/png...)
● navigate via links and submit forms

Let’s follow the example!!!
Example -- eBay API
GET .../item/180881974947
{
  "name" : "Monty Python and the Holy Grail white rabbit big pointy teeth",
  "id" : "180881974947",
  ...
  "links" : [
    { “type: "application/vnd.ebay.item",
      "rel": "Add item to watchlist",
      "href": "https://.../user/12345678/watchlist/180881974947"},
    { // and a whole lot of other operations ]}


Source: http://www.slideshare.net/josdirksen/rest-from-get-to-hateoas
Media types
●   application/atom+xml
●   image/jpeg
●   audio/vnd.wave
●   application/vnd.buyfolio.listing+json
Hypermedia links
● Embed Links
  ○ <img src="..." />
  ○ <x:include href"..."   />
Hypermedia links
● Embed Links
  ○ <img src="..." />
  ○ <x:include href"..." />
● Outbound Links
  ○ <a href="..." target="_blank">...</a>
Hypermedia links
● Embed Links
  ○ <img src="..." />
  ○ <x:include href"..." />
● Outbound Links
  ○ <a href="..." target="_blank">...</a>
● Templated Links
  ○ <form method="get" action="...">...</form>
  ○ <link href="http://www.example.org/?search={search}"   />
Hypermedia links
● Embed Links
   ○ <img src="..." />
   ○ <x:include href"..." />
● Outbound Links
   ○ <a href="..." target="_blank">...</a>
● Templated Links
   ○ <form method="get" action="...">...</form>
   ○ <link href="http://www.example.org/?search={search}"   />
● Idempotent Links
   ○ <link rel="edit" href="http://example.org/edit/1"/>
   ○ (new XMLHttpRequest()).open("DELETE", "/tags/"+id);
Hypermedia links
● Embed Links
   ○ <img src="..." />
   ○ <x:include href"..." />
● Outbound Links
   ○ <a href="..." target="_blank">...</a>
● Templated Links
   ○ <form method="get" action="...">...</form>
   ○ <link href="http://www.example.org/?search={search}"   />
● Idempotent Links
   ○ <link rel="edit" href="http://example.org/edit/1"/>
   ○ (new XMLHttpRequest()).open("DELETE", "/tags/"+id);
● Non-Idempotent Links
   ○ <form method="post" action="...">...</form>
Hypermedia Design Elements
1.   Base Format
2.   State Transfer
3.   Domain Style
4.   Application Flow
Base format
1.   JSON
2.   XML
3.   XHTML/HTML5
4.   Others (YAML, CSV, Markdown, Protocol
     Buffers)
State Transfer (client-initiated)
1. None (i.e. read-only)
2. Predefined (via external documentation)
3. Ad-Hoc (via in-message hypermedia
   controls)
Domain Style
1. Specific
2. General
3. Agnostic
Domain Style
<!-- domain-specific design -->
<story>
  <id>...</id>
  <estimate>...</estimate>
</story>
Domain Style
/* domain-general design */
{
    "collection" : {
        "items" : {
            { "key" : "id",
              "value" : "12345" }
        ...
Domain Style
<!-- domain-agnostic design -->
<ul class="order">
  <li class="id">...</li>
  <ul class="shipping-address">
    <li class="street-address">...</li>
    ...
I haven't mentioned
● Resources
● Http verbs
● Http status codes
Surfing your API




Source: Building Hypermedia APIs with HTML5 and Node by Mike Amundsen
XHTML as a base format
●   Native support for links and forms
●   Ubiquitous client (browser)
●   XHTML is XML
●   HAML :)
Extending vs versioning
Reasons for a new version:
● A change that alters the meaning or
  functionality of an existing feature or
  element
● A change that causes an existing element to
  disappear or become disallowed
● A change that converts an optional element
  into a required element
Javascript RIA
;)
Criticism
Usually compared to "traditional" REST API
Criticism
● Overcomplicated client
● Extra traffic
Rails and HATEOAS
● lack of abstractions for hypermedia controls
Rails and HATEOAS
● lack of abstractions for hypermedia controls
● confusing terms:
  ○ #resource are two different resources
Rails and HATEOAS
● lack of abstractions for hypermedia controls
● confusing terms:
  ○ #resource are three different resources
● OPTIONS verb
Rails and HATEOAS
● lack of abstractions for hypermedia controls
● confusing terms:
  ○ #resource are three different resources
● OPTIONS verb
● PATCH verb
Rails and HATEOAS
● lack of abstractions for hypermedia controls
● confusing terms:
  ○ #resource are three different resources
● OPTIONS verb
● PATCH verb
● PUT verb
  ○ upsert
  ○ whole resource state
Rails and HATEOAS
● lack of abstractions for hypermedia controls
● confusing terms:
  ○ #resource are three different resources
● OPTIONS verb
● PATCH verb
● PUT verb
  ○ upsert
  ○ whole resource state
● custom media types require custom code
Richardson Maturity Model




Source: http://martinfowler.com/articles/richardsonMaturityModel.html
Books

Weitere ähnliche Inhalte

Andere mochten auch

How to become a Product Samurai - Chris Lukassen
How to become a Product Samurai - Chris LukassenHow to become a Product Samurai - Chris Lukassen
How to become a Product Samurai - Chris Lukassen
Avisi B.V.
 
SOA Pattern : Legacy Wrappers
SOA Pattern : Legacy Wrappers SOA Pattern : Legacy Wrappers
SOA Pattern : Legacy Wrappers
WSO2
 

Andere mochten auch (18)

HCLT Whitepaper: Legacy Modernization
HCLT Whitepaper: Legacy Modernization HCLT Whitepaper: Legacy Modernization
HCLT Whitepaper: Legacy Modernization
 
BPM for SOA+ESB+API and cloud
BPM for SOA+ESB+API and cloud BPM for SOA+ESB+API and cloud
BPM for SOA+ESB+API and cloud
 
How to become a Product Samurai - Chris Lukassen
How to become a Product Samurai - Chris LukassenHow to become a Product Samurai - Chris Lukassen
How to become a Product Samurai - Chris Lukassen
 
Apiworld
ApiworldApiworld
Apiworld
 
Legacy to industry leader: a modernization case study
Legacy to industry leader: a modernization case studyLegacy to industry leader: a modernization case study
Legacy to industry leader: a modernization case study
 
Twilio Signal 2016 API Architecture
Twilio Signal 2016 API ArchitectureTwilio Signal 2016 API Architecture
Twilio Signal 2016 API Architecture
 
LeaseWeb API Architecture @ APINL Meetup
LeaseWeb API Architecture @ APINL MeetupLeaseWeb API Architecture @ APINL Meetup
LeaseWeb API Architecture @ APINL Meetup
 
SOA Pattern : Legacy Wrappers
SOA Pattern : Legacy Wrappers SOA Pattern : Legacy Wrappers
SOA Pattern : Legacy Wrappers
 
Updating Legacy Systems: Making the Financial Case for a Modernization Project
Updating Legacy Systems: Making the Financial Case for a Modernization Project Updating Legacy Systems: Making the Financial Case for a Modernization Project
Updating Legacy Systems: Making the Financial Case for a Modernization Project
 
IO State In Distributed API Architecture
IO State In Distributed API ArchitectureIO State In Distributed API Architecture
IO State In Distributed API Architecture
 
Api Abstraction & Api Chaining
Api Abstraction & Api ChainingApi Abstraction & Api Chaining
Api Abstraction & Api Chaining
 
Legacy modernization, cloud orchestration, api publishing
Legacy modernization, cloud orchestration, api publishingLegacy modernization, cloud orchestration, api publishing
Legacy modernization, cloud orchestration, api publishing
 
Building a Modern Microservices Architecture at Gilt: The Essentials
Building a Modern Microservices Architecture at Gilt: The EssentialsBuilding a Modern Microservices Architecture at Gilt: The Essentials
Building a Modern Microservices Architecture at Gilt: The Essentials
 
ITANA 2016: API Architecture and Implementation
ITANA 2016: API Architecture and ImplementationITANA 2016: API Architecture and Implementation
ITANA 2016: API Architecture and Implementation
 
Building an API Platform for Digital Transformation
Building an API Platform for Digital TransformationBuilding an API Platform for Digital Transformation
Building an API Platform for Digital Transformation
 
Dc meetup-pure-api-led-connectivity-16x9
Dc meetup-pure-api-led-connectivity-16x9Dc meetup-pure-api-led-connectivity-16x9
Dc meetup-pure-api-led-connectivity-16x9
 
From a Monolithic to a Distributed API Architecture
 at Eventbrite - Presente...
From a Monolithic to a Distributed API Architecture
 at Eventbrite - Presente...From a Monolithic to a Distributed API Architecture
 at Eventbrite - Presente...
From a Monolithic to a Distributed API Architecture
 at Eventbrite - Presente...
 
API Architecture
API ArchitectureAPI Architecture
API Architecture
 

Ähnlich wie Hypermedia api (HATEOAS)

The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIsThe liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
Jorge Ferrer
 
Making Sense of Hypermedia APIs – Hype or Reality?
Making Sense of Hypermedia APIs – Hype or Reality?Making Sense of Hypermedia APIs – Hype or Reality?
Making Sense of Hypermedia APIs – Hype or Reality?
Akana
 
A Practical Guide to Hypermedia APIs
A Practical Guide to Hypermedia APIsA Practical Guide to Hypermedia APIs
A Practical Guide to Hypermedia APIs
SmartLogic
 
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
Gustaf Nilsson Kotte
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
Pamela Fox
 
A Practical Guide To Hypermedia APIs - Philly.rb
A Practical Guide To Hypermedia APIs - Philly.rbA Practical Guide To Hypermedia APIs - Philly.rb
A Practical Guide To Hypermedia APIs - Philly.rb
SmartLogic
 

Ähnlich wie Hypermedia api (HATEOAS) (20)

The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIsThe liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
 
Making Sense of Hypermedia APIs – Hype or Reality?
Making Sense of Hypermedia APIs – Hype or Reality?Making Sense of Hypermedia APIs – Hype or Reality?
Making Sense of Hypermedia APIs – Hype or Reality?
 
Yahoo for the Masses
Yahoo for the MassesYahoo for the Masses
Yahoo for the Masses
 
Website Optimization -SEO - Step By Step
Website Optimization -SEO - Step By StepWebsite Optimization -SEO - Step By Step
Website Optimization -SEO - Step By Step
 
Great APIs - Future of Your Progress App
Great APIs - Future of Your Progress AppGreat APIs - Future of Your Progress App
Great APIs - Future of Your Progress App
 
API Discovery: Visibility, Usability, and Advocacy
API Discovery: Visibility, Usability, and AdvocacyAPI Discovery: Visibility, Usability, and Advocacy
API Discovery: Visibility, Usability, and Advocacy
 
A Practical Guide to Hypermedia APIs
A Practical Guide to Hypermedia APIsA Practical Guide to Hypermedia APIs
A Practical Guide to Hypermedia APIs
 
01 web 2.0 - more than a pretty face for soa
01   web 2.0 - more than a pretty face for soa01   web 2.0 - more than a pretty face for soa
01 web 2.0 - more than a pretty face for soa
 
API Introduction - API Management Workshop Munich from Ronnie Mitra
API Introduction - API Management Workshop Munich from Ronnie MitraAPI Introduction - API Management Workshop Munich from Ronnie Mitra
API Introduction - API Management Workshop Munich from Ronnie Mitra
 
CSI: WordPress -- Getting Into the Guts
CSI: WordPress -- Getting Into the GutsCSI: WordPress -- Getting Into the Guts
CSI: WordPress -- Getting Into the Guts
 
WordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTOWordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTO
 
Wordcamp Toronto Presentation
Wordcamp Toronto PresentationWordcamp Toronto Presentation
Wordcamp Toronto Presentation
 
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
 
On-page SEO for Drupal
On-page SEO for DrupalOn-page SEO for Drupal
On-page SEO for Drupal
 
Webcast: Pragmatic REST: The Next Generation
Webcast: Pragmatic REST: The Next GenerationWebcast: Pragmatic REST: The Next Generation
Webcast: Pragmatic REST: The Next Generation
 
The Open Web
The Open WebThe Open Web
The Open Web
 
A Practical Guide To Hypermedia APIs - Philly.rb
A Practical Guide To Hypermedia APIs - Philly.rbA Practical Guide To Hypermedia APIs - Philly.rb
A Practical Guide To Hypermedia APIs - Philly.rb
 
Api craft notes
Api craft notesApi craft notes
Api craft notes
 
API Design Tour: Digital River
API Design Tour: Digital RiverAPI Design Tour: Digital River
API Design Tour: Digital River
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Hypermedia api (HATEOAS)

  • 1. Hypermedia API Pavel Mitin 2012 Anadea Inc.
  • 2. Why does it matter API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API, API..
  • 3. Problem Existing APIs are often: ● unclear ● fragile ● not extendable
  • 4. Possible solution “WWW is fundamentally a distributed hypermedia application.” Richard Taylor
  • 5. Possible solution “WWW is fundamentally a distributed hypermedia application.” Richard Taylor And the application works!
  • 6. How WEB works Browsers know how to: ● deal with media types (text/html, image/png...) ● navigate via links and submit forms
  • 7. How WEB works Browsers know how to: ● deal with media types (text/html, image/png...) ● navigate via links and submit forms Let’s follow the example!!!
  • 8. Example -- eBay API GET .../item/180881974947 { "name" : "Monty Python and the Holy Grail white rabbit big pointy teeth", "id" : "180881974947", ... "links" : [ { “type: "application/vnd.ebay.item", "rel": "Add item to watchlist", "href": "https://.../user/12345678/watchlist/180881974947"}, { // and a whole lot of other operations ]} Source: http://www.slideshare.net/josdirksen/rest-from-get-to-hateoas
  • 9. Media types ● application/atom+xml ● image/jpeg ● audio/vnd.wave ● application/vnd.buyfolio.listing+json
  • 10. Hypermedia links ● Embed Links ○ <img src="..." /> ○ <x:include href"..." />
  • 11. Hypermedia links ● Embed Links ○ <img src="..." /> ○ <x:include href"..." /> ● Outbound Links ○ <a href="..." target="_blank">...</a>
  • 12. Hypermedia links ● Embed Links ○ <img src="..." /> ○ <x:include href"..." /> ● Outbound Links ○ <a href="..." target="_blank">...</a> ● Templated Links ○ <form method="get" action="...">...</form> ○ <link href="http://www.example.org/?search={search}" />
  • 13. Hypermedia links ● Embed Links ○ <img src="..." /> ○ <x:include href"..." /> ● Outbound Links ○ <a href="..." target="_blank">...</a> ● Templated Links ○ <form method="get" action="...">...</form> ○ <link href="http://www.example.org/?search={search}" /> ● Idempotent Links ○ <link rel="edit" href="http://example.org/edit/1"/> ○ (new XMLHttpRequest()).open("DELETE", "/tags/"+id);
  • 14. Hypermedia links ● Embed Links ○ <img src="..." /> ○ <x:include href"..." /> ● Outbound Links ○ <a href="..." target="_blank">...</a> ● Templated Links ○ <form method="get" action="...">...</form> ○ <link href="http://www.example.org/?search={search}" /> ● Idempotent Links ○ <link rel="edit" href="http://example.org/edit/1"/> ○ (new XMLHttpRequest()).open("DELETE", "/tags/"+id); ● Non-Idempotent Links ○ <form method="post" action="...">...</form>
  • 15. Hypermedia Design Elements 1. Base Format 2. State Transfer 3. Domain Style 4. Application Flow
  • 16. Base format 1. JSON 2. XML 3. XHTML/HTML5 4. Others (YAML, CSV, Markdown, Protocol Buffers)
  • 17. State Transfer (client-initiated) 1. None (i.e. read-only) 2. Predefined (via external documentation) 3. Ad-Hoc (via in-message hypermedia controls)
  • 18. Domain Style 1. Specific 2. General 3. Agnostic
  • 19. Domain Style <!-- domain-specific design --> <story> <id>...</id> <estimate>...</estimate> </story>
  • 20. Domain Style /* domain-general design */ { "collection" : { "items" : { { "key" : "id", "value" : "12345" } ...
  • 21. Domain Style <!-- domain-agnostic design --> <ul class="order"> <li class="id">...</li> <ul class="shipping-address"> <li class="street-address">...</li> ...
  • 22. I haven't mentioned ● Resources ● Http verbs ● Http status codes
  • 23. Surfing your API Source: Building Hypermedia APIs with HTML5 and Node by Mike Amundsen
  • 24. XHTML as a base format ● Native support for links and forms ● Ubiquitous client (browser) ● XHTML is XML ● HAML :)
  • 25. Extending vs versioning Reasons for a new version: ● A change that alters the meaning or functionality of an existing feature or element ● A change that causes an existing element to disappear or become disallowed ● A change that converts an optional element into a required element
  • 27. Criticism Usually compared to "traditional" REST API
  • 29. Rails and HATEOAS ● lack of abstractions for hypermedia controls
  • 30. Rails and HATEOAS ● lack of abstractions for hypermedia controls ● confusing terms: ○ #resource are two different resources
  • 31. Rails and HATEOAS ● lack of abstractions for hypermedia controls ● confusing terms: ○ #resource are three different resources ● OPTIONS verb
  • 32. Rails and HATEOAS ● lack of abstractions for hypermedia controls ● confusing terms: ○ #resource are three different resources ● OPTIONS verb ● PATCH verb
  • 33. Rails and HATEOAS ● lack of abstractions for hypermedia controls ● confusing terms: ○ #resource are three different resources ● OPTIONS verb ● PATCH verb ● PUT verb ○ upsert ○ whole resource state
  • 34. Rails and HATEOAS ● lack of abstractions for hypermedia controls ● confusing terms: ○ #resource are three different resources ● OPTIONS verb ● PATCH verb ● PUT verb ○ upsert ○ whole resource state ● custom media types require custom code
  • 35. Richardson Maturity Model Source: http://martinfowler.com/articles/richardsonMaturityModel.html
  • 36. Books