SlideShare a Scribd company logo
1 of 15
Download to read offline
RESTful HATEOAS
standards using
Java based
Katharsis
Keith D. Moore
• Independent Software Consultant
• KD Moore Consulting
• http://www.kdmooreconsulting.com
• keith@kdmooreconsulting.com
• @keithdmoore94
• in/keithdmoore94
What is a RESTful API?
An application program interface (API) that uses HTTP
methods like GET, POST, PUT, PATCH, OPTIONS and
DELETE to make requests and receive responses.
HTTP Methods for REST
• GET - this is a read method (get all/get one)
• POST - this is a create method
• PUT - this is an update method (usually a full replacement)
• PATCH - this is an update method (usually partial)
• OPTIONS - typically used for preflight requests or metadata
• DELETE - this a delete method
HATEOAS
• (Hypermedia as the Engine of Application State) is a constraint
of the REST application architecture. A hypermedia-driven site
provides information to navigate the site's REST interfaces
dynamically by including hypermedia links with the responses.
• Allows a client to navigate a set of resources with very little
documentation.
• Allows for resource urls to change without impacting the client.
• Essentially provides the ability to create a self-describing API
Parkinson's law of triviality is C.
Northcote Parkinson's 1957
argument that members of an
organization give disproportionate
weight to trivial issues. He observed
that a committee whose job was to
approve the plans for a nuclear
power plant spent the majority of its
time on discussions about relatively
minor but easy-to-grasp issues,
such as what materials to use for the
staff bike-shed, while neglecting the
proposed design of the plant itself,
which is far more important but also
a far more difficult and complex task.
The Bikeshed moment
• How are the requests/responses going to be formatted?
• Are we going to use a PATCH method for full and partial
updates?
• What is the format for a pagination or sorting request?
• How will requests be structured that act on resource
relationships?
• How will error responses be formatted?
JSON API to the rescue
• JSON API is a specification for how a client should request that resources be
fetched or modified, and how a server should respond to those requests.
• http://jsonapi.org (there really is a specification for it)
• Even has its own media type: application/vnd.api+json
• Lots of MUST, MUST NOT, SHOULD, MAY, etc.
• There are still some decisions to be made but this gives you a framework to make
some of the more fine grained decisions.
• Several implementations in a variety of languages. Both client-side and server-side.
REST URI’s
	•	GET /api/tasks: returns all tasks
	•	GET /api/tasks/1: returns the task with ID 1
	•	POST /api/tasks: creates a task with the data sent in
the body
	•	PATCH /api/tasks/1: updates the task with ID 1 with
the data sent in the body (only send what you want to
update)
	•	DELETE /api/tasks/1: delete the task with ID 1
	•	OPTIONS /api/tasks: metadata about the member
resource
Sample Response
{
"data": {
"type": "articles",
"id": "1",
"attributes": {
“title”: “Having fun with JSON”,
“description”: “Explore the fun you can have with JSON.”
},
"relationships": {
"author": {
"links": {
"self": "/articles/1/relationships/author",
"related": “/articles/1/author"
}
}
}
}
}
atharsis
• a Greek word meaning "cleansing" or “purging”
• Elegant and powerful HATEOAS framework for Java based on the
JSON API standard
• Uses ResourceRepository and ResourceRelationshipRepository
• Annotation based or interface based
• Modular
• Core
• Spring
• JAX-RS
• Servlet
• Vertx
• Examples
• Very few dependencies
Let’s look at Katharsis in Action
Filter/Sort/Group/Pagination
• GET /api/tasks?filter[tasks][name]=Make%20Coffee
• GET /api/tasks?sort[tasks][name]=asc
• GET /api/tasks?group[tasks]=name
• GET /api/tasks?include[tasks]=project
• GET /api/tasks?page[offset]=0&page[limit]=10
Pagination using Links
"links": {
"self": “http://example.com/articles/22“,
"first": “http://example.com/articles?page[offset]=0”
"prev": “http://example.com/articles?page[offset]=1”
"next": "http://example.com/articles?page[offset]=3",
"last": "http://example.com/articles?page[offset]=10"
}
References and Links
• http://jsonapi.org
• https://en.wikipedia.org/wiki/HATEOAS
• http://katharsis.io
• https://en.wikipedia.org/wiki/Law_of_triviality

More Related Content

What's hot

CakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsCakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIs
anthony_putignano
 
Keeping Discovery in the Library
Keeping Discovery in the LibraryKeeping Discovery in the Library
Keeping Discovery in the Library
Ken Varnum
 
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
Harry Potter
 

What's hot (19)

Rest api-basic
Rest api-basicRest api-basic
Rest api-basic
 
