Instance SPARQL endpoint

Every dataset in TriplyDB has a SPARQL endpoint for the data it holds. The instance SPARQL endpoint answers questions about the instance itself: which datasets an account owns, which saved queries run against a dataset, which assets were uploaded last week, which flow runs failed. It holds the same information the HTTP API returns as JSON, as RDF, so one SPARQL query can combine what would otherwise take many API requests.

Where to find it

The endpoint is at /sparql on the instance's API address. On this page, API stands for that address, so the endpoint is:

https://API/sparql

It is a read-only SPARQL 1.1 endpoint.

A request without credentials sees what an anonymous visitor sees. To see what you see when you are logged in, send an API token in an Authorization: Bearer header:

curl -H "Authorization: Bearer TRIPLYDB_TOKEN" \
     --data-urlencode "query=select * { ?dataset a <https://triplydb.com/Triply/triplydb/def/Dataset> }" \
     https://API/sparql

The endpoint also works as the target of a service clause. A query you run on a dataset in the same instance can reach it like this, and the endpoint then answers with your access, as if you had sent your own token:

prefix datasetDef: <https://triplydb.com/Triply/triplydb/def/Dataset/>

select ?dataset ?name where {
  service <https://API/sparql> {
    ?dataset datasetDef:name ?name .
  }
}
limit 10

What it contains

The endpoint describes these kinds of resources:

  • accounts, both users and groups, and the members of each group;
  • datasets, with their graphs, services and assets;
  • saved queries, version by version;
  • stories;
  • flows and their runs, on instances where flows are switched on;
  • the instance itself: its addresses, version and instance-wide prefixes.

The same view as the API

The endpoint shows what the HTTP API shows you, with your access. Logged out, you see public resources only. Flows and flow runs are shown only to logged-in users.

Results are always up to date: every query reads the instance as it is when the query runs.

How resources are named

A resource is named by its API address, the URL that returns its JSON. A dataset is https://API/datasets/ACCOUNT/DATASET, an account is https://API/accounts/ACCOUNT. Resource IRIs are therefore different on each instance.

A resource has the same IRI wherever it appears. A dataset's owner is the IRI of the account, so a query can follow it to the account's own properties:

<https://API/datasets/academy/pokemon>
  a triplyDef:Dataset ;
  datasetDef:name "pokemon" ;
  datasetDef:owner <https://API/accounts/academy> .

<https://API/accounts/academy>
  a triplyDef:Account ;
  accountDef:accountName "academy" .

Renaming a dataset or account changes its API address, and with it its IRI here.

Classes and properties are the same everywhere

Classes and properties live in one namespace, https://triplydb.com/Triply/triplydb/def/, on every instance, so a query written against one instance runs unchanged on another. Each resource states its class with rdf:type: a dataset is a https://triplydb.com/Triply/triplydb/def/Dataset.

A property is named by its class and the key that holds the value in the API's JSON. The name of a dataset is https://triplydb.com/Triply/triplydb/def/Dataset/name, and the name of a saved query is https://triplydb.com/Triply/triplydb/def/QueryVersion/name. If you know the API, you can guess most property names.

Results use the prefix triplyDef: for the classes, and one prefix per class for its properties, such as datasetDef: for those of a dataset. Each class under classes and properties gives its namespace and prefix. A query has to declare each prefix it uses.

Classes and properties

Each class below lists its properties by their local name: prefix the class's namespace to get the full IRI, so name under Dataset is https://triplydb.com/Triply/triplydb/def/Dataset/name.

Account

A user or a group. Resources at /accounts/ACCOUNT.

Class https://triplydb.com/Triply/triplydb/def/Account (triplyDef:Account). Properties in the namespace https://triplydb.com/Triply/triplydb/def/Account/ (accountDef:).

