SlideShare una empresa de Scribd logo
1 de 18
BENEFITS OF
HYPERMEDIA APIS
Paulo Gandra de
Sousa
pagsousa@gmail.co
m
Hypermedia is defined by the
presence of application
control information
embedded within, or as a
layer above, the presentation
of information.
Mike Amudsen
3
“
THE HYPERMEDIA
CONSTRAINT
Hipermedia as the
engine of application
state *
* HATEOAS
“
HYPERMEDIA IS THE ENGINE
Hypermedia payloads carry more
information than just the data stored
on the server. Hypermedia payloads
carry two types of vital metadata:
metadata about the data itself and
metadata about the possible options
for modifying the state of the
application at that moment.
Mike Amudsen
5
THE HYPERMEDIA
CONSTRAINT
The application is therefore an
engine that moves from one state
to the next by examining and
choosing from among the
alternative state transitions in the
current set of representations.
Roy Fielding
6
“
IMMEDIATE BENEFITS
Explorable API
Inline documentation
Simple client logic
7
“BILLBOARD” ENDPOINT
GET /api
8
200 Ok
<links>
<link rel=“…” href=“…”/>
<link rel=“…” href=“…”/>
...
</links>
LINKED DATA PRINCIPLES
1.Use URIs as names for things
2.Use HTTP URIs so that people can look up those
names.
3.When someone looks up a URI, provide useful
information, using the standards
4.Include links to other URIs so that they can
discover more things.
Tim Berners-Lee (2006)
http://www.w3.org/DesignIssues/LinkedData.html
9
EXAMPLE: CHECK BANK ACCOUNT
BALANCE
EXPLORABLE API + INLINE
DOCUMENTATION
GET /account/12345
200 OK
<?xml version="1.0"?>
<account>
<account_number>12345</account_number>
<link rel=“self” href=“/account/12345” />
<balance currency="usd">100.00</balance>
<link rel=“http://bank.org/rel/first-subscriber" href="/customer/123" />
<link rel=“http://bank.org/rel/subscribers" href="/account/12345/subscriber" />
<link rel="http://bank.org/rel/deposit" href="/account/12345/deposit" />
<link rel="http://bank.org/rel/withdraw" href="/account/12345/withdraw" />
<link rel="http://bank.org/rel/transfer" href="/account/12345/transfer" />
<link rel="http://bank.org/rel/close" href="/account/12345/close" />
</account>
10
Semantic
and
documentati
on
Use URI as
names
Explorable
CLIENT SIMPLICITY
Coupled to
implementation
res = GET /account/123
If enough-funds() then
msg = build-withdraw-
message()
url = build-url-from-
template()
POST msg @ url
Endif
Hypermedia-driven
res = GET /account/123
If res.hasLink(“withdraw”) then
msg = build-withdraw-
message()
POST msg @
res.link(“withdraw”)
Endif
11
Needs to
know URL
template
Business
logic spills
out to client
Server
handles
Business
logic
Server
manages URL
structure
VS
FLEXIBILITY & EVOLUTION
Server takes ownership of URL
Offloading content
Upgrading
12
EXAMPLE: CHECK BANK ACCOUNT
BALANCE
SERVER MODIFIES URL
STRUCTURE
GET /account/12345
200 OK
<?xml version="1.0"?>
<account>
<account_number>12345</account_number>
<link rel=“self” href=“/account/12345” />
<balance currency="usd">100.00</balance>
<link rel=“http://bank.org/rel/first-subscriber"
href=“/crm/123?role=customer" />
<link rel=“http://bank.org/rel/subscribers" href="/account/12345/subscriber" />
<link rel="http://bank.org/rel/deposit" href="/account/12345/deposit" />
<link rel="http://bank.org/rel/withdraw" href="/account/12345/withdraw" />
<link rel="http://bank.org/rel/transfer" href="/account/12345/transfer" />
<link rel="http://bank.org/rel/close" href="/account/12345/close" />
</account>
13
New URL; no
problem client just
follows it
EXAMPLE: CHECK BANK ACCOUNT
BALANCE
CONTENT OFFLOADING
GET /account/12345
200 OK
<?xml version="1.0"?>
<account>
<account_number>12345</account_number>
<link rel=“self” href=“/account/12345” />
<balance currency="usd">100.00</balance>
<link rel=“http://bank.org/rel/first-subscriber"
href=“http://one-crm.com/api/tenant/bankABC/prospect/754" />
<link rel=“http://bank.org/rel/pricing"
href=“http://bankABC.cdn.akamai.com/static/pricing" />
...
</account>
14
Content offloaded
to 3rd party
providers
EXAMPLE: CHECK BANK ACCOUNT
BALANCE
SERVER UPGRADE
GET /account/12345
200 OK
<?xml version="1.0"?>
<account>
<account_number>12345</account_number>
<link rel=“self” href=“/account/12345” />
<balance currency="usd">100.00</balance>
<link rel=“http://bank.org/rel/first-subscriber"
href=“http://one-crm.com/api/tenant/bankABC/prospect/754" />
<link rel=“http://bank.org/rel/pricing"
href=“http://bankABC.cdn.akamai.com/static/pricing" />
<link rel="http://bank.org/rel/deposit"
href="/account/12345/deposit"
type=“application/vnd.bankABC.deposit.v2+xml,
application/vnd.bankABC.deposit+xml” />
...
</account> 15
New relationship;
only V2 clients will
know it
New media type
accepted; only V2
clients will know it
16
CLOSINGS
1. Adhere to the
hypermedia constraint
2. Aim for a “billboard”
API
3. Decouple client and
server
REFERENCES
Jørn Wildt (2013) Selling the benefits of hypermedia APIs.
http://soabits.blogspot.no/2013/12/selling-benefits-
of-hypermedia.html
David (2012) Getting hyper about hypermedia APIs.
https://signalvnoise.com/posts/3373-getting-hyper-
about-hypermedia-apis
“Architectural Styles and the Design of Network-based
Software Architectures”, PhD Thesis (2000), Roy Thomas
Fielding.
http://www.ics.uci.edu/~fielding/pubs/dissertation/top.
htm
Leonard Richardson, Mike Amundsen, RESTful web APIs.
O’Reily Media. ISBN: 1449358063