Api crash
Api crashApi crash
Api crash
 
Best Practices for RESTful Web Services
Best Practices for RESTful Web ServicesBest Practices for RESTful Web Services
Best Practices for RESTful Web Services
 
Test in Rest. API testing with the help of Rest Assured.
Test in Rest. API testing with the help of  Rest Assured.Test in Rest. API testing with the help of  Rest Assured.
Test in Rest. API testing with the help of Rest Assured.
 
Best Practice in Web Service Design
Best Practice in Web Service DesignBest Practice in Web Service Design
Best Practice in Web Service Design
 
Building Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff StanoBuilding Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff Stano
 
Dotnet- An overview of ASP.NET & ADO.NET- Mazenet solution
Dotnet- An overview of ASP.NET & ADO.NET- Mazenet solutionDotnet- An overview of ASP.NET & ADO.NET- Mazenet solution
Dotnet- An overview of ASP.NET & ADO.NET- Mazenet solution
 
introduction about REST API
introduction about REST APIintroduction about REST API
introduction about REST API
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
Introduction to RESTful Webservices in JAVA
Introduction to RESTful Webservices  in JAVA Introduction to RESTful Webservices  in JAVA
Introduction to RESTful Webservices in JAVA
 
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India 2015 - Rest with Java (jax rs) and jerseyEclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
 
Implementing Site Search in CQ5 / AEM
Implementing Site Search in CQ5 / AEMImplementing Site Search in CQ5 / AEM
Implementing Site Search in CQ5 / AEM
 
Getting started with DSpace 7 REST API
Getting started with DSpace 7 REST APIGetting started with DSpace 7 REST API
Getting started with DSpace 7 REST API
 
Rest api to integrate with your site
Rest api to integrate with your siteRest api to integrate with your site
Rest api to integrate with your site
 
At Begin, URL Handling and REST
At Begin, URL Handling and RESTAt Begin, URL Handling and REST
At Begin, URL Handling and REST
 
CakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsCakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIs
 
Rest api and-crud-api
Rest api and-crud-apiRest api and-crud-api
Rest api and-crud-api
 
Keeping Discovery in the Library
Keeping Discovery in the LibraryKeeping Discovery in the Library
Keeping Discovery in the Library
 
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
 

Viewers also liked

Gearing up for push notifications
Gearing up for push notificationsGearing up for push notifications
Gearing up for push notifications
Keith Moore
 

Viewers also liked (10)

RESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based KatharsisRESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based Katharsis
 
Gearing up for push notifications
Gearing up for push notificationsGearing up for push notifications
Gearing up for push notifications
 
Netflix OSS and HATEOAS deployed on production - JavaLand
Netflix OSS and HATEOAS deployed on production - JavaLandNetflix OSS and HATEOAS deployed on production - JavaLand
Netflix OSS and HATEOAS deployed on production - JavaLand
 
Indexes: The neglected performance all rounder
Indexes: The neglected performance all rounderIndexes: The neglected performance all rounder
Indexes: The neglected performance all rounder
 
Revitalizing Walmart's Aging Architecture for Web Scale
Revitalizing Walmart's Aging Architecture for Web ScaleRevitalizing Walmart's Aging Architecture for Web Scale
Revitalizing Walmart's Aging Architecture for Web Scale
 
Clean architecture on Android
Clean architecture on AndroidClean architecture on Android
Clean architecture on Android
 
Pagination Done the Right Way
Pagination Done the Right WayPagination Done the Right Way
Pagination Done the Right Way
 
Reactive Distributed Applications with Vert.x
Reactive Distributed Applications with Vert.xReactive Distributed Applications with Vert.x
Reactive Distributed Applications with Vert.x
 
Vert.x for Microservices Architecture
Vert.x for Microservices ArchitectureVert.x for Microservices Architecture
Vert.x for Microservices Architecture
 
Patterns for building resilient and scalable microservices platform on AWS
Patterns for building resilient and scalable microservices platform on AWSPatterns for building resilient and scalable microservices platform on AWS
Patterns for building resilient and scalable microservices platform on AWS
 

Similar to RESTful HATEOAS standards using Java based Katharsis

REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
Jeelani Shaik
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
Lorna Mitchell
 

Similar to RESTful HATEOAS standards using Java based Katharsis (20)

Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIs
 
Rest APIs Training
Rest APIs TrainingRest APIs Training
Rest APIs Training
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
 
APITalkMeetupSharable
APITalkMeetupSharableAPITalkMeetupSharable
APITalkMeetupSharable
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
API testing with the help of Rest Assured
API testing with the help of  Rest Assured API testing with the help of  Rest Assured
API testing with the help of Rest Assured
 