Property Value type Description
accountName xsd:string The short name used in URLs.
name xsd:string The display name.
description xsd:string The account's description.
avatarUrl xsd:anyURI The account's picture.
accountType xsd:string "user" or "group".
accessLevel xsd:string A group's access level: "public", "internal" or "private".
createdAt xsd:dateTime When the account was created. On a user, shown to logged-in users only.
updatedAt xsd:dateTime When the account last changed.
email xsd:string The account's email address. Shown only to those the API shows it to, such as the user themselves.
verified xsd:boolean Whether the user has confirmed their email address.
mfaEnabled xsd:boolean Whether the user has set up two-factor authentication.
groups rdf:List of Account IRIs The groups a user belongs to.
ancestors rdf:List of IRIs The parent groups of a nested group, from the top down.
ancestors/accountName xsd:string A parent group's short name.
ancestors/name xsd:string A parent group's display name.

GroupMember

One user's membership of a group. Resources at /accounts/GROUP/members/USER.

Class https://triplydb.com/Triply/triplydb/def/GroupMember (triplyDef:GroupMember). Properties in the namespace https://triplydb.com/Triply/triplydb/def/GroupMember/ (groupMemberDef:).

Property Value type Description
user IRI of an Account The member.
role xsd:string What the member may do in the group, such as "owner" or "member".
inheritedFrom xsd:string For a membership inherited from a parent group, that group's short name.
createdAt xsd:dateTime When the user joined the group.
updatedAt xsd:dateTime When the membership last changed.

Dataset

Resources at /datasets/ACCOUNT/DATASET.

Class https://triplydb.com/Triply/triplydb/def/Dataset (triplyDef:Dataset). Properties in the namespace https://triplydb.com/Triply/triplydb/def/Dataset/ (datasetDef:).

Property Value type Description
name xsd:string The short name used in URLs.
displayName xsd:string The title.
description xsd:string The description, in Markdown.
avatarUrl xsd:anyURI The dataset's picture.
owner IRI of an Account The account that owns the dataset.
accessLevel xsd:string "public", "internal" or "private".
license xsd:string The license, such as "CC0 1.0".
createdAt xsd:dateTime When the dataset was created.
updatedAt xsd:dateTime When the dataset last changed.
tags rdf:List of xsd:string The dataset's tags.
prefixes rdf:List of IRIs The prefix declarations of the dataset.
prefixes/prefixLabel xsd:string A prefix, such as "skos".
prefixes/iri xsd:anyURI The namespace the prefix stands for.
download IRI, one per format A download of the whole dataset.
download/url xsd:anyURI The address of the download.
download/mediaType xsd:string Its format, such as "text/turtle" or "application/n-quads".

Graph

A graph of a dataset. Resources at /datasets/ACCOUNT/DATASET/graphs/ID.

Class https://triplydb.com/Triply/triplydb/def/Graph (triplyDef:Graph). Properties in the namespace https://triplydb.com/Triply/triplydb/def/Graph/ (graphDef:).

Property Value type Description
graphName xsd:anyURI The graph's IRI, by which queries address it.
numberOfStatements xsd:integer The number of statements in the graph.
uploadedAt xsd:dateTime When the graph was uploaded, for a graph that came from an upload.
importedAt xsd:dateTime When the graph was imported, for a graph that came from another dataset.
importedFrom IRI Where an imported graph came from, with importedFrom/dataset and importedFrom/graphName.
importedFrom/dataset IRI of a Dataset The dataset an imported graph came from.
importedFrom/graphName xsd:string The graph's name in that dataset.

Service

A service of a dataset. Resources at /datasets/ACCOUNT/DATASET/services/SERVICE.

Class https://triplydb.com/Triply/triplydb/def/Service (triplyDef:Service). Properties in the namespace https://triplydb.com/Triply/triplydb/def/Service/ (serviceDef:).

