<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Describing Linked Data Platform Applications with the Hydra Core Vocabulary</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Nandana Mihindukulasooriya</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Raul Garc a-Castro</string-name>
          <email>rgarcia@fi.upm.es</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Ontology Engineering Group, Universidad Politecnica de Madrid</institution>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <fpage>33</fpage>
      <lpage>36</lpage>
      <abstract>
        <p>The Linked Data Platform (LDP) W3C Recommendation provides a standard protocol and a set of best practices for the development of read-write Linked Data applications based on HTTP access to Web resources that describe their state using the RDF data model. The Hydra Core Vocabulary is an initiative to de ne a lightweight vocabulary to describe hypermedia-driven Web APIs. By specifying concepts commonly used in Web APIs such as hypermedia controls with their explicit semantics, the Hydra Core Vocabulary enables creation of generic API clients. This paper discusses how LDP applications can bene t from the Hydra Core Vocabulary to describe their APIs. Using Hydra, an LDP application can enable generic clients by describing the semantics of the expected and returned data. Having an API documentation will be a more e cient approach for most LDP applications than gathering information about a ordences and restrictions in each HTTP interaction. Nevertheless, there are potential con icts that have to be taken into consideration such as Hydra collections vs LDP containers or Hydra paging vs LDP paging.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>The Hydra Core Vocabulary2 is developed by the W3C Hydra community
group and it provides a lightweight vocabulary to create hypermedia-driven
Web APIs. By specifying a number of concepts commonly used in Web APIs, it
enables a server to advertise valid state transitions following REST best practices.
This paper discusses how LDP applications can bene t from Hydra to describe
their APIs.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Example</title>
      <p>LDP applications use HTTP headers to advertise the information about their
a ordances. For instance, when a resource is retrieved using a GET operation, the
LDP server provides an \Allow" header (See Fig 1), which lists the allowed HTTP
operations. Further, it provides an \Accept-Post" header, and an \Accept-Patch"
header that advertise the media types accepted by the respective operations.</p>
      <p>However, when generic RDF media types such as `text/turtle ' or
`application/ld+json' are used, the clients cannot discover the information about the
application-speci c structural or value constraints. For example, an
application may require clients to use a certain vocabulary and may have cardinality
restrictions. The LDP working group deferred addressing this issue until the
W3C RDF Data Shapes3 working group provides a mechanism for de ning
such constraints. As of now, one alternative is to use custom media types (e.g.,
application/vnd.myapp-concept+json) but this approach does not scale as the
client will have to be aware of large number of custom media types and also
increases coupling between the server and the client. If the application restrictions
are de ned in media type semantics, a new media type has to be introduced
whenever those restrictions evolve.</p>
      <p>A better alternative is to compliment LDP applications with a Hydra API
documentation (see an example4). This allows the application to advertise the
restrictions on the input data and possible outcomes using hydra:supportedClass,
hydra:supportedOperation, hydra:supportedProperty and other properties of
hydra:apiDocumentation. In such cases, the API documentation can be advertised
using both hydra:apiDocumentation and ldp:constrainedBy Link relations.
Further, the Hydra Core Vocabulary can be extended to provide information that
goes beyond the media type scope such as the headers supported and the value
restrictions on the supported headers5.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Potential con icts</title>
      <p>Even though the Hydra Core Vocabulary can be used to describe APIs of LDP
applications, there are some potential con icts that have to be taken into account</p>
      <sec id="sec-3-1">
        <title>2 http://www.hydra-cg.com/spec/latest/core/ 3 http://www.w3.org/2014/data-shapes/charter 4 http://nandana.github.io/ldp-hydra/api.json 5 http://github.com/HydraCG/Specifications/issues/99</title>
        <p>HTTP /1.1 200 OK
Content - Type : application / ld + json ;
Link : &lt; http :// www . w3 . org / ns / ldp # Resource &gt;; rel =" type "
Allow : OPTIONS , HEAD , GET , PUT , PATCH , DELETE
Accept - Patch : text / ldpatch
Content - Length : 250
ETag : W / '123456789 '
{
}
" @context ": ...
" @id ": " http :// example . org / product /a",
" issueTracker ": " http :// example . org / products /a/ bugs "</p>
        <p>Listing 1.1. Fig 1. GET response (product LDPR)
