SlideShare ist ein Scribd-Unternehmen logo
1 von 64
Downloaden Sie, um offline zu lesen
THE HYPERMEDIA API
      Ben Longden / @blongden
WHO ARE YOU?
 SOFTWARE ENGINEER & MANAGER
Inviqa, Session Digital, Sensio Labs UK
Twitter: blongden
GitHub: blongden
Email: ben@nocarrier.co.uk
ARCHITECTURAL STYLES
RPC
           http://.../create_account.php?
          email_addr=user@example.com&
passwd_hash=2ab548fae3162ccfa1a2d41a55557a92&
               user_name=CrunchAll
RICHARDSON MATURITY
      LEVEL 0
THE SWAMP OF POX
    PLAIN OLD XML
       (OR JSON)
<user>
    <emailaddr>user@example.com</emailaddr>
    <username>CrunchAll</username>
</user>
WS-*
SOAP
RICHARDSON MATURITY
       LEVEL 1
IDENTIFICATION OF
   RESOURCES
     PRETTY URLS
NO VERBS
FIND THE NOUNS
Users can create messages that are visible to other users who
                       follow them.
CRAFT URLS FOR YOUR
    RESOURCES
       http://.../users/{name}
       http://.../messages/{id}
SUBSETS OF DATA
   http://.../users/blongden/messages
HTTP AS A TUNNEL
METHODS
METADATA
PAYLOAD
HTTP IS SUCCESSFUL
AUTHENTICATION, CACHE, CONTENT
         NEGOTIATION
RICHARDSON MATURITY
      LEVEL 2
 USE THE VERBS THAT HTTP PROVIDES
          GET POST PUT DELETE
         OPTIONS TRACE HEAD CONNECT PATCH
SAFE ACTIONS
   HEAD & GET
IDEMPOTENT ACTIONS
   HEAD, GET, PUT, DELETE
        OPTIONS, TRACE
IDENTIFY STATES
      LIST USERS, LIST A SINGLE USER
  LIST MESSAGES, LIST A SINGLE MESSAGE
      CREATE/UPDATE/DELETE A USER
         FOLLOW/UNFOLLOW A USER
GET /users/blongden/messages HTTP/1.1
Host: example.com
POST /users/blongden/messages HTTP/1.1
Host: example.com
PUT /users/blongden/messages/1 HTTP/1.1
Host: example.com
DELETE /users/blongden/messages/1 HTTP/1.1
Host: example.com
RICHARDSON MATURITY
    MODEL LEVEL 3
      HYPERMEDIA
HYPERMEDIA
 Hypermedia is used as a logical extension of the term
hypertext in which graphics, audio, video, plain text and
 hyperlinks intertwine to create a generally non-linear
                medium of information.
HYPERMEDIA
AFFORDANCES
[LE] EMBEDDED LINKS
<img src='http://example.com/logo' />
[LO] OUTBOUND LINKS
<a href='http://example.com/search' title='view search page'>
     Search
</a>
[LT] TEMPLATED QUERIES
 <form method='get'>...</form>
[LN] NON-IDEMPOTENT
      UPDATES
<form method='post'>...</form>
[LI] IDEMPOTENT
    UPDATES
SUPPORT FOR PUT AND DELETE
REGISTERED MEDIA TYPES
HAL
HYPERTEXT APPLICATION LANGUAGE
"_links": {
    "next":   { "href": "/orders?page=2" },
    "self":   { "href": "/orders" }
},
"_embedded": { "order": [
    "_links": {
        "customer": {
            "href": "/customer/bob",
            "title": "Bob Jones <bob@jones.com>"
        },
        "self": { "href": "/orders/123" }
    },
    "currency": "USD", "total": 30
]}
<?xml version="1.0"?>
<resource href="/orders">
  <link rel="next" href="/orders?page=2"/>
  <link rel="search" href="/orders?id={order_id}"/>
  <resource rel="order" href="/orders/123">
    <link rel="customer" href="/customer/bob" title="Bob Jones <bob@j