Property Value type Description
name xsd:string The service's name.
type xsd:string The kind of store, such as "virtuoso", "jena" or "elasticSearch".
version xsd:string The version of the store.
status xsd:string Where the service has got to, such as "running" or "error".
endpoint xsd:anyURI The address to send queries to. Absent until the service runs.
outOfSync xsd:boolean Whether the dataset has changed since the service loaded it.
numberOfLoadedStatements xsd:integer The statements the service holds.
numberOfGraphs xsd:integer The graphs the service holds once it has finished loading.
numberOfLoadedGraphs xsd:integer The graphs loaded so far.
numberOfGraphErrors xsd:integer The graphs that failed to load.
error IRI Why the service failed, when it did, with error/message and error/code.
error/message xsd:string The error message.
error/code xsd:integer The error's status code.
loadedAt xsd:dateTime When the service last finished loading.
createdAt xsd:dateTime When the service was created.

Asset

A file stored in a dataset. Resources at /datasets/ACCOUNT/DATASET/assets/ID.

Class https://triplydb.com/Triply/triplydb/def/Asset (triplyDef:Asset). Properties in the namespace https://triplydb.com/Triply/triplydb/def/Asset/ (assetDef:).

Property Value type Description
assetName xsd:string The file name.
url xsd:anyURI The download address of the latest version.
createdAt xsd:dateTime When the asset was first uploaded.
versions rdf:List of AssetVersion IRIs Every version, oldest first.

AssetVersion

One uploaded version of an asset. Its IRI is its download address.

Class https://triplydb.com/Triply/triplydb/def/AssetVersion (triplyDef:AssetVersion). Properties in the namespace https://triplydb.com/Triply/triplydb/def/AssetVersion/ (assetVersionDef:).

Property Value type Description
url xsd:anyURI The download address of this version.
fileSize xsd:integer The size in bytes.
uploadedAt xsd:dateTime When this version was uploaded.
uploadedBy IRI The account that uploaded this version, with uploadedBy/accountName and uploadedBy/name.
uploadedBy/accountName xsd:string The short name of the account that uploaded it.
uploadedBy/name xsd:string That account's display name.

QueryVersion

One version of a saved query. Resources at /queries/ACCOUNT/QUERY/VERSION.

Class https://triplydb.com/Triply/triplydb/def/QueryVersion (triplyDef:QueryVersion). Properties in the namespace https://triplydb.com/Triply/triplydb/def/QueryVersion/ (queryVersionDef:).

Property Value type Description
name xsd:string The short name used in URLs.
displayName xsd:string The title.
description xsd:string The description, in Markdown.
owner IRI of an Account The account that owns the query.
accessLevel xsd:string "public", "internal" or "private".
dataset IRI of a Dataset The dataset the query runs against.
service xsd:anyURI The SPARQL endpoint the query is sent to.
serviceConfig IRI What the query runs on, with serviceConfig/type and serviceConfig/service.
serviceConfig/type xsd:string The kind of service the query runs on, such as "speedy" or "virtuoso".
serviceConfig/service IRI of a Service The service the query runs on. Absent for Speedy, TriplyDB's built-in engine.
version xsd:integer This version's number.
numberOfVersions xsd:integer How many versions the query has.
versionsInformation rdf:List of IRIs Every version of the query.
versionsInformation/version xsd:integer A version's number.
versionsInformation/accountName xsd:string The short name of the account that saved it.
versionsInformation/name xsd:string That account's display name.
versionsInformation/avatar xsd:anyURI That account's picture.
versionsInformation/createdAt xsd:dateTime When it was saved.
requestConfig IRI How the query is sent, with the properties below that start with requestConfig/.
requestConfig/payload IRI The SPARQL text, with requestConfig/payload/query or requestConfig/payload/update.
requestConfig/payload/query xsd:string The SPARQL text of a query.
requestConfig/payload/update xsd:string The SPARQL text of an update.
requestConfig/type xsd:string The query form, such as "select" or "construct".
requestConfig/valid xsd:boolean Whether the SPARQL text parses.
requestConfig/ldFrame rdf:JSON The JSON-LD frame applied to the results, as an rdf:JSON literal.
variables rdf:List of IRIs The query's variables.
variables/name xsd:string A variable's name.
variables/defaultValue xsd:string Its default value.
variables/required xsd:boolean Whether a value is required.
variables/allowedValues rdf:List of xsd:string The values it accepts, when limited.
variables/termType xsd:string Whether it takes an IRI ("NamedNode") or a literal ("Literal").
variables/datatype xsd:anyURI The datatype of a literal value.
variables/language xsd:string The language tag of a literal value.
tags rdf:List of xsd:string The query's tags.
link xsd:anyURI The query's API address.
createdAt xsd:dateTime When the query was created.
updatedAt xsd:dateTime When the query last changed.
lastQueriedAt xsd:dateTime When the query was last run.