Rest WebAPI with OData
Rest WebAPI with ODataRest WebAPI with OData
Rest WebAPI with OData
 
Lessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxLessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptx
 
Introduction to Google APIs
Introduction to Google APIsIntroduction to Google APIs
Introduction to Google APIs
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST API
 
REST Methodologies
REST MethodologiesREST Methodologies
REST Methodologies
 

Recently uploaded

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 

Recently uploaded (20)

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 

RESTful HATEOAS standards using Java based Katharsis

  • 2. Keith D. Moore • Independent Software Consultant • KD Moore Consulting • http://www.kdmooreconsulting.com • keith@kdmooreconsulting.com • @keithdmoore94 • in/keithdmoore94
  • 3. What is a RESTful API? An application program interface (API) that uses HTTP methods like GET, POST, PUT, PATCH, OPTIONS and DELETE to make requests and receive responses.
  • 4. HTTP Methods for REST • GET - this is a read method (get all/get one) • POST - this is a create method • PUT - this is an update method (usually a full replacement) • PATCH - this is an update method (usually partial) • OPTIONS - typically used for preflight requests or metadata • DELETE - this a delete method
  • 5. HATEOAS • (Hypermedia as the Engine of Application State) is a constraint of the REST application architecture. A hypermedia-driven site provides information to navigate the site's REST interfaces dynamically by including hypermedia links with the responses. • Allows a client to navigate a set of resources with very little documentation. • Allows for resource urls to change without impacting the client. • Essentially provides the ability to create a self-describing API
  • 6. Parkinson's law of triviality is C. Northcote Parkinson's 1957 argument that members of an organization give disproportionate weight to trivial issues. He observed that a committee whose job was to approve the plans for a nuclear power plant spent the majority of its time on discussions about relatively minor but easy-to-grasp issues, such as what materials to use for the staff bike-shed, while neglecting the proposed design of the plant itself, which is far more important but also a far more difficult and complex task.
  • 7. The Bikeshed moment • How are the requests/responses going to be formatted? • Are we going to use a PATCH method for full and partial updates? • What is the format for a pagination or sorting request? • How will requests be structured that act on resource relationships? • How will error responses be formatted?
  • 8. JSON API to the rescue • JSON API is a specification for how a client should request that resources be fetched or modified, and how a server should respond to those requests. • http://jsonapi.org (there really is a specification for it) • Even has its own media type: application/vnd.api+json • Lots of MUST, MUST NOT, SHOULD, MAY, etc. • There are still some decisions to be made but this gives you a framework to make some of the more fine grained decisions. • Several implementations in a variety of languages. Both client-side and server-side.
  • 9. REST URI’s • GET /api/tasks: returns all tasks • GET /api/tasks/1: returns the task with ID 1 • POST /api/tasks: creates a task with the data sent in the body • PATCH /api/tasks/1: updates the task with ID 1 with the data sent in the body (only send what you want to update) • DELETE /api/tasks/1: delete the task with ID 1 • OPTIONS /api/tasks: metadata about the member resource
  • 10. Sample Response { "data": { "type": "articles", "id": "1", "attributes": { “title”: “Having fun with JSON”, “description”: “Explore the fun you can have with JSON.” }, "relationships": { "author": { "links": { "self": "/articles/1/relationships/author", "related": “/articles/1/author" } } } } }
  • 11. atharsis • a Greek word meaning "cleansing" or “purging” • Elegant and powerful HATEOAS framework for Java based on the JSON API standard • Uses ResourceRepository and ResourceRelationshipRepository • Annotation based or interface based • Modular • Core • Spring • JAX-RS • Servlet • Vertx • Examples • Very few dependencies
  • 12. Let’s look at Katharsis in Action
  • 13. Filter/Sort/Group/Pagination • GET /api/tasks?filter[tasks][name]=Make%20Coffee • GET /api/tasks?sort[tasks][name]=asc • GET /api/tasks?group[tasks]=name • GET /api/tasks?include[tasks]=project • GET /api/tasks?page[offset]=0&page[limit]=10
  • 14. Pagination using Links "links": { "self": “http://example.com/articles/22“, "first": “http://example.com/articles?page[offset]=0” "prev": “http://example.com/articles?page[offset]=1” "next": "http://example.com/articles?page[offset]=3", "last": "http://example.com/articles?page[offset]=10" }
  • 15. References and Links • http://jsonapi.org • https://en.wikipedia.org/wiki/HATEOAS • http://katharsis.io • https://en.wikipedia.org/wiki/Law_of_triviality