How to Use the SPARQL Endpoint
How to Use the SPARQL Endpoint
Currently, the SPARQL endpoint can be accessed via a web interface linked from every project's frontend page.
Additional to that, it can be used as an HTTP web service. By posting required parameters to the endpoint it will return the result of the SPARQL query in a specified format.
Note
You can use POST and GET for posting queries to the SPARQL endpoint. For longer queries POST should be used.
See HTTP Web Services Based on the SPARQL Endpoint for details.
See below for a detailed description:
Parameter | Required | Description |
---|---|---|
query | yes | contains the entire SPARQL query. See here for details. limitations: only SELECT and DESCRIBE/CONSTRUCT queries are allowed at the moment. |
queryname | yes, if query is null | the name of a named query that is defined in the SesameSetup.xml If a query name AND a query parameter is given, the named query is preferred. Either the query OR the query name parameter have to be set. |
[parameter] | no | A parameter that is used when a named query is specified with 'queryname' that requires parameters. |
content-type | no | Specifies the content type of the returned data. If no content-type is passed, text/xml will be used. The PoolParty project SPARQL endpoint also supports the CSV (comma separated values) and TSV (tab separated values) content types as output format. Please keep in mind when specifying the output format you have to write out the format, e.g. |
template | no | name of a local Velocity template or URL to a velocity template located on an openly accessible server. For these content-types there is already a predefined way of rendering the results: |
NoteOnly SELECT queries can be formatted with velocity templates. When the template parameter is used you also have to specify the content-type parameter. The content type has to be set to the content type produced by the velocity template. |
Errors
If an error occurs, either the HTTP status code 400 or 500 will be returned, an error message is provided to identify the exact problem.
Common errors are listed below:
Error | Status Code | Description |
---|---|---|
Template Error | 400 Bad Request | The template specified in the template parameter could not be found or contains errors. See error message or log files for specific information. |
Invalid Query | 400 Bad Request | The query was malformed or could not be evaluated. See error message or log files for specific information. |
Internal Error | 500 Internal Server Error | An exception occured while processing the request. See error message or log files for specific information. |
Limitations
The query timeout is set to 300 sec (=5 min). Queries that take longer than that will be aborted after 300 sec to ensure availability and performance of the system services.
SELECT query results are limited to 500. Although you can send multiple queries and split up the results with the LIMIT and OFFSET modifiers (see SPARQL specification).
Example
GET
http://vocabulary.semantic-web.at/PoolParty/sparql/semweb?query=SELECT%20%3Fs%20%3Fp%20%3Fo%20WHERE%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D%20LIMIT%2050%20OFFSET%200&content-type=application%2Fjson
POST
POST http://vocabulary.semantic-web.at/PoolParty/sparql/semweb content-type application/x-www-form-urlencoded query=SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 50 OFFSET 0&content-type=application/json
Example With Query Parameter
As described here queries defined in the SesameSetup.xml can have parameters (defined as %%%URI%%% in this example).
<entry> <key>DataOfSingleConcept</key> <value> <sparqlQueryParameterMap> <entry> <key>URI</key> <value><http://vocabulary.semantic-web.at/semweb/308></value> </entry> </sparqlQueryParameterMap> <sparqlQueryTemplate> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?Predicate ?Object WHERE { %%%URI%%% ?Predicate ?Object FILTER ( ?Predicate != rdf:type && ?Predicate != skos:semanticRelation) } </sparqlQueryTemplate> </value> </entry>
The call to the SPARQL endpoint using this query and the providing the query parameter would look like this:
http://vocabulary.semantic-web.at/PoolParty/sparql/semweb?queryname=DataOfSingleConcept&URI=<http://vocabulary.semantic-web.at/semweb/307>
In the REST Console browser extension this can be tested in the following way.
Define the URL of the API call and the method POST:
Set the Content-Type of the body to 'application/x-www-form-urlencoded' and pass the SPARQL query in the body:
Don't forget that the PoolParty API requires authentication (Basic Auth):