SlideShare a Scribd company logo
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

PDF
Rest api testing
PPTX
RESTful Web Service using Swagger
PPTX
Overview of REST - Raihan Ullah
PPTX
How to build a rest api
PPTX
Knowledge of web ui for automation testing
PPTX
Summon and LibGuides in Drupal
PPTX
REST-API introduction for developers
PPTX
REST-API's for architects and managers
Rest api testing
RESTful Web Service using Swagger
Overview of REST - Raihan Ullah
How to build a rest api
Knowledge of web ui for automation testing
Summon and LibGuides in Drupal
REST-API introduction for developers
REST-API's for architects and managers

What's hot (19)

PPTX
Rest api-basic
PPTX
Api crash
PDF
Best Practices for RESTful Web Services
PPTX
Test in Rest. API testing with the help of Rest Assured.
PDF
Best Practice in Web Service Design
PPTX
Building Ext JS Using HATEOAS - Jeff Stano
PPTX
Dotnet- An overview of ASP.NET & ADO.NET- Mazenet solution
PPTX
introduction about REST API
PDF
REST API and CRUD
PPTX
Introduction to RESTful Webservices in JAVA
PDF
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
PDF
Implementing Site Search in CQ5 / AEM
PDF
Getting started with DSpace 7 REST API
PPTX
Rest api to integrate with your site
KEY
At Begin, URL Handling and REST
PPTX
CakeFest 2013 - A-Z REST APIs
PPTX
Rest api and-crud-api
PPTX
Keeping Discovery in the Library
PDF
How to build a rest api.pptx
Rest api-basic
Api crash
Best Practices for RESTful Web Services
Test in Rest. API testing with the help of Rest Assured.
Best Practice in Web Service Design
Building Ext JS Using HATEOAS - Jeff Stano
Dotnet- An overview of ASP.NET & ADO.NET- Mazenet solution
introduction about REST API
REST API and CRUD
Introduction to RESTful Webservices in JAVA
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Implementing Site Search in CQ5 / AEM
Getting started with DSpace 7 REST API
Rest api to integrate with your site
At Begin, URL Handling and REST
CakeFest 2013 - A-Z REST APIs
Rest api and-crud-api
Keeping Discovery in the Library
How to build a rest api.pptx
Ad

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

PPTX
Pragmatic REST APIs
PPTX
Rest APIs Training
PPTX
RESTful Services
PPTX
ASP.NET Mvc 4 web api
PDF
REST API Recommendations
PDF
Restful风格ž„web服务架构
PDF
Best Practices in Web Service Design
PPT
APITalkMeetupSharable
PPTX
Api crash
PPTX
Api crash
PPTX
Api crash
PPTX
Api crash
PPTX
Api crash
PPTX
Api crash
PPTX
API testing with the help of Rest Assured
PPTX
Rest WebAPI with OData
PPTX
Lessons learned on the Azure API Stewardship Journey.pptx
PPT
Introduction to Google APIs
PPSX
Advanced Web Development in PHP - Understanding REST API
PPTX
REST Methodologies
Pragmatic REST APIs
Rest APIs Training
RESTful Services
ASP.NET Mvc 4 web api
REST API Recommendations
Restful风格ž„web服务架构
Best Practices in Web Service Design
APITalkMeetupSharable
Api crash
Api crash
Api crash
Api crash
Api crash
Api crash
API testing with the help of Rest Assured
Rest WebAPI with OData
Lessons learned on the Azure API Stewardship Journey.pptx
Introduction to Google APIs
Advanced Web Development in PHP - Understanding REST API
REST Methodologies
Ad

Recently uploaded (20)

PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
Digital Logic Computer Design lecture notes
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
web development for engineering and engineering
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPT
introduction to datamining and warehousing
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPT
Mechanical Engineering MATERIALS Selection
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Artificial Intelligence
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Sustainable Sites - Green Building Construction
PPTX
bas. eng. economics group 4 presentation 1.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Digital Logic Computer Design lecture notes
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
web development for engineering and engineering
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
introduction to datamining and warehousing
CH1 Production IntroductoryConcepts.pptx
Internet of Things (IOT) - A guide to understanding
Mechanical Engineering MATERIALS Selection
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Artificial Intelligence
Automation-in-Manufacturing-Chapter-Introduction.pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Foundation to blockchain - A guide to Blockchain Tech
Sustainable Sites - Green Building Construction
bas. eng. economics group 4 presentation 1.pptx

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