Hypertext Application Language: Difference between revisions

Content deleted Content added
Format code samples
Tags: nowiki added Visual edit
WikiCleanerBot (talk | contribs)
m v2.05b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation)
 
(33 intermediate revisions by 29 users not shown)
Line 1:
{{Short description|Proposed computer definition standard}}
'''Hypertext Application Language''' ('''HAL''') is an [[Internet Draft]] (a "work in progress") standard convention for defining [[hypermedia]] such as links to external [[web resource|resources]] within [[JSON]] or [[XML]] code. It is documented in an [[Internet Draft]] (a "work in progress"), with the latest version 11 published the 10th of October 2023. The standard was initially proposed onin June 2012, specifically for use with JSON,<ref name="rfc4627">{{cite journalweb |last1=Kelly |first1=Mike |title=JSON Hypertext Application Language|journal=Network Working Group|date=July 2012|issue=Internet-Draft|url=httphttps://tools.ietf.org/pdfhtml/rfc4627.pdfdraft-kelly-json-hal-00 |formatpublisher=PDFIETF |accessdate=2316 JulyOctober 20142018 |date=7 June 2012}}</ref> and has since become available in two variations, each specific to JSON orand XML. The two associated [[MIME]] types are media type: application/hal+xml and media type: application/hal+json.<ref>{{cite book|last1=Richardson|first1=Leonard|last2=Ruby|first2=Mike Amundsen ; foreword by Sam|title=RESTful Web APIs|date=2013|publisher=O'Reilly|___location=Sebastopol, CA|isbn=978-1-4493-5806-8|edition=First edition.|chapter=7}}</ref>
 
HAL was created to be simple to use and easily applicable across different [[___domain (software engineering)|domains]] by avoiding the need to impose any requirements on how the project be structured. Maintaining this minimal impact approach, HAL has enabled developers to create general-purpose [[library (computing)|libraries]] which can be easily incorporated on any [[API]] that uses HAL.<ref{{Citation nameneeded|reason="rfc4627"/>RFC4627 does not mention HAL|date=October 2018}}
 
APIs that adopt HAL are generally more appealing to developers{{POV statement|date=March 2015}} because it simplifiessimplify the use of [[open-source software|open source]] libraries and makesmake it possible to interact with the [[application programming interface|API]] using JSON or XML. The alternative would be having to develop a [[proprietary format]] which in turn forces developers to learn how to use yet another foreign format.<ref name="stateless">{{cite web|last1=Kelly|first1=Mike|title=HAL - Hypertext Application Language A lean hypermedia type|url=httphttps://stateless.cogroup/hal_specification.html|accessdate=23 July 2014|date=2011-06-13}}</ref>
 
== Convention ==
HAL is structured in such a way as to represent elements based on two concepts: Resources and Links. Resources consist of [[URI]] links, embedded resources, your standard data (be it JSON or XML), and non URI links. Links have a target URI, as well as the name of the link (referred to as 'rel'), as well as optional properties designed to be mindful of deprecation and content negotiation.<ref name="stateless"/>
 
==Example==
General Resource<pre>
<syntaxhighlight lang="json">
{
"_links": {
Line 19 ⟶ 21:
"name": "HAL Cookbook"
}
</syntaxhighlight>
</pre>Embedded resource<pre>
<syntaxhighlight lang="json">
{
"_links": {
Line 30 ⟶ 34:
"_links": {
"self": {
"href": "http://author-example.com/api/author/shahadat"
}
},
"id": "shahadat",
"name": "Shahadat Hossain Khan",
"homepage": "http://author-example.com"
}
},
Line 40 ⟶ 45:
"name": "HAL Cookbook"
}
</syntaxhighlight>
</pre>Collections
{
<syntaxhighlight lang="json">
"_links": {
{
"self": {
"_links": {
"href": "<nowiki>http://example.com/api/book/hal-cookbook</nowiki>"
"self": },{
"href": "<nowiki>http://example.com/api/book/hal-cookbook</nowiki>"
"next": {
},
"href": "<nowiki>http://example.com/api/book/hal-case-study</nowiki>"
"next": },{
"href": "<nowiki>http://example.com/api/book/hal-case-study</nowiki>"
"prev": {
},
"href": "<nowiki>http://example.com/api/book/json-and-beyond</nowiki>"
"prev": },{
"href": "<nowiki>http://example.com/api/book/json-and-beyond</nowiki>"
"first": {
},
"href": "<nowiki>http://example.com/api/book/catalog</nowiki>"
"first": },{
"href": "<nowiki>http://example.com/api/book/catalog</nowiki>"
"last": {
},
"href": "<nowiki>http://example.com/api/book/upcoming-books</nowiki>"
"last": }{
"href": "<nowiki>http://example.com/api/book/upcoming-books</nowiki>"
},
}
},
"_embedded": {
"author": {
"_links": {
"self": {
"href": "<nowiki>http://author-example.com</nowiki>api/author/shahadat"
}
},
"id": "shahadat",
"name": "Shahadat Hossain Khan",
"homepage": "http://author-example.com"
}
}
},
"id": "hal-cookbook",
"name": "HAL Cookbook"
}
</syntaxhighlight>
 
==See also==
* [[HATEOAS]]
* [[CURIE]], (or Compact [[URI]])
 
== References ==
Line 81 ⟶ 91:
 
==External links==
* [https://tools.ietf.org/html/draft-kelly-json-hal-0811 JSON Hypertext Application Language latest draft-kelly-json-hal-08]
 
[[Category:JSON]]
Line 89 ⟶ 99:
[[Category:XML-based standards]]
[[Category:World Wide Web Consortium standards]]
 
 
{{Web-stub}}