ones.com>"/>
    <total>30</total>
    <currency>USD</currency>
  </resource>
</resource>
<?php
$hal = new NocarrierHal('/orders');
$hal->addLink('next', '/orders?page=2');
$hal->addLink('search', '/orders?id={order_id}');

$resource = new NocarrierHal(
    '/orders/123',
    array(
        'total' => 30.00,
        'currency' => 'GBP',
    )
);

$resource->addLink('customer', '/customer/bob', 'Bob Jones <bob@jones
.com>');
$hal->addResource('order', $resource);
echo $hal->asXml();
echo $hal->asJson();
LINK RELATIONS
SHORT SYNTAX
"STYLESHEET", "PROFILE"
MICROFORMATS
  registered link relations
IANA
registered link relations
CUSTOM LINK RELATIONS
      http://.../rels/message
DESIGNING A
HYPERMEDIA TYPE
XML OR JSON?
  HTML? YAML?
JSON
UBIQUITOUS AND EASY TO PARSE
        RIGID STRUCTURE
XML
UBIQUITOUS BUT HARDER TO PARSE
           EVOLVABLE
{
    "name": "Ben",
    "phone": "07777000000"
}
{
    "name": "Ben",
    "phone": [ "07777000000", "07777000001" ]
}
<?xml version="1.0"?>
<contact>
    <name>Ben</name>
    <phone>07777000000</phone>
</contact>
<?xml version="1.0"?>
<contact>
    <name>Ben</name>
    <phone>07777000000</phone>
    <phone>07777000001</phone>
</contact>
CONSIDER H-FACTORS
DO YOU NEED TO EXTEND AN EXISTING
            FORMAT?
WHY USE A REGISTERED
       TYPE?
EXISTING TOOLS
INTEROPERABILITY
THE 'CHATTY API'
   PROBLEM
ZOOM
THE HYPERTEXT CACHE PATTERN
http://.../users/blongden?zoom=messages
{
    "_links": {
      "self": { href: "http://.../users/blongden" },
      "messages": { href: "http://.../users/blongden/messages" }
    }
    "_embedded": {
      "messages": { ... }
    }
}
COMMON INTERFACE
THANK YOU.
 http://joind.in/8048
The hypermedia api
The hypermedia api

Weitere ähnliche Inhalte

Andere mochten auch

Hypermedia in API Design: Enterprise as an Early Adopter
Hypermedia in API Design: Enterprise as an Early AdopterHypermedia in API Design: Enterprise as an Early Adopter
Hypermedia in API Design: Enterprise as an Early AdopterApigee | Google Cloud
 
Sull’adattamento dell’individuo al cambiamento - Elisei
Sull’adattamento dell’individuo al cambiamento - EliseiSull’adattamento dell’individuo al cambiamento - Elisei
Sull’adattamento dell’individuo al cambiamento - EliseiCAF CIA
 
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
 
Vota en blanco mi hermana ( o )
Vota  en  blanco  mi  hermana ( o )Vota  en  blanco  mi  hermana ( o )
Vota en blanco mi hermana ( o )Fred Rojas Krrillo
 
Programa pisa oportunidad para mejorar la educación mundial
Programa pisa oportunidad para mejorar la educación mundialPrograma pisa oportunidad para mejorar la educación mundial
Programa pisa oportunidad para mejorar la educación mundialospinacampojorge
 
AMES Awards 2014 - Few Selections
AMES Awards 2014 - Few SelectionsAMES Awards 2014 - Few Selections
AMES Awards 2014 - Few SelectionsLBSL
 
Album souvenir - Open Véronic DiCaire 2012
Album souvenir - Open Véronic DiCaire 2012Album souvenir - Open Véronic DiCaire 2012
Album souvenir - Open Véronic DiCaire 2012FondationLCc
 
Why should i care about hypermedia
Why should i care about hypermediaWhy should i care about hypermedia
Why should i care about hypermediaNordic APIs
 
Markenmanagement bei Zahnarztpraxen
Markenmanagement bei ZahnarztpraxenMarkenmanagement bei Zahnarztpraxen
Markenmanagement bei ZahnarztpraxenOliver Winter
 
Api anti patterns
Api anti patternsApi anti patterns
Api anti patternsMike Pearce
 
Deep-dive into Microservice Outer Architecture
Deep-dive into Microservice Outer ArchitectureDeep-dive into Microservice Outer Architecture
Deep-dive into Microservice Outer ArchitectureWSO2
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Yevgeniy Brikman
 
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Hypermedia: The Missing Element to Building Adaptable Web APIs in RailsHypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Hypermedia: The Missing Element to Building Adaptable Web APIs in RailsToru Kawamura
 
Die Eventmacher 2008 Vorabversion
Die Eventmacher 2008 VorabversionDie Eventmacher 2008 Vorabversion
Die Eventmacher 2008 Vorabversionel_presidente82
 

Andere mochten auch (18)

Hypermedia in API Design: Enterprise as an Early Adopter
Hypermedia in API Design: Enterprise as an Early AdopterHypermedia in API Design: Enterprise as an Early Adopter
Hypermedia in API Design: Enterprise as an Early Adopter
 
Sull’adattamento dell’individuo al cambiamento - Elisei
Sull’adattamento dell’individuo al cambiamento - EliseiSull’adattamento dell’individuo al cambiamento - Elisei
Sull’adattamento dell’individuo al cambiamento - Elisei
 
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?
 
PAT 11-12 - Presentación da 1ª reunión cos grupos de 1º dos graos (marzo)
PAT 11-12 - Presentación da 1ª reunión cos grupos de 1º dos graos (marzo)PAT 11-12 - Presentación da 1ª reunión cos grupos de 1º dos graos (marzo)
PAT 11-12 - Presentación da 1ª reunión cos grupos de 1º dos graos (marzo)
 
Titi
TitiTiti
Titi
 
Revista 2008
Revista 2008Revista 2008
Revista 2008
 
Vota en blanco mi hermana ( o )
Vota  en  blanco  mi  hermana ( o )Vota  en  blanco  mi  hermana ( o )
Vota en blanco mi hermana ( o )
 
Programa pisa oportunidad para mejorar la educación mundial
Programa pisa oportunidad para mejorar la educación mundialPrograma pisa oportunidad para mejorar la educación mundial
Programa pisa oportunidad para mejorar la educación mundial
 
AMES Awards 2014 - Few Selections
AMES Awards 2014 - Few SelectionsAMES Awards 2014 - Few Selections
AMES Awards 2014 - Few Selections
 
Album souvenir - Open Véronic DiCaire 2012
Album souvenir - Open Véronic DiCaire 2012Album souvenir - Open Véronic DiCaire 2012
Album souvenir - Open Véronic DiCaire 2012
 
Why should i care about hypermedia
Why should i care about hypermediaWhy should i care about hypermedia
Why should i care about hypermedia
 
Markenmanagement bei Zahnarztpraxen
Markenmanagement bei ZahnarztpraxenMarkenmanagement bei Zahnarztpraxen
Markenmanagement bei Zahnarztpraxen
 
Api anti patterns
Api anti patternsApi anti patterns
Api anti patterns
 
Javantura v4 - True RESTful Java Web Services with JSON API and Katharsis - M...
Javantura v4 - True RESTful Java Web Services with JSON API and Katharsis - M...Javantura v4 - True RESTful Java Web Services with JSON API and Katharsis - M...
Javantura v4 - True RESTful Java Web Services with JSON API and Katharsis - M...
 
Deep-dive into Microservice Outer Architecture
Deep-dive into Microservice Outer ArchitectureDeep-dive into Microservice Outer Architecture
Deep-dive into Microservice Outer Architecture
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Hypermedia: The Missing Element to Building Adaptable Web APIs in RailsHypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
 
Die Eventmacher 2008 Vorabversion
Die Eventmacher 2008 VorabversionDie Eventmacher 2008 Vorabversion
Die Eventmacher 2008 Vorabversion
 

Ähnlich wie The hypermedia api

Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsOpening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsBastian Hofmann
 
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...Doris Chen
 
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011Alessandro Nadalin
 
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés RianchoCODE BLUE
 
How to get along with HATEOAS without letting the bad guys steal your lunch?
How to get along with HATEOAS without letting the bad guys steal your lunch?How to get along with HATEOAS without letting the bad guys steal your lunch?
How to get along with HATEOAS without letting the bad guys steal your lunch?Graham Charters
 
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...Grégory Engels
 
Getting Stuff In And Out Of Buzz (1)
Getting  Stuff In And Out Of  Buzz (1)Getting  Stuff In And Out Of  Buzz (1)
Getting Stuff In And Out Of Buzz (1)Paul Kinlan
 
Universal DDoS Mitigation Bypass
Universal DDoS Mitigation BypassUniversal DDoS Mitigation Bypass
Universal DDoS Mitigation BypassAlbert Hui
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring BootJoshua Long
 
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
 
rest-api-basics.pptx
rest-api-basics.pptxrest-api-basics.pptx
rest-api-basics.pptxFikiRieza2
 
GOTO Copenhagen - Radical Agility with Autonomous Teams and Microservices in ...
GOTO Copenhagen - Radical Agility with Autonomous Teams and Microservices in ...GOTO Copenhagen - Radical Agility with Autonomous Teams and Microservices in ...
GOTO Copenhagen - Radical Agility with Autonomous Teams and Microservices in ...Jan Löffler
 
SAP integration sample payloads for Azure Logic Apps
SAP integration sample payloads for Azure Logic AppsSAP integration sample payloads for Azure Logic Apps
SAP integration sample payloads for Azure Logic AppsDavid Burg
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesciklum_ods
 

Ähnlich wie The hypermedia api (20)

CSG 2012
CSG 2012CSG 2012
CSG 2012
 
How RESTful Is Your REST?
How RESTful Is Your REST?How RESTful Is Your REST?
How RESTful Is Your REST?
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsOpening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands
 
Bcs 053 solved assignment 2014-15
Bcs 053 solved assignment 2014-15Bcs 053 solved assignment 2014-15
Bcs 053 solved assignment 2014-15
 
Microformats
MicroformatsMicroformats
Microformats
 
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...
 
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
 
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
 
Modified REST Presentation
Modified REST PresentationModified REST Presentation
Modified REST Presentation
 
Design Hypermedia APIs
Design Hypermedia APIsDesign Hypermedia APIs
Design Hypermedia APIs
 
How to get along with HATEOAS without letting the bad guys steal your lunch?
How to get along with HATEOAS without letting the bad guys steal your lunch?How to get along with HATEOAS without letting the bad guys steal your lunch?
How to get along with HATEOAS without letting the bad guys steal your lunch?
 
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...
 
Getting Stuff In And Out Of Buzz (1)
Getting  Stuff In And Out Of  Buzz (1)Getting  Stuff In And Out Of  Buzz (1)
Getting Stuff In And Out Of Buzz (1)
 
Universal DDoS Mitigation Bypass
Universal DDoS Mitigation BypassUniversal DDoS Mitigation Bypass
Universal DDoS Mitigation Bypass
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
 
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-api-basics.pptx
rest-api-basics.pptxrest-api-basics.pptx
rest-api-basics.pptx
 
GOTO Copenhagen - Radical Agility with Autonomous Teams and Microservices in ...
GOTO Copenhagen - Radical Agility with Autonomous Teams and Microservices in ...GOTO Copenhagen - Radical Agility with Autonomous Teams and Microservices in ...
GOTO Copenhagen - Radical Agility with Autonomous Teams and Microservices in ...
 
SAP integration sample payloads for Azure Logic Apps
SAP integration sample payloads for Azure Logic AppsSAP integration sample payloads for Azure Logic Apps
SAP integration sample payloads for Azure Logic Apps
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 

The hypermedia api