Story

A data story. Resources at /stories/ACCOUNT/STORY.

Class https://triplydb.com/Triply/triplydb/def/Story (triplyDef:Story). Properties in the namespace https://triplydb.com/Triply/triplydb/def/Story/ (storyDef:).

Property Value type Description
name xsd:string The short name used in URLs.
displayName xsd:string The title.
owner IRI of an Account The account that owns the story.
accessLevel xsd:string "public", "internal" or "private".
link xsd:anyURI The story's page in the console.
bannerUrl xsd:anyURI The story's banner image.
content rdf:List of IRIs The story's blocks, in order.
content/type xsd:string "paragraph" or "query".
content/paragraph xsd:string A paragraph's text, in Markdown.
content/query IRI of a QueryVersion The saved query a query block shows.
content/caption xsd:string A query block's caption.
tags rdf:List of xsd:string The story's tags.
createdAt xsd:dateTime When the story was created.
updatedAt xsd:dateTime When the story last changed.

Flow

A flow. Resources at /flows/blueprints/ACCOUNT/ID.

Class https://triplydb.com/Triply/triplydb/def/Flow (triplyDef:Flow). Properties in the namespace https://triplydb.com/Triply/triplydb/def/Flow/ (flowDef:).

Property Value type Description
id xsd:string The flow's identifier.
label xsd:string The flow's name.
owner IRI of an Account The account that owns the flow.
createdBy IRI of an Account The user who created the flow.
accessLevel xsd:string "public", "internal" or "private".
createdAt xsd:dateTime When the flow was created.
updatedAt xsd:dateTime When the flow last changed.

FlowRun

One run of a flow. Resources at /flows/runs/ID.

Class https://triplydb.com/Triply/triplydb/def/FlowRun (triplyDef:FlowRun). Properties in the namespace https://triplydb.com/Triply/triplydb/def/FlowRun/ (flowRunDef:).

Property Value type Description
blueprint IRI of a Flow The flow that ran.
startedBy IRI of an Account The user who started the run.
createdAt xsd:dateTime When the run started.
finishedAt xsd:dateTime When the run ended.
status xsd:string "waiting", "pending", "running", "finished", "failed", "timeout" or "aborted".
statusMessage xsd:string Why the run ended as it did, when it failed.

Instance

The TriplyDB instance itself, one resource at /info.

Class https://triplydb.com/Triply/triplydb/def/Instance (triplyDef:Instance). Properties in the namespace https://triplydb.com/Triply/triplydb/def/Instance/ (instanceDef:).

Property Value type Description
consoleUrl xsd:anyURI The address of the web interface.
apiUrl xsd:anyURI The address of the API.
contactEmail xsd:string The address for questions about this instance.
version xsd:string The TriplyDB version the instance runs.
buildDate xsd:string When the running build was made. Shown to logged-in users only.
buildId xsd:string The identifier of the running build. Shown to logged-in users only.
defaultAccessLevel xsd:string The access level of a new dataset, query or story created without one.
maxAccessLevel xsd:string The most open access level anything on the instance may have.
prefixes rdf:List of IRIs The prefix declarations that apply to every dataset.
prefixes/prefixLabel xsd:string A prefix.
prefixes/iri xsd:anyURI The namespace it stands for.
instanceStartedAt xsd:dateTime When the instance last started.
instanceUpdatedAt xsd:dateTime When the instance was last upgraded.

