Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SPARQL

Tentris implements SPARQL 1.1. This includes the following specifications.

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 /sparql endpoint accepts the read operations defined in SPARQL 1.1 Query Language (SELECT, ASK, CONSTRUCT, and DESCRIBE).

  • The /stream endpoint 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) SERVICE graph 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 /update endpoint accepts write operations defined in SPARQL 1.1 Update (e.g., DELETE, INSERT, and LOAD).

  • The /graph-store endpoint accepts graph store operations (e.g., GET, POST, PUT, and DELETE).

Supported Formats

Query Responses

Tentris supports the following response formats for read operations.

  • SPARQL JSON (Content-Type: application/sparql-results+json), for SELECT and ASK queries
  • SPARQL XML (Content-Type: application/sparql-results+xml), for SELECT and ASK queries
  • SPARQL CSV (Content-Type: text/csv), for SELECT queries
  • SPARQL TSV (Content-Type: text/tab-separated-values), for SELECT queries
  • RDF N-Triples (Content-Type: application/n-triples), for CONSTRUCT and DESCRIBE queries
  • RDF Turtle (Content-Type: text/turtle), for CONSTRUCT and DESCRIBE queries
  • RDF/XML (Content-Type: application/rdf+xml), for CONSTRUCT and DESCRIBE queries
  • JSON-LD (experimental) (Content-Type: application/ld+json), for CONSTRUCT and DESCRIBE queries

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"