Read and write RDF data from and to LinkedDataHub dataspaces over HTTP

LinkedDataHub implements a uniform, generic RESTful Linked Data API as defined by the SPARQL 1.1 Graph Store HTTP Protocol. It adds a few conventions of its own, however — such as automatic document metadata — as well as some constraints.

This page covers what applies to every request. Documents describes the methods for managing document data, SPARQL endpoint the query protocol, Linked Data proxy browsing external data and other dataspaces, and System endpoints the paths served outside the document hierarchy.

Authentication

The LinkedDataHub UI supports two authentication methods:

See how those authentication methods can be configured or how to get an account on LinkedDataHub.

HTTP API access using the CLI or curl currently does not support the OIDC method.

Access control

All HTTP access to documents is subject to access control. Requesting a document with insufficient access rights will result in a 403 Forbidden response. That means either:

  • the user is not authenticated and public access to the document is not allowed
  • the user is authenticated but the associated agent does not have an authorization to perform the action on the requested document

Content negotiation

LinkedDataHub implements proactive content negotiation based on the request Accept header value. The following RDF media types are supported:

Supported formats and their media types
Format Media type Direction
Turtle text/turtle Request, response
N-Triples application/n-triples Request, response
RDF/XML application/rdf+xml Request, response
JSON-LD application/ld+json Request, response
RDF/POST application/x-www-form-urlencoded Request only

The same document, negotiated as N-Triples:

GET /products/1/ HTTP/1.1
Host: localhost:4443
Accept: application/n-triples

HTTP/1.1 200 OK
Content-Type: application/n-triples
ETag: "1e635b4-ntriples"

<https://localhost:4443/products/1/#this> <https://schema.org/name> "Chai" .
…

Error responses

LinkedDataHub provides machine-readable error responses in the requested RDF format. An example of 403 Forbidden:

@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .
@prefix http: <http://www.w3.org/2011/http#> .
@prefix sc:   <http://www.w3.org/2011/http-statusCodes#> .
@prefix dct:  <http://purl.org/dc/terms/> .

[ a http:Response ;
    dct:title "Access not authorized" ;
    http:reasonPhrase "Forbidden" ;
    http:sc sc:Forbidden ;
    http:statusCodeValue "403"^^xsd:long
] .

Hypermedia

Responses describe their context in Link headers (RFC 8288), so a client discovers the endpoint, the ontology or the administration dataspace from the response instead of constructing their URIs. All the links are folded into a single Link header.

Link relations in LinkedDataHub responses
Relation Target
http://www.w3.org/ns/sparql-service-description#endpoint The dataspace's SPARQL endpoint
https://w3id.org/atomgraph/linkeddatahub/dataspaces#dataspace The dataspace the response belongs to
https://w3id.org/atomgraph/linkeddatahub/dataspaces#ontology The dataspace's ontology, when it declares one
https://w3id.org/atomgraph/linkeddatahub/dataspaces#admin The base URI of the administration dataspace: on end-user dataspace responses its pair, on administration dataspace responses its own
https://w3id.org/atomgraph/client#stylesheet The dataspace's XSLT stylesheet, when it declares one
http://www.w3.org/ns/auth/acl#agent The authenticated agent, when there is one
http://www.w3.org/ns/auth/acl#mode One link per access mode the agent holds on the requested document (acl:Read, acl:Append, acl:Write); historical versions advertise acl:Read at most
timemap, timegate, original, self On versioned documents: the Memento relations of RFC 7089

On a proxied response the local relations are left out and the remote resource's own Link headers are forwarded instead, which is how federation finds the remote SPARQL endpoint; acl:agent is kept, since it describes the request.

curl -k -I -E cert.pem:password https://localhost:4443/

Caching

GET and HEAD RDF responses from the backend triplestores (not LinkedDataHub responses) are cached automatically by LinkedDataHub using Varnish as an HTTP proxy cache. You can check the age of the response by inspecting the Age response header (the value is in seconds). Anonymous SPARQL queries are cached too, on their body.

LinkedDataHub sends ETag response headers derived from a digest of the document's URL and its RDF content. Every representation (HTML, RDF/XML, Turtle, etc.) gets a distinct ETag value, and language-negotiated HTML representations factor the accepted languages into the tag. Treat the value as opaque: it is a validator to quote back in a conditional request, and nothing about the document can be read from it.

HTML responses carry a Content-Language negotiated against the languages the UI ships with, and advertise Vary: Accept-Language so shared caches keep the renderings apart.

Caching of LinkedDataHub responses can be enabled on the nginx HTTP proxy server by uncommenting the add_header Cache-Control directives in the platform/nginx.conf.template file. Caching of /uploads/ and /static/ namespaces is enabled by default.