Más contenido relacionado

La actualidad más candente

Google Cloud Platform
Google Cloud PlatformGoogle Cloud Platform
Google Cloud Platform
VMware Tanzu
 

La actualidad más candente (20)

AWS-Data-Migration-module3
AWS-Data-Migration-module3AWS-Data-Migration-module3
AWS-Data-Migration-module3
 
Deep Dive on AWS Migration Hub - AWS Online Tech Talks
Deep Dive on AWS Migration Hub - AWS Online Tech TalksDeep Dive on AWS Migration Hub - AWS Online Tech Talks
Deep Dive on AWS Migration Hub - AWS Online Tech Talks
 
Introduction to Azure Functions
Introduction to Azure FunctionsIntroduction to Azure Functions
Introduction to Azure Functions
 
Google Cloud Platform
Google Cloud PlatformGoogle Cloud Platform
Google Cloud Platform
 
Architecture: Microservices
Architecture: MicroservicesArchitecture: Microservices
Architecture: Microservices
 
Presentation about servers
Presentation about serversPresentation about servers
Presentation about servers
 
Serverless Architectures.pdf
Serverless Architectures.pdfServerless Architectures.pdf
Serverless Architectures.pdf
 
Web server
Web serverWeb server
Web server
 
Introduction to Azure
Introduction to AzureIntroduction to Azure
Introduction to Azure
 
AWS Amplify
AWS AmplifyAWS Amplify
AWS Amplify
 
AWS Connectivity, VPC Design and Security Pro Tips
AWS Connectivity, VPC Design and Security Pro TipsAWS Connectivity, VPC Design and Security Pro Tips
AWS Connectivity, VPC Design and Security Pro Tips
 