because the LDP speci cation and the Hydra Core Vocabulary have overlapping
features such as LDP Containers vs Hydra Collections and LDP Paging vs Hydra
Paged Collections.
3.1</p>
        <sec id="sec-3-1-1">
          <title>LDP Container vs hydra:Collection</title>
          <p>Organizing a set of Linked Data resources into a collection is a common use case
in many Linked Data applications. Both LDP and Hydra provide constructs
to maintain enumerations of related resources. LDP Containers act both as
enumerations of related resources and creation factories for new resources. There
are three types of LDP containers depending on the di erent levels of exibility
needed by an application: Basic, Direct, and Indirect. LDP clients can use the
Prefer header6 to provide a hint to the server about the appropriate response
to a client's needs. Hydra collections are more simple and list the resources
in the collection using the hydra:member property. However, Hydra collections
are exible and can be extended while describing their behaviour using the
API documentation. An LDP Direct Container can simultaneously exist as a
Hydra collection by de ning hydra:member as the membership property and its
behaviour be described using a Hydra API documentation.
3.2</p>
        </sec>
        <sec id="sec-3-1-2">
          <title>LDP Paging vs hydra:PagedCollection</title>
          <p>Because some resources can get large, sometimes it becomes necessary to split such
resources into pages when served to a client. Both the LDP speci cation and the
Hydra Core Vocabulary provide constructs needed for paging. The LDP Paging
speci cation7 uses the Link headers to specify that a served representation is a
page (e.g., Link: &lt;http://www.w3.org/ns/ldp#Page&gt;; rel=\type"). Further, it</p>
        </sec>
      </sec>
      <sec id="sec-3-2">
        <title>6 http://www.ietf.org/rfc/rfc7240.txt 7 http://www.w3.org/TR/ldp-paging/</title>
        <p>provides links to the \canonical" resource (e.g., Link: &lt;http://example.org/res&gt;;
rel=\canonical"), and the next page. Optionally LDP servers may provide links
to the rst, last, and previous pages using similar Link headers.</p>
        <p>Further, LDP Paging de nes parameters that a client can use to provide hints
to a server about the representations that it can handle (e.g., max-triple-count,
max-kbyte-count, and max-member-count ). When ordering is important, LDP
Paging allows servers to specify an ldp:pageSortCriteria using ldp:pageSortOrder,
ldp:pageSortPredicate, and optionally a ldp:pageSortCollation properties. In such
cases, the LDP server ensures that all the members on any single page have
the proper sort order with relation to all members on any next and previous
pages. The ldp:pageSortCriteria reuses SPARQL8 SELECTs ORDER BY clause
to de ne ordering.</p>
        <p>Similarly Hydra de nes a hydra:PagedCollection which may include links
to rstPage, nextPage, previousPage, and lastPage. Further, it may contain
information about total items of the resource and the number of items included in
a page. However, unlike LDP Paging, these information are included in the page
content itself rather than in Link relation headers. Having these two di erent
approaches makes it a bit cumbersome for the paging clients as they have to be
aware and be able to handle both approaches.
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Conclusion</title>
      <p>This paper discusses the possibility of using the Hydra Core Vocabulary for
describing LDP applications. The early attempts to describe LDP applications
with a Hydra API documentation shows that it is possible even though there are
some con icts to take care of. While collections can coexist in both cases, the
paging clients need to be aware of two di erent approaches. Thus, there is also
an opportunity for the two W3C working groups to collaborate and learn from
each other than implementing two distinct mechanisms for a similar purpose
such as paging.</p>
      <p>Acknowledgments: The authors are supported by the 4V
(TIN2013-46238-C42-R) project.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Heath</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bizer</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>Linked Data: Evolving the Web into a Global Data Space</article-title>
          .
          <article-title>Synthesis lectures on the semantic web: theory and technology 1(1</article-title>
          ) (
          <year>February 2011</year>
          )
          <volume>1</volume>
          {
          <fpage>136</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Mihindukulasooriya</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Garc</surname>
            a-Castro,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Esteban</given-names>
            <surname>Gutierrez</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          :
          <article-title>Linked Data Platform as a novel approach for Enterprise Application Integration</article-title>
          .
          <source>In: Proceedings of the 4th International Workshop on Consuming Linked Data (COLD2013)</source>
          , Sydney, Australia (
          <year>October 2013</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>