• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Hypermedia api (HATEOAS)
 

Hypermedia api (HATEOAS)

on

  • 2,945 views

 

Statistics

Views

Total Views
2,945
Views on SlideShare
2,647
Embed Views
298

Actions

Likes
2
Downloads
29
Comments
0

17 Embeds 298

http://novembermeeting.blogspot.com 231
http://novembermeeting.blogspot.ru 13
http://novembermeeting.blogspot.co.uk 12
http://novembermeeting.blogspot.com.ar 6
http://novembermeeting.blogspot.be 5
http://novembermeeting.blogspot.cz 5
http://novembermeeting.blogspot.in 5
http://novembermeeting.blogspot.de 3
http://novembermeeting.blogspot.com.es 3
http://novembermeeting.blogspot.co.nz 3
http://novembermeeting.blogspot.fr 3
http://novembermeeting.blogspot.ca 2
http://novembermeeting.blogspot.pt 2
http://www.directrss.co.il 2
http://novembermeeting.blogspot.com.br 1
http://novembermeeting.blogspot.se 1
http://novembermeeting.blogspot.co.il 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Hypermedia api (HATEOAS) Hypermedia api (HATEOAS) Presentation Transcript

    • Hypermedia API Pavel Mitin 2012 Anadea Inc.
    • Why does it matterAPI, 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..
    • ProblemExisting APIs are often:● unclear● fragile● not extendable
    • Possible solution“WWW is fundamentally a distributedhypermedia application.” Richard Taylor
    • Possible solution“WWW is fundamentally a distributedhypermedia application.” Richard TaylorAnd the application works!
    • How WEB worksBrowsers know how to:● deal with media types (text/html, image/png...)● navigate via links and submit forms
    • How WEB worksBrowsers know how to:● deal with media types (text/html, image/png...)● navigate via links and submit formsLet’s follow the example!!!
    • Example -- eBay APIGET .../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 Elements1. Base Format2. State Transfer3. Domain Style4. Application Flow
    • Base format1. JSON2. XML3. XHTML/HTML54. 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 Style1. Specific2. General3. 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 havent mentioned● Resources● Http verbs● Http status codes
    • Surfing your APISource: 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 versioningReasons 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;)
    • CriticismUsually 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 ModelSource: http://martinfowler.com/articles/richardsonMaturityModel.html
    • Books