Introduction to Cloud Computing
Introduction to Cloud ComputingIntroduction to Cloud Computing
Introduction to Cloud Computing
 
Hybrid Cloud on AWS
Hybrid Cloud on AWSHybrid Cloud on AWS
Hybrid Cloud on AWS
 
AWS as a Data Platform
AWS as a Data PlatformAWS as a Data Platform
AWS as a Data Platform
 
AWS Simple Storage Service (s3)
AWS Simple Storage Service (s3) AWS Simple Storage Service (s3)
AWS Simple Storage Service (s3)
 
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
 
AWS IAM Tutorial | Identity And Access Management (IAM) | AWS Training Videos...
AWS IAM Tutorial | Identity And Access Management (IAM) | AWS Training Videos...AWS IAM Tutorial | Identity And Access Management (IAM) | AWS Training Videos...
AWS IAM Tutorial | Identity And Access Management (IAM) | AWS Training Videos...
 
Introduction to Serverless
Introduction to ServerlessIntroduction to Serverless
Introduction to Serverless
 
AWS networking fundamentals
AWS networking fundamentalsAWS networking fundamentals
AWS networking fundamentals
 
Amazon Route 53 - Webinar Presentation 9.16.2015
Amazon Route 53 - Webinar Presentation 9.16.2015Amazon Route 53 - Webinar Presentation 9.16.2015
Amazon Route 53 - Webinar Presentation 9.16.2015
 

Destacado

Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)
Paulo Gandra de Sousa
 

Destacado (15)

Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)
 
Enterprise Integration Patterns
Enterprise Integration PatternsEnterprise Integration Patterns
Enterprise Integration Patterns
 
PoEAA by Example
PoEAA by ExamplePoEAA by Example
PoEAA by Example
 
Rest web services
Rest web servicesRest web services
Rest web services
 
Patterns for distributed systems
Patterns for distributed systemsPatterns for distributed systems
Patterns for distributed systems
 
Lição prova professor coordenador
Lição prova professor coordenadorLição prova professor coordenador
Lição prova professor coordenador
 
Principles of Service Orientation
Principles of Service OrientationPrinciples of Service Orientation
Principles of Service Orientation
 
REST beyond CRUD
REST beyond CRUDREST beyond CRUD
REST beyond CRUD
 
Modern web architectural patterns
Modern web architectural patternsModern web architectural patterns
Modern web architectural patterns
 
Design Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codeDesign Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID code
 
Decoupled Communication
Decoupled CommunicationDecoupled Communication
Decoupled Communication
 
RESTful services Design Lab
RESTful services Design LabRESTful services Design Lab
RESTful services Design Lab
 
Communication
CommunicationCommunication
Communication
 
OO design principles and patterns
OO design principles and patternsOO design principles and patterns
OO design principles and patterns
 
Software Product Lines
Software Product LinesSoftware Product Lines
Software Product Lines
 

Similar a Benefits of Hypermedia API

Web2 0 Incredibles
Web2 0 IncrediblesWeb2 0 Incredibles
Web2 0 Incredibles
anjeshdubey
 
Entity Linking and REST Patterns in SOA
Entity Linking and REST Patterns in SOA Entity Linking and REST Patterns in SOA
Entity Linking and REST Patterns in SOA
WSO2
 
IBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic InvestmentIBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic Investment
Strongback Consulting
 
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
PolarSeven Pty Ltd
 

Similar a Benefits of Hypermedia API (20)

Talking to 25% of the web - In-depth report and analysis on the WordPress RES...
Talking to 25% of the web - In-depth report and analysis on the WordPress RES...Talking to 25% of the web - In-depth report and analysis on the WordPress RES...
Talking to 25% of the web - In-depth report and analysis on the WordPress RES...
 
4163A - What is Web 2.0.ppt
4163A - What is Web 2.0.ppt4163A - What is Web 2.0.ppt
4163A - What is Web 2.0.ppt
 
