LinkedDataFragments / Server.js

A Triple Pattern Fragments server for Node.js
http://linkeddatafragments.org/
Other
178 stars 59 forks source link

Is it possible to distinguish between standard SPARQL endpoint and LDF endpoint #20

Closed m1ci closed 9 years ago

m1ci commented 9 years ago

Hi, I was wondering whether it is possible "automatically" to distinguish between standard SPARQL endpoint and LDF endpoint?

Say you have endpoint URL http://example.com/endpoint but we your not aware whether this is LDF or standard SPARQL endpoint. Being able to automatically detect the type of endpoint will help to choose the right client type (for LDF or standard LDF). Thanks!

RubenVerborgh commented 9 years ago

Hi @m1ci,

First of all, a little nitpick: you probably want to distinguish SPARQL endpoints from TPF servers. With "LDF", we mean all servers that publish Linked Data in some way (so this also includes SPARQL endpoints). A "TPF" (Triple Pattern Fragments) server is a specific kind of LDF server that offers access to triples by triple pattern.

The reliable way to detect a TPF interface is to look inside of the response. The TPF interface is self-describing; it literally says clients what it does. For example, take the resource with URL http://bit.ly/1I0eNgt (I purposely used a URL shortener here so we can't see any clues). If you get an RDF-based representation

$ curl -L -H "Accept: text/turtle" http://bit.ly/1I0eNgt

it will contain the following triples (reformatted for readability):

    <http://fragments.dbpedia.org/2015/en#dataset> a void:Dataset, hydra:Collection;
        void:subset <>;
        hydra:search [
          hydra:template "http://fragments.dbpedia.org/2015/en{?subject,predicate,object}";
          hydra:mapping [
            hydra:variable "subject";
            hydra:property rdf:subject.
          ],[
            hydra:variable "predicate";
            hydra:property rdf:predicate.
          ],[
            hydra:variable "object";
            hydra:property rdf:object.
          ]
        ].

Or, in human language:

This resource is a subset of the DBpedia 2015 dataset. You can search it by RDF subject, predicate, and object.

In other words: "this server supports the TPF interface".

If a server replies with the above, it supports the TPF interface. If responses do not contain this, it is certainly not a TPF interface. Might be a SPARQL endpoint, might be something else.

You should thus request the resource and look for the pattern

   _:dataset void:subset <>;
       hydra:search [
         hydra:mapping [ hydra:property rdf:subject ],
         hydra:mapping [ hydra:property rdf:predicate ],
         hydra:mapping [ hydra:property rdf:object ]
       ].

where "_:dataset" can be any identifier, and <> is the URL of the resource you just requested.

m1ci commented 9 years ago

Oh, I see, makes sense! Will indeed consider this approach. Thanks!