Examples

Each example is a complete query for the endpoint.

Datasets of an account

The datasets of an account, with their license where one is set:

prefix accountDef: <https://triplydb.com/Triply/triplydb/def/Account/>
prefix datasetDef: <https://triplydb.com/Triply/triplydb/def/Dataset/>

select ?dataset ?name ?license where {
  ?owner accountDef:accountName "academy" .
  ?dataset datasetDef:owner ?owner ;
           datasetDef:name ?name .
  optional { ?dataset datasetDef:license ?license }
}
order by ?name

Datasets with a tag

The datasets tagged geo:

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix datasetDef: <https://triplydb.com/Triply/triplydb/def/Dataset/>

select ?dataset ?name where {
  ?dataset datasetDef:tags/rdf:rest*/rdf:first "geo" ;
           datasetDef:name ?name .
}

Saved queries and their SPARQL

The saved queries of an account, with their SPARQL text and the dataset they run against:

prefix triplyDef: <https://triplydb.com/Triply/triplydb/def/>
prefix accountDef: <https://triplydb.com/Triply/triplydb/def/Account/>
prefix queryVersionDef: <https://triplydb.com/Triply/triplydb/def/QueryVersion/>

select ?name ?version ?dataset ?queryText where {
  ?query a triplyDef:QueryVersion ;
         queryVersionDef:owner/accountDef:accountName "academy" ;
         queryVersionDef:name ?name ;
         queryVersionDef:version ?version ;
         queryVersionDef:dataset ?dataset ;
         queryVersionDef:requestConfig/queryVersionDef:requestConfig\/payload/queryVersionDef:requestConfig\/payload\/query ?queryText .
}

Recent asset uploads

The most recent asset uploads, with their size and who uploaded them:

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix assetDef: <https://triplydb.com/Triply/triplydb/def/Asset/>
prefix assetVersionDef: <https://triplydb.com/Triply/triplydb/def/AssetVersion/>

select ?fileName ?size ?uploadedAt ?uploader where {
  ?asset assetDef:assetName ?fileName ;
         assetDef:versions/rdf:rest*/rdf:first ?version .
  ?version assetVersionDef:fileSize ?size ;
           assetVersionDef:uploadedAt ?uploadedAt .
  optional { ?version assetVersionDef:uploadedBy/assetVersionDef:uploadedBy\/accountName ?uploader }
}
order by desc(?uploadedAt)
limit 10

Failed flow runs

The flow runs that failed, with the flow they belong to and the reason. Flows are shown only to logged-in users, so this query needs a token:

prefix flowDef: <https://triplydb.com/Triply/triplydb/def/Flow/>
prefix flowRunDef: <https://triplydb.com/Triply/triplydb/def/FlowRun/>

select ?flowLabel ?startedAt ?message where {
  ?run flowRunDef:status "failed" ;
       flowRunDef:createdAt ?startedAt ;
       flowRunDef:blueprint/flowDef:label ?flowLabel .
  optional { ?run flowRunDef:statusMessage ?message }
}
order by desc(?startedAt)

Instance version and addresses

The instance's version and addresses:

prefix triplyDef: <https://triplydb.com/Triply/triplydb/def/>
prefix instanceDef: <https://triplydb.com/Triply/triplydb/def/Instance/>

select ?version ?consoleUrl ?apiUrl where {
  ?instance a triplyDef:Instance ;
            instanceDef:version ?version ;
            instanceDef:consoleUrl ?consoleUrl ;
            instanceDef:apiUrl ?apiUrl .
}