Expedite the development lifecycle with MongoDB and serverless - DEM02 - Sant...
Expedite the development lifecycle with MongoDB and serverless - DEM02 - Sant...Expedite the development lifecycle with MongoDB and serverless - DEM02 - Sant...
Expedite the development lifecycle with MongoDB and serverless - DEM02 - Sant...
 
Web2 0 Incredibles
Web2 0 IncrediblesWeb2 0 Incredibles
Web2 0 Incredibles
 
How to use Informatica Power Center as a RESTful Web Service Client?
How to use Informatica Power Center as a RESTful Web Service Client?How to use Informatica Power Center as a RESTful Web Service Client?
How to use Informatica Power Center as a RESTful Web Service Client?
 
Getting Started with API Management
Getting Started with API ManagementGetting Started with API Management
Getting Started with API Management
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
 
How to use Informatica Power Center as a RESTful Web Service Client?
How to use Informatica Power Center as a RESTful Web Service Client?How to use Informatica Power Center as a RESTful Web Service Client?
How to use Informatica Power Center as a RESTful Web Service Client?
 
REST.ppt
REST.pptREST.ppt
REST.ppt
 
Entity Linking and REST Patterns in SOA
Entity Linking and REST Patterns in SOA Entity Linking and REST Patterns in SOA
Entity Linking and REST Patterns in SOA
 
Easy integration of Bluemix services with your applications
Easy integration of Bluemix services with your applicationsEasy integration of Bluemix services with your applications
Easy integration of Bluemix services with your applications
 
Agilewiz PaaS, SaaS, Web 2.5, Platform Technology, BPO Platform Technology,Di...
Agilewiz PaaS, SaaS, Web 2.5, Platform Technology, BPO Platform Technology,Di...Agilewiz PaaS, SaaS, Web 2.5, Platform Technology, BPO Platform Technology,Di...
Agilewiz PaaS, SaaS, Web 2.5, Platform Technology, BPO Platform Technology,Di...
 
IBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic InvestmentIBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic Investment
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
 
Oracle Enterprise 2.0 & Business Applications
Oracle Enterprise 2.0 &  Business ApplicationsOracle Enterprise 2.0 &  Business Applications
Oracle Enterprise 2.0 & Business Applications
 
