Platform API‎ > ‎

Store SPARQL Service

URI Pattern

Each item in the store has its own URI based on its unique identifier:

http://api.talis.com/stores/{storename}/services/sparql


Resource Operations

URI PatternMethodRequest BodySemanticsCapability required
/services/sparqlGETRetrieve a simple query formNone
/services/sparql?query=GETPerform a SPARQL searchNone
POSTapplication/x-www-form-urlencoded parametersPerform a SPARQL searchNone


Request Parameters

ParameterRequired?DescriptionValues
queryYesThe SPARQL query to performA SPARQL query
outputNoSpecify the output formatSee below
callback  NoSpecify the callback function for a JSONP requestA JSONP callback function 


Additional Options & Restrictions


Specifying the Data Set

The SPARQL service associated with a platform store uses a fixed default (background) graph. The contents of this graph is the contents of the Metabox.

The service does not support specifying the dataset in either the protocol (using default-graph-uri and named-graph-uri parameters) or within the SPARQL query itself (using FROM and FROM NAMED).

The Store Multisparql Service does provide some additional options for querying multiple graphs.


Output Formats

The following table summarizes the different output formats supported by the SPARQL service. The output types can be selected using Content Negotiation using either the Accept header or the output parameter. The Sparql Service also supports javascript (jsonp) output (see the JSONP Javascript Output section below).

SPARQL Query TypeOutput Param ValueMime TypeSchema
SELECTxmlapplication/sparql-results+xmlSPARQL Query Results XML Format
jsonapplication/sparql-results+jsonSerializing SPARQL Query Results in JSON Format
ASKxmlapplication/sparql-results+xmlSPARQL Query Results XML Format
jsonapplication/sparql-results+jsonSerializing SPARQL Query Results in JSON Format
CONSTRUCTxml or rdfapplication/rdf+xmlRDF/XML Syntax
jsonapplication/jsonRDF/JSON Syntax
ntriplestext/plainN-Triples
turtletext/turtleTurtle
DESCRIBExml or rdfapplication/rdf+xmlRDF/XML Syntax
jsonapplication/jsonRDF/JSON Syntax
ntriplestext/plainN-Triples
turtletext/turtleTurtle

Note: for backwards compatibility, where the text/turtle media type is listed, the deprecated application/x-turtle media type is also supported, though it is given a lower weighting during Content Negotiation

JSONP (Javascript) Output

The following table summarizes the content-negotiation logic for obtaining the sparql results as JSONP using the output (or Accept header) and the callback parameter (see here for all the logic). The output parameter, if set, will override the Accept header.

Output Param ValueAccept Header CallbackOutput Format
 jsonapplication/javascript {valid javascript identifier}JSONP with mime-type application/javascript
{NOT json, e.g., xml}application/javascript {valid javascript identifier} XML format depending on the query type - see Output Formats section above. (Because output overrides the Accept header and callback)
json */* {valid javascript identifier}JSONP with mime-type application/javascript

 */*{valid javascript identifier}JSONP with mime-type application/javascript 
  {valid javascript identifierJSONP with mime-type application/javascript ("If no Accept header field is present, then it is assumed that the client accept all media types")
json {valid javascript identifier} JSONP with mime-type application/javascript

 application/javascript{valid javascript identifier} JSONP with mime-type application/javascript
 json  JSON format (see table in Output Formats section above). This is the case if callback is either empty or doesn't exist.
 Is set e.g., application/xml (NOT application/javascript OR */* OR no header){valid javascript identifier}XML format depending on the query type - see Output Formats section above. (Because no output parameter is set and the Accept header does not include javascript.)

It is the combination of the output parameter (or Accept header) and the callback parameter that specifies JSONP output. If the output parameter is any other value than json, (or the Accept header is not application/javascript or */*) then the callback parameter will be ignored.

Only valid javascript identifiers are allowed as the callback parameter value.

Restrictions on Query Times

The SPARQL service endpoint enforces a maximum execution time for all SPARQL queries. This is to ensure that long-running queries do not degrade the service for other users. Queries that exceed the maximum allowable time will be terminated and a 500 Internal Server error response returned.


SPARQL Extensions

The SPARQL service endpoint includes support for some extensions to the SPARQL query language. The full list of SPARQL Extensions are documented separately.


Further Reading

The official SPARQL protocol specification has additional information on specifying queries, response formats and error conditions.

Comments