SPARQL
Tentris implements SPARQL 1.1. This includes the following specifications.
- SPARQL 1.1 Query Language
- SPARQL 1.1 Update
- SPARQL 1.1 Service Description
- SPARQL 1.1 Federated Query
- SPARQL 1.1 Protocol
- SPARQL 1.1 Graph Store HTTP Protocol
Tentris also extends SPARQL beyond the standard (see Extensions).
The parts of the standard that Tentris does not support yet and deviations from the standards are listed in Limitations.
Endpoints
Tentris makes the following endpoints available for the SPARQL 1.1 Protocol and the SPARQL 1.1 Graph Store HTTP Protocol.
-
The
/sparqlendpoint accepts the read operations defined in SPARQL 1.1 Query Language (SELECT,ASK,CONSTRUCT, andDESCRIBE). -
The
/streamendpoint also accepts read operations. This endpoint is optimized for large responses, uses less RAM, and its response size is not limited. It should not be used with queries using the (non-silent)SERVICEgraph pattern (SPARQL 1.1 Federated Query). This is due to a fundamental limitation in HTTP streaming, which does not allow responses to report errors that may occur after the streaming of results has started. -
The
/updateendpoint accepts write operations defined in SPARQL 1.1 Update (e.g.,DELETE,INSERT, andLOAD). -
The
/graph-storeendpoint accepts graph store operations (e.g.,GET,POST,PUT, andDELETE).
Supported Formats
Query Responses
Tentris supports the following response formats for read operations.
- SPARQL JSON (Content-Type:
application/sparql-results+json), forSELECTandASKqueries - SPARQL XML (Content-Type:
application/sparql-results+xml), forSELECTandASKqueries - SPARQL CSV (Content-Type:
text/csv), forSELECTqueries - SPARQL TSV (Content-Type:
text/tab-separated-values), forSELECTqueries - RDF N-Triples (Content-Type:
application/n-triples), forCONSTRUCTandDESCRIBEqueries - RDF Turtle (Content-Type:
text/turtle), forCONSTRUCTandDESCRIBEqueries - RDF/XML (Content-Type:
application/rdf+xml), forCONSTRUCTandDESCRIBEqueries - JSON-LD (experimental) (Content-Type:
application/ld+json), forCONSTRUCTandDESCRIBEqueries
Load and GSP Input
Tentris supports the following input formats for LOAD and GSP operations.
- RDF N-Triples (Content-Type:
application/n-triples) - RDF Turtle (Content-Type:
text/turtle) - RDF N-Quads (Content-Type:
application/n-quads) - RDF TriG (Content-Type:
application/trig) - RDF/XML (Content-Type:
application/rdf+xml) - JSON-LD (experimental) (Content-Type:
application/ld+json)Note: The JSON-LD parser does not stream. The whole document is kept in memory while it is parsed. To protect against OOM attacks JSON-LD has its own limits for ingestion size (see the
limit-json-ld-*options in chapter Configuration File)
Quad formats are supported for the dataset extensions of LOAD and GSP (see chapter SPARQL Extensions).
Usage Examples
/sparql
Count all triples in the default graph.
curl -H "Content-Type: application/sparql-query" \
--data "SELECT (COUNT(*) AS ?c) WHERE { ?s ?p ?o }" "http://localhost:9080/sparql"
/stream
Select all triples in the default graph.
curl -H "Content-Type: application/sparql-query" \
--data "SELECT * WHERE { ?s ?p ?o }" "http://localhost:9080/stream"
/update
Add the triple <s> <p> <o> to the default graph.
curl -H "Content-Type: application/sparql-update" \
--data "INSERT DATA { <s> <p> <o> }" "http://localhost:9080/update"
To override the default LOAD strictness (default-online-update-mode) specified in the configuration,
use the mode parameter (the options are strict and lax). The mode parameter goes where the graph specification goes.
curl -H "Content-Type: application/sparql-update" \
--data "LOAD <https://example.com/triples.nt>" \
"http://localhost:9080/update?mode=lax"
/graph-store
GET
Retrieve the contents of the default graph as Turtle.
curl -H "Accept: text/turtle" "http://localhost:9080/graph-store?default"
POST
Insert additional data into the default graph.
curl -H "Content-Type: text/turtle" -X POST -T data.ttl \
"http://localhost:9080/graph-store?default"
To stream data generated by a command to Tentris, use curl's -T - option.
zstdcat compressed.ttl.zst | curl -H "Content-Type: text/turtle" -X POST -T - \
"http://localhost:9080/graph-store?default"
To override the default graph-store-protocol strictness (default-online-update-mode) specified in the configuration,
use the mode parameter (the options are strict and lax).
curl -H "Content-Type: text/turtle" -X POST -T data.ttl \
"http://localhost:9080/graph-store?default&mode=lax"
PUT
Replace the data in the default graph with other data.
curl -H "Content-Type: text/turtle" -X PUT -T data.ttl \
"http://localhost:9080/graph-store?default"
Streaming data generated by a command to Tentris and overriding the default graph-store-protocol strictness work the same way as for POST.
DELETE
Delete the contents of the default graph.
curl -X DELETE "http://localhost:9080/graph-store?default"