SlideShare a Scribd company logo
1 of 37
Chris Marinos presents:
Hypermedia APIs:
The Rest of REST
The Agenda
❖ REST overview
❖ Hypermedia
❖ Affordances
❖ Demo
Who has written or consumed a REST API?
What is REST?
–Chris Marinos
REST APIs are where you, like, follow HTTP and stuff
Representational State Transfer (REST) is a
software architecture style consisting of guidelines
and best practices for creating scalable web
services. REST is a coordinated set of constraints
applied to the design of components in a distributed
hypermedia system that can lead to a more
performant and maintainable architecture.
Representational State Transfer (REST) is a
software architecture style consisting of guidelines
and best practices for creating scalable web
services. REST is a coordinated set of constraints
applied to the design of components in a distributed
hypermedia system that can lead to a more
performant and maintainable architecture.
REST is the architectural style of the internet
REST Constraints
❖ Client-Server
❖ Stateless
❖ Cache
❖ Uniform Interface
❖ Layered System
❖ Code-On-Demand (optional)
REST Benefits
❖ Client-Server -> reuse across clients
❖ Stateless -> scalability/reliability
❖ Cache -> performance
❖ Uniform Interface -> simplicity of interaction
❖ Layered System -> visibility
❖ Code-On-Demand (optional) -> extensibility of client
No HTTP?
–Roy Fielding
“…if the engine of application state (and hence the
API) is not being driven by hypertext, then it cannot
be RESTful and cannot be a REST API. Period.”
The Agenda
❖ REST overview
❖ Hypermedia
❖ Affordances
❖ Demo
HATEOAS
Hypertext as the Engine of Application State
(also a horrible acronym)
So what is hypermedia?
Richardson Maturity Model
Level 0: Pox
Level 1: Resources
Level 2: HTTP Verbs
Level 3: Hypermedia Controls
REST
Level 0: POX
POST /myservice/
{
method: ‘get_customer’
customer_id: 1235
}
POST /myservice/
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-
encoding">
<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetCustomer>
<m:CustomerId>1234</m:CustomerId>
</m:GetCustomer>
</soap:Body>
</soap:Envelope>
Level 1: Resources
POST /customer/
{ method: ‘get_customer’, customer_id: 1234}
POST /organization/
{ method: ‘get_organization’, organization_id: 1234}
POST /organization/
{
method: ‘create_organization’,
organization_id: 1234,
name: ‘new name’
}
Level 2: Verbs
GET /organizations/
————————
{
organization_id: 1234
name: ‘Cool Stuff Inc.’
}
POST /organizations/
{
organization_id: 999
name: ‘My New Organization’
}
GET /organizations/999
————————
{
organization_id: 999
name: ‘My New Organization’
}
Level 3: Hypermedia
GET /organizations/
<form name="input" method=“post" action=“/organizations/“>
Name: <input type="text" name=“organization_name">
<input type="submit" value="Submit">
</form>
POST /organizations/
{
organization_id: 1234
name: ‘My RESTful Organization’
}
The Agenda
❖ REST overview
❖ Hypermedia
❖ Affordances
❖ Demo
“A REST API should be entered with no prior
knowledge beyond the initial URI (bookmark) and set
of standardized media types that are appropriate for
the intended audience (i.e., expected to be
understood by any client that might use the API)”
–Roy Fielding
Affordances
State transitions over URL structure
Hypermedia Benefits
• API discoverability and documentation
• Reuse of state transition logic across clients
• Ease of client development
• More flexibility for servers to evolve
Hypermedia Formats
HTML
XHTML
Collection+JSON
Siren
HAL
JSON-LD
NOT JSON or XML
Collection+JSON
{
"collection" :
{
"version" : “1.0",
"href" : “https://foo.com/api/“,
"links" : […],
"items" : […],
"queries" : […],
"template" : {…}
}
}
Links
"links" : [
{
"href": “https://foo.com/api/organizations/",
"rel": "organizations"
},
{
"href": “https://foo.com/api/customers/",
"rel": "customers"
},
],
Items
"items": [
{
"href": “https://foo.com/api/organizations/1/",
"data": [
{
"name": “organization_id”,
"value": “my_org”
}
],
"links": [
{
“href": “https://foo.com/api/organizations/1/customers“,
"rel": "customers"
},
]
}
]
Queries
"queries" : [
{"rel" : "search",
"href" : “https://foo.com/api/customers/search”,
"data" : [
{"name" : “last_name", "value" : ""}
]
}
],
Template
"template" : {
"data" : [
{"name" : “fist_name”, "value" : "", "prompt" : “First name”},
{"name" : “last_name”, "value" : "", "prompt" : “Last name"},
]
}
The Agenda
❖ REST overview
❖ Hypermedia
❖ Affordances
❖ Demo
Who’s using this stuff?
Who has written or consumed a REST API?
Questions?
❖ API Craft Google group/mailing list
❖ RESTful Web APIs (Richardson/Amundsen)
❖ Roy Fielding’s thesis/blog
❖ Hypermedia formats (HAL, Siren, Hydra, CJ, JSON-LD,
UBER, etc.)
❖ API Craft conference in Detroit (http://apicraft.org/)

More Related Content

What's hot

Rest & RESTful WebServices
Rest & RESTful WebServicesRest & RESTful WebServices
Rest & RESTful WebServicesPrateek Tandon
 
REST - Representational State Transfer
REST - Representational State TransferREST - Representational State Transfer
REST - Representational State TransferPeter R. Egli
 
Soap and restful webservice
Soap and restful webserviceSoap and restful webservice
Soap and restful webserviceDong Ngoc
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web ServicesKasun Madusanke
 
RESTful services
RESTful servicesRESTful services
RESTful servicesgouthamrv
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUDPrem Sanil
 
introduction about REST API
introduction about REST APIintroduction about REST API
introduction about REST APIAmilaSilva13
 
Introduction to webservices
Introduction to webservicesIntroduction to webservices
Introduction to webservicesGagandeep Singh
 
How to build a rest api.pptx
How to build a rest api.pptxHow to build a rest api.pptx
How to build a rest api.pptxHarry Potter
 
SQL Server Service Broker – A Competent Architecture by Microsoft
SQL Server Service Broker – A Competent Architecture by MicrosoftSQL Server Service Broker – A Competent Architecture by Microsoft
SQL Server Service Broker – A Competent Architecture by Microsoftsara stanford
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST Ram Awadh Prasad, PMP
 

What's hot (20)

Rest & RESTful WebServices
Rest & RESTful WebServicesRest & RESTful WebServices
Rest & RESTful WebServices
 
REST - Representational State Transfer
REST - Representational State TransferREST - Representational State Transfer
REST - Representational State Transfer
 
Soap and restful webservice
Soap and restful webserviceSoap and restful webservice
Soap and restful webservice
 
Rest surekha
Rest surekhaRest surekha
Rest surekha
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web Services
 
Implementation advantages of rest
Implementation advantages of restImplementation advantages of rest
Implementation advantages of rest
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
introduction about REST API
introduction about REST APIintroduction about REST API
introduction about REST API
 
Web services for banks
Web services for banksWeb services for banks
Web services for banks
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Rest
RestRest
Rest
 
Rest web services
Rest web servicesRest web services
Rest web services
 
Introduction to webservices
Introduction to webservicesIntroduction to webservices
Introduction to webservices
 
REST Presentation
REST PresentationREST Presentation
REST Presentation
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
How to build a rest api.pptx
How to build a rest api.pptxHow to build a rest api.pptx
How to build a rest api.pptx
 
SQL Server Service Broker – A Competent Architecture by Microsoft
SQL Server Service Broker – A Competent Architecture by MicrosoftSQL Server Service Broker – A Competent Architecture by Microsoft
SQL Server Service Broker – A Competent Architecture by Microsoft
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST
 

Similar to Hypermedia APIs: The Rest of REST

Together Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaTogether Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaVladimir Tsukur
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJerry Kurian
 
Restful webservices
Restful webservicesRestful webservices
Restful webservicesKong King
 
REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008Ryan Hoegg
 
Hypermedia APIs and HATEOAS
Hypermedia APIs and HATEOASHypermedia APIs and HATEOAS
Hypermedia APIs and HATEOASVladimir Tsukur
 
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...Codemotion
 
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integrationCdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integrationDavid Gómez García
 
rest-api-basics.pptx
rest-api-basics.pptxrest-api-basics.pptx
rest-api-basics.pptxFikiRieza2
 
SAP ODATA Overview & Guidelines
SAP ODATA Overview & GuidelinesSAP ODATA Overview & Guidelines
SAP ODATA Overview & GuidelinesAshish Saxena
 
Design Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John HardyDesign Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John HardyManageIQ
 
Web Apps for the Masses
Web Apps for the MassesWeb Apps for the Masses
Web Apps for the MassesDavid Tufts
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!Evan Mullins
 

Similar to Hypermedia APIs: The Rest of REST (20)

Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Together Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaTogether Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with Hypermedia
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with Java
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008
 
Old WP REST API, New Tricks
Old WP REST API, New TricksOld WP REST API, New Tricks
Old WP REST API, New Tricks
 
Hypermedia APIs and HATEOAS
Hypermedia APIs and HATEOASHypermedia APIs and HATEOAS
Hypermedia APIs and HATEOAS
 
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
 
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integrationCdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
 
Modified REST Presentation
Modified REST PresentationModified REST Presentation
Modified REST Presentation
 
rest-api-basics.pptx
rest-api-basics.pptxrest-api-basics.pptx
rest-api-basics.pptx
 
SAP ODATA Overview & Guidelines
SAP ODATA Overview & GuidelinesSAP ODATA Overview & Guidelines
SAP ODATA Overview & Guidelines
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
APITalkMeetupSharable
APITalkMeetupSharableAPITalkMeetupSharable
APITalkMeetupSharable
 
How RESTful Is Your REST?
How RESTful Is Your REST?How RESTful Is Your REST?
How RESTful Is Your REST?
 
Cqrs api v2
Cqrs api v2Cqrs api v2
Cqrs api v2
 
Design Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John HardyDesign Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John Hardy
 
Nuxeo JavaOne 2007
Nuxeo JavaOne 2007Nuxeo JavaOne 2007
Nuxeo JavaOne 2007
 
Web Apps for the Masses
Web Apps for the MassesWeb Apps for the Masses
Web Apps for the Masses
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
 

Recently uploaded

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 

Recently uploaded (20)

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 

Hypermedia APIs: The Rest of REST

  • 1. Chris Marinos presents: Hypermedia APIs: The Rest of REST
  • 2. The Agenda ❖ REST overview ❖ Hypermedia ❖ Affordances ❖ Demo
  • 3.
  • 4.
  • 5. Who has written or consumed a REST API?
  • 7. –Chris Marinos REST APIs are where you, like, follow HTTP and stuff
  • 8. Representational State Transfer (REST) is a software architecture style consisting of guidelines and best practices for creating scalable web services. REST is a coordinated set of constraints applied to the design of components in a distributed hypermedia system that can lead to a more performant and maintainable architecture.
  • 9. Representational State Transfer (REST) is a software architecture style consisting of guidelines and best practices for creating scalable web services. REST is a coordinated set of constraints applied to the design of components in a distributed hypermedia system that can lead to a more performant and maintainable architecture.
  • 10. REST is the architectural style of the internet
  • 11. REST Constraints ❖ Client-Server ❖ Stateless ❖ Cache ❖ Uniform Interface ❖ Layered System ❖ Code-On-Demand (optional)
  • 12. REST Benefits ❖ Client-Server -> reuse across clients ❖ Stateless -> scalability/reliability ❖ Cache -> performance ❖ Uniform Interface -> simplicity of interaction ❖ Layered System -> visibility ❖ Code-On-Demand (optional) -> extensibility of client
  • 14. –Roy Fielding “…if the engine of application state (and hence the API) is not being driven by hypertext, then it cannot be RESTful and cannot be a REST API. Period.”
  • 15. The Agenda ❖ REST overview ❖ Hypermedia ❖ Affordances ❖ Demo
  • 16. HATEOAS Hypertext as the Engine of Application State (also a horrible acronym)
  • 17. So what is hypermedia?
  • 18. Richardson Maturity Model Level 0: Pox Level 1: Resources Level 2: HTTP Verbs Level 3: Hypermedia Controls REST
  • 19. Level 0: POX POST /myservice/ { method: ‘get_customer’ customer_id: 1235 } POST /myservice/ <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap- encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetCustomer> <m:CustomerId>1234</m:CustomerId> </m:GetCustomer> </soap:Body> </soap:Envelope>
  • 20. Level 1: Resources POST /customer/ { method: ‘get_customer’, customer_id: 1234} POST /organization/ { method: ‘get_organization’, organization_id: 1234} POST /organization/ { method: ‘create_organization’, organization_id: 1234, name: ‘new name’ }
  • 21. Level 2: Verbs GET /organizations/ ———————— { organization_id: 1234 name: ‘Cool Stuff Inc.’ } POST /organizations/ { organization_id: 999 name: ‘My New Organization’ } GET /organizations/999 ———————— { organization_id: 999 name: ‘My New Organization’ }
  • 22. Level 3: Hypermedia GET /organizations/ <form name="input" method=“post" action=“/organizations/“> Name: <input type="text" name=“organization_name"> <input type="submit" value="Submit"> </form> POST /organizations/ { organization_id: 1234 name: ‘My RESTful Organization’ }
  • 23. The Agenda ❖ REST overview ❖ Hypermedia ❖ Affordances ❖ Demo
  • 24. “A REST API should be entered with no prior knowledge beyond the initial URI (bookmark) and set of standardized media types that are appropriate for the intended audience (i.e., expected to be understood by any client that might use the API)” –Roy Fielding
  • 26. State transitions over URL structure
  • 27. Hypermedia Benefits • API discoverability and documentation • Reuse of state transition logic across clients • Ease of client development • More flexibility for servers to evolve
  • 29. Collection+JSON { "collection" : { "version" : “1.0", "href" : “https://foo.com/api/“, "links" : […], "items" : […], "queries" : […], "template" : {…} } }
  • 30. Links "links" : [ { "href": “https://foo.com/api/organizations/", "rel": "organizations" }, { "href": “https://foo.com/api/customers/", "rel": "customers" }, ],
  • 31. Items "items": [ { "href": “https://foo.com/api/organizations/1/", "data": [ { "name": “organization_id”, "value": “my_org” } ], "links": [ { “href": “https://foo.com/api/organizations/1/customers“, "rel": "customers" }, ] } ]
  • 32. Queries "queries" : [ {"rel" : "search", "href" : “https://foo.com/api/customers/search”, "data" : [ {"name" : “last_name", "value" : ""} ] } ],
  • 33. Template "template" : { "data" : [ {"name" : “fist_name”, "value" : "", "prompt" : “First name”}, {"name" : “last_name”, "value" : "", "prompt" : “Last name"}, ] }
  • 34. The Agenda ❖ REST overview ❖ Hypermedia ❖ Affordances ❖ Demo
  • 36. Who has written or consumed a REST API?
  • 37. Questions? ❖ API Craft Google group/mailing list ❖ RESTful Web APIs (Richardson/Amundsen) ❖ Roy Fielding’s thesis/blog ❖ Hypermedia formats (HAL, Siren, Hydra, CJ, JSON-LD, UBER, etc.) ❖ API Craft conference in Detroit (http://apicraft.org/)

Editor's Notes

  1. Ask for questions! Don’t be offended if I suggest that we talk about it offline. (I ramble)
  2. http://commons.wikimedia.org/wiki/File:Roy_Fielding.jpg Know this guy?
  3. http://commons.wikimedia.org/wiki/File:Rembrandt_-_Moses_with_the_Ten_Commandments_-_Google_Art_Project.jpg Fielding presented constraints/definition for REST As usual with rules/manifestos, people didn’t quite agree
  4. Raise your hands… I bet everyone is right… just not the way you think Next, I have one simple question
  5. This was a harder question than I thought to answer
  6. My definition before I did my homework
  7. http://en.wikipedia.org/wiki/Representational_state_transfer wikipedia definition of REST (no wonder I couldn’t sum it up)
  8. Wait a second, what’s this?
  9. Massively distributed Highly scalable Extremely decoupled Low latency
  10. Hypermedia is a requirement for REST, HTTP isn’t Hypermedia is a core part of Fielding’s dissertation, HTTP is only mentioned indirectly For this talk, we’re going to focus on REST over HTTP, but that’s NOT a requirement
  11. http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven according to Roy, you need hypermedia
  12. Let’s get more concrete
  13. If Fielding is black and white about REST, Richardson’s model is shades of grey
  14. server is pushing down resource state alongside available transitions through the system think about google.com as an example
  15. http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven
  16. http://upload.wikimedia.org/wikipedia/en/0/01/Screenshot_of_Zork_running_on_Frotz_through_iTerm_2_on_Mac_OSX.png Who’s ever played a text adventure? Wasn’t it annoying trying to guess what the game wanted you to type? The web works in a similar way- both are basically state machines (though the web is massively distributed, lazily evaluated, etc.) Much easier if you tell the player what they’re able to do instead of having them guess (though maybe less fun)
  17. Without hypermedia, we agonize over URL structure. Trying to make life easier for clients? The thing is, clients don’t care about URLs, they care about state transition/manipulation.
  18. Lots of formats with different affordances- going to focus on CJ for this talk since it’s easy to grok, natural transition for CRUD thinking, one I’m most familiar with, etc.
  19. sort of… not a ton of perfect examples, but it seem to be coming along
  20. Has anyone browsed a web page? If so you’ve used a REST API. Apply the same concepts that made the web successful to your APIs and profit.