Microservices: Decomposing Applications for Deployability and Scalability (ja...
Microservices: Decomposing Applications for Deployability and Scalability (ja...Microservices: Decomposing Applications for Deployability and Scalability (ja...
Microservices: Decomposing Applications for Deployability and Scalability (ja...
 
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
 
Connected Architecture Fabric Creating a Connected World
Connected Architecture Fabric Creating a Connected WorldConnected Architecture Fabric Creating a Connected World
Connected Architecture Fabric Creating a Connected World
 
Micro service architecture
Micro service architectureMicro service architecture
Micro service architecture
 
Oracle Applications R12 architecture
Oracle Applications R12 architectureOracle Applications R12 architecture
Oracle Applications R12 architecture
 

Más de Paulo Gandra de Sousa (8)

Minds-on DDD
Minds-on DDDMinds-on DDD
Minds-on DDD
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Design Patterns: Back to Basics
Design Patterns: Back to BasicsDesign Patterns: Back to Basics
Design Patterns: Back to Basics
 
Hypermedia APIs
Hypermedia APIsHypermedia APIs
Hypermedia APIs
 
Revision control with Mercurial
Revision control with MercurialRevision control with Mercurial
Revision control with Mercurial
 
Documenting Software Architectures
Documenting Software ArchitecturesDocumenting Software Architectures
Documenting Software Architectures
 
models of distributed computing
models of distributed computingmodels of distributed computing
models of distributed computing
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systems
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 

Benefits of Hypermedia API

  • 1. BENEFITS OF HYPERMEDIA APIS Paulo Gandra de Sousa pagsousa@gmail.co m
  • 2. Hypermedia is defined by the presence of application control information embedded within, or as a layer above, the presentation of information. Mike Amudsen 3 “
  • 3. THE HYPERMEDIA CONSTRAINT Hipermedia as the engine of application state * * HATEOAS
  • 4. “ HYPERMEDIA IS THE ENGINE Hypermedia payloads carry more information than just the data stored on the server. Hypermedia payloads carry two types of vital metadata: metadata about the data itself and metadata about the possible options for modifying the state of the application at that moment. Mike Amudsen 5
  • 5. THE HYPERMEDIA CONSTRAINT The application is therefore an engine that moves from one state to the next by examining and choosing from among the alternative state transitions in the current set of representations. Roy Fielding 6 “
  • 6. IMMEDIATE BENEFITS Explorable API Inline documentation Simple client logic 7
  • 7. “BILLBOARD” ENDPOINT GET /api 8 200 Ok <links> <link rel=“…” href=“…”/> <link rel=“…” href=“…”/> ... </links>
  • 8. LINKED DATA PRINCIPLES 1.Use URIs as names for things 2.Use HTTP URIs so that people can look up those names. 3.When someone looks up a URI, provide useful information, using the standards 4.Include links to other URIs so that they can discover more things. Tim Berners-Lee (2006) http://www.w3.org/DesignIssues/LinkedData.html 9
  • 9. EXAMPLE: CHECK BANK ACCOUNT BALANCE EXPLORABLE API + INLINE DOCUMENTATION GET /account/12345 200 OK <?xml version="1.0"?> <account> <account_number>12345</account_number> <link rel=“self” href=“/account/12345” /> <balance currency="usd">100.00</balance> <link rel=“http://bank.org/rel/first-subscriber" href="/customer/123" /> <link rel=“http://bank.org/rel/subscribers" href="/account/12345/subscriber" /> <link rel="http://bank.org/rel/deposit" href="/account/12345/deposit" /> <link rel="http://bank.org/rel/withdraw" href="/account/12345/withdraw" /> <link rel="http://bank.org/rel/transfer" href="/account/12345/transfer" /> <link rel="http://bank.org/rel/close" href="/account/12345/close" /> </account> 10 Semantic and documentati on Use URI as names Explorable
  • 10. CLIENT SIMPLICITY Coupled to implementation res = GET /account/123 If enough-funds() then msg = build-withdraw- message() url = build-url-from- template() POST msg @ url Endif Hypermedia-driven res = GET /account/123 If res.hasLink(“withdraw”) then msg = build-withdraw- message() POST msg @ res.link(“withdraw”) Endif 11 Needs to know URL template Business logic spills out to client Server handles Business logic Server manages URL structure VS
  • 11. FLEXIBILITY & EVOLUTION Server takes ownership of URL Offloading content Upgrading 12
  • 12. EXAMPLE: CHECK BANK ACCOUNT BALANCE SERVER MODIFIES URL STRUCTURE GET /account/12345 200 OK <?xml version="1.0"?> <account> <account_number>12345</account_number> <link rel=“self” href=“/account/12345” /> <balance currency="usd">100.00</balance> <link rel=“http://bank.org/rel/first-subscriber" href=“/crm/123?role=customer" /> <link rel=“http://bank.org/rel/subscribers" href="/account/12345/subscriber" /> <link rel="http://bank.org/rel/deposit" href="/account/12345/deposit" /> <link rel="http://bank.org/rel/withdraw" href="/account/12345/withdraw" /> <link rel="http://bank.org/rel/transfer" href="/account/12345/transfer" /> <link rel="http://bank.org/rel/close" href="/account/12345/close" /> </account> 13 New URL; no problem client just follows it
  • 13. EXAMPLE: CHECK BANK ACCOUNT BALANCE CONTENT OFFLOADING GET /account/12345 200 OK <?xml version="1.0"?> <account> <account_number>12345</account_number> <link rel=“self” href=“/account/12345” /> <balance currency="usd">100.00</balance> <link rel=“http://bank.org/rel/first-subscriber" href=“http://one-crm.com/api/tenant/bankABC/prospect/754" /> <link rel=“http://bank.org/rel/pricing" href=“http://bankABC.cdn.akamai.com/static/pricing" /> ... </account> 14 Content offloaded to 3rd party providers
  • 14. EXAMPLE: CHECK BANK ACCOUNT BALANCE SERVER UPGRADE GET /account/12345 200 OK <?xml version="1.0"?> <account> <account_number>12345</account_number> <link rel=“self” href=“/account/12345” /> <balance currency="usd">100.00</balance> <link rel=“http://bank.org/rel/first-subscriber" href=“http://one-crm.com/api/tenant/bankABC/prospect/754" /> <link rel=“http://bank.org/rel/pricing" href=“http://bankABC.cdn.akamai.com/static/pricing" /> <link rel="http://bank.org/rel/deposit" href="/account/12345/deposit" type=“application/vnd.bankABC.deposit.v2+xml, application/vnd.bankABC.deposit+xml” /> ... </account> 15 New relationship; only V2 clients will know it New media type accepted; only V2 clients will know it
  • 16. 1. Adhere to the hypermedia constraint 2. Aim for a “billboard” API 3. Decouple client and server
  • 18. Jørn Wildt (2013) Selling the benefits of hypermedia APIs. http://soabits.blogspot.no/2013/12/selling-benefits- of-hypermedia.html David (2012) Getting hyper about hypermedia APIs. https://signalvnoise.com/posts/3373-getting-hyper- about-hypermedia-apis “Architectural Styles and the Design of Network-based Software Architectures”, PhD Thesis (2000), Roy Thomas Fielding. http://www.ics.uci.edu/~fielding/pubs/dissertation/top. htm Leonard Richardson, Mike Amundsen, RESTful web APIs. O’Reily Media. ISBN: 1449358063

Notas del editor

  1. http://www.v3.co.uk/IMG/063/257063/web-http-url-address-internet-online-www.jpg
  2. From wikipedia: http://en.wikipedia.org/wiki/HATEOAS This principle is the key differentiator between a REST and most other forms of client server system. Rather than the actions and interfaces a client may use being defined elsewhere, such as in a WSDL file or predefined in the client code, the principle is that the hypermedia in eachserver response will contain links that correspond to all the actions that the client can currently perform. Therefore, dependent on the current application state, every server response describes the new actions that are available. The server can change the range of allowable responses in a dynamic way, and a client should adapt its behavior to these changes. A client of a RESTful application need only know a single fixed URL to access it. All future actions should be discoverable dynamically from hypermedia links included in the representations of the resources that are returned from that URL. Standardized media types are also expected to be understood by any client that might use a RESTful API. Application state transitions are driven by a combination of the known processing rules for each media type, client selection from the server-provided choices in representations received, and the user's manipulation of those representations. Thus interactions are driven by hypermedia, rather than by any out-of-band information.[1] If necessary, the client’s knowledge of media types, resource communication mechanisms, and user interaction, may be improved on-the-fly by the transmission of code-on-demand from the server to the client as defined elsewhere in the REST architecture.[2]
  3. http://soabits.blogspot.no/2013/12/selling-benefits-of-hypermedia.html
  4. Single entry point URI /api Everything else is discovered thru links
  5. http://www.w3.org/DesignIssues/LinkedData.html
  6. Based on http://restcookbook.com/Basics/hateoas/
  7. http://soabits.blogspot.no/2013/12/selling-benefits-of-hypermedia.html
  8. Based on http://restcookbook.com/Basics/hateoas/
  9. Based on http://restcookbook.com/Basics/hateoas/
  10. Old clients will ignore the relationships they don’t understand and will continue to send V1 representations while new clients will understand the new relationships and will take advantage of V2 representations
  11. http://www.newswire.com/blog/wp-content/uploads/2015/02/Expert-Strategies-for-Writing-Your-Press-Release-Summary.jpg
  12. http://www.pdgm.com/getmedia/49986e29-2fba-4629-8a09-591205b91ed4/Library_1400_800.jpg.aspx