SlideShare uma empresa 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

Mais conteúdo relacionado

Mais procurados

Web Application Deployment
Web Application DeploymentWeb Application Deployment
Web Application Deployment
elliando dias
 
Advantages of tree structured directories(56(1)
Advantages of tree structured directories(56(1)Advantages of tree structured directories(56(1)
Advantages of tree structured directories(56(1)
myrajendra
 
Hypertext and hypermedia
Hypertext and hypermediaHypertext and hypermedia
Hypertext and hypermedia
Jay Patel
 
History of websites
History of websitesHistory of websites
History of websites
leahwilshh2
 

Mais procurados (20)

Business analysis in IT
Business analysis in ITBusiness analysis in IT
Business analysis in IT
 
Responsive Websites
Responsive WebsitesResponsive Websites
Responsive Websites
 
What does a business analyst do?
What does a business analyst do?What does a business analyst do?
What does a business analyst do?
 
Web Application Deployment
Web Application DeploymentWeb Application Deployment
Web Application Deployment
 
Advantages of tree structured directories(56(1)
Advantages of tree structured directories(56(1)Advantages of tree structured directories(56(1)
Advantages of tree structured directories(56(1)
 
Usecase Presentation
Usecase PresentationUsecase Presentation
Usecase Presentation
 
Agile Integration with APIs and Containers Workshop
Agile Integration with APIs and Containers Workshop Agile Integration with APIs and Containers Workshop
Agile Integration with APIs and Containers Workshop
 
Brève introduction au Linked Open Data [appliqué aux institutions culturelles]
Brève introduction au Linked Open Data [appliqué aux institutions culturelles]Brève introduction au Linked Open Data [appliqué aux institutions culturelles]
Brève introduction au Linked Open Data [appliqué aux institutions culturelles]
 
Architecture Review
Architecture ReviewArchitecture Review
Architecture Review
 
Server Side VS Client Side
Server Side VS Client SideServer Side VS Client Side
Server Side VS Client Side
 
3 tier architecture
3 tier architecture3 tier architecture
3 tier architecture
 
Multi-tenant Database Design for SaaS
Multi-tenant Database Design for SaaSMulti-tenant Database Design for SaaS
Multi-tenant Database Design for SaaS
 
Hypertext and hypermedia
Hypertext and hypermediaHypertext and hypermedia
Hypertext and hypermedia
 
Software requirement and specification
Software requirement and specificationSoftware requirement and specification
Software requirement and specification
 
The Evolving Role of the Business Analyst
The Evolving Role of the Business AnalystThe Evolving Role of the Business Analyst
The Evolving Role of the Business Analyst
 
Analysis modeling
Analysis modelingAnalysis modeling
Analysis modeling
 
6 Week / Month Industrial Training in Hoshiarpur Punjab- PHP Project Report
6 Week / Month Industrial Training in Hoshiarpur Punjab- PHP Project Report 6 Week / Month Industrial Training in Hoshiarpur Punjab- PHP Project Report
6 Week / Month Industrial Training in Hoshiarpur Punjab- PHP Project Report
 
Architectural Design & Patterns
Architectural Design&PatternsArchitectural Design&Patterns
Architectural Design & Patterns
 
Use case diagrams
Use case diagramsUse case diagrams
Use case diagrams
 
History of websites
History of websitesHistory of websites
History of websites
 

Destaque

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
 

Destaque (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
 

Semelhante 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
 

Semelhante 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
 

Mais 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

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
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
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
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
 
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
 
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
 
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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
[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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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...
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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...
 

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 do 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