Web Algebra
v2.0.4Composable Linked Data and SPARQL operations, and LinkedDataHub content tools
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
GET
Retrieves RDF data from a named graph using HTTP GET. The URL serves as both the resource identifier and the named graph address in systems with direct graph identification. Returns the RDF graph describing the resource at that URL.
| Parameter | Type | Description |
|---|---|---|
url * | string | The URL to fetch RDF data from. This should be a valid URL pointing to RDF content. |
PATCH
Updates RDF data in a named graph using HTTP PATCH with SPARQL Update. The URL serves as both the resource identifier and the named graph address in systems with direct graph identification. Updates the RDF graph at that URL using the SPARQL update payload provided in the `update` argument. Only INSERT/WHERE and DELETE WHERE forms of SPARQL Update are supported by PATCH! Only a single update operation is allowed. Returns True if the operation was successful, False otherwise. Note: This operation does not return the updated graph, it only confir…
| Parameter | Type | Description |
|---|---|---|
update * | string | The SPARQL update string to execute. |
url * | string | The URL to send the SPARQL UPDATE to. This should be a valid URL. |
POST
Creates or appends RDF data to a named graph using HTTP POST. The URL serves as both the resource identifier and the named graph address in systems with direct graph identification. Creates or adds to the RDF graph (provided as JSON-LD payload) at that URL. Returns True if the operation was successful, False otherwise. Note: This operation does not return the updated graph, it only confirms the success of the operation.
| Parameter | Type | Description |
|---|---|---|
data * | object | The RDF data to append, represented as a JSON-LD dict. |
url * | string | The URL to send the RDF data to. This should be a valid URL. |
PUT
Replaces RDF data in a named graph using HTTP PUT. The URL serves as both the resource identifier and the named graph address in systems with direct graph identification. Completely replaces the RDF graph (provided as JSON-LD payload) at that URL. Returns True if the operation was successful, False otherwise. Note: This operation does not return the updated graph, it only confirms the success of the operation.
| Parameter | Type | Description |
|---|---|---|
data * | object | The RDF data to send, represented as a JSON-LD dict. |
url * | string | The URL to send the RDF data to. This should be a valid URL. |
ldh-AddConstruct
Creates a SPARQL CONSTRUCT query resource in a document. This tool creates a SPARQL CONSTRUCT query that can be executed and referenced within LinkedDataHub. The query can be used for charts, views, or other data processing operations. This tool: - Creates a sp:Construct resource with the SPARQL query text - Posts the new CONSTRUCT query resource to the target document - Supports optional title, description, fragment identifier, and service URI Note: the service URI is _not_ the SPARQL endpoint URL but an instance of `sd…
| Parameter | Type | Description |
|---|---|---|
query * | string | The SPARQL CONSTRUCT query string. |
title * | string | Title of the CONSTRUCT query. |
url * | string | The URI of the document to write the CONSTRUCT query to. |
description | string | Optional description of the CONSTRUCT query. |
fragment | string | Optional fragment identifier for the query URI (e.g., 'my-query' creates #my-query). |
service | string | Optional URI of the SPARQL service/endpoint specific to this query. Note: the service URI is _not_ the SPARQL endpoint URL but an instance of `sd:Service` that describes the SPARQL service capabilitie… |
ldh-AddFile
Adds a file to a LinkedDataHub document via multipart RDF/POST. Appends `a nfo:FileDataObject ; nfo:fileName ; dct:title ; ...` to the target document and stores the file bytes at `<base>/uploads/{sha1}` (LDH's built-in upload namespace). The file is a resource the document holds, not one of its content blocks: to show it in the content mode, place it with ldh-AddObjectBlock, the returned `url` as its value. Arguments: - `url` — URI of the target document to add the file's description to. - `file` — absolute local file path.…
| Parameter | Type | Description |
|---|---|---|
file * | string | Absolute local file path. The bytes are read and uploaded. |
title * | string | Title of the file (dct:title). |
url * | string | Target document URI to add the file's description to. |
content_type | string | Optional MIME-type override; auto-detected from path if absent. |
description | string | Optional description (dct:description). |
ldh-AddGenericService
Writes a generic SPARQL service description to a LinkedDataHub document. This tool creates a SPARQL service description that can be referenced and used within LinkedDataHub. The service description includes endpoint information and supported capabilities. This tool: - Creates an sd:Service resource with endpoint URI and supported languages - Posts the new service description to the target document - Supports optional title, description, fragment identifier, graph store, and authentication - Automatically sets SPARQL 1.1…
| Parameter | Type | Description |
|---|---|---|
endpoint * | string | Endpoint URI of the SPARQL service. |
title * | string | Title of the service. |
url * | string | The URI of the document to write the service to. |
auth_pwd | string | Optional authorization password for the service. |
auth_user | string | Optional authorization username for the service. |
description | string | Optional description of the service. |
fragment | string | Optional fragment identifier for the service URI (e.g., 'my-service' creates #my-service). |
graph_store | string | Optional Graph Store URI for the service. |
ldh-AddResultSetChart
Writes a chart of SPARQL SELECT query results to a LinkedDataHub document. The chart is a resource the document holds, not one of its content blocks: to show it in the content mode, place it with ldh-AddObjectBlock, the chart's URI as its value - so give the chart a fragment identifier. A chart shows values: the query's bindings themselves, as a table or a plot, the way a spreadsheet would. It is the fit for aggregates and measurements - totals, counts, sums per shop or per month. A resource in a chart is a bare cell, with no image, label or lin…
| Parameter | Type | Description |
|---|---|---|
category_var_name * | string | Name of the SPARQL variable used as category (without leading '?'). |
chart_type * | string | URI of the chart type (e.g., https://w3id.org/atomgraph/client#BarChart). |
query * | string | URI of an existing sp:Select query resource to visualize (not a SPARQL query string). |
series_var_name * | string | array | Name of the SPARQL variable used as series/value (without leading '?'), or an array of names for several series. |
title * | string | Title of the chart. |
url * | string | The URI of the document to write the chart to. |
description | string | Optional description of the chart. |
fragment | string | Optional fragment identifier for the chart URI (e.g., 'my-chart' creates #my-chart). |
ldh-AddSelect
Creates a SPARQL SELECT query resource in a document. This tool creates a SPARQL SELECT query that can be executed and referenced within LinkedDataHub. The query can be used for charts, views, or other data processing operations. This tool: - Creates a sp:Select resource with the SPARQL query text - Posts the new SELECT query resource to the target document - Supports optional title, description, fragment identifier, and service URI Note: the service URI is _not_ the SPARQL endpoint URL but an instance of `sd:Service` th…
| Parameter | Type | Description |
|---|---|---|
query * | string | The SPARQL SELECT query string. |
title * | string | Title of the SELECT query. |
url * | string | The URI of the document to write the SELECT query to. |
description | string | Optional description of the SELECT query. |
fragment | string | Optional fragment identifier for the query URI (e.g., 'my-query' creates #my-query). |
service | string | Optional URI of the SPARQL service/endpoint specific to this query. Note: the service URI is _not_ the SPARQL endpoint URL but an instance of `sd:Service` that describes the SPARQL service capabilitie… |
ldh-AddView
Writes a view of SPARQL SELECT query results to a LinkedDataHub document. The view is a resource the document holds, not one of its content blocks: to show it in the content mode, place it with ldh-AddObjectBlock, the view's URI as its value - so give the view a fragment identifier. A view shows resources - things, people, places, documents - each as itself: its label, its image, its links. LinkedDataHub DESCRIBEs the resources the query's first projected variable binds and renders those descriptions in the view's mode, so that variable must bin…
| Parameter | Type | Description |
|---|---|---|
query * | string | URI of an existing sp:Select query resource to visualize (not a SPARQL query string). |
title * | string | Title of the view. |
url * | string | The URI of the document to write the view to. |
description | string | Optional description of the view. |
fragment | string | Optional fragment identifier for the view URI (e.g., 'my-view' creates #my-view). |
mode | string | Optional URI of the layout the view shows its results in (a view mode, not an object block's mode). Defaults to ListMode. Pick it by what the resources carry: GridMode for resources with an image, Map… |
show_when_empty | boolean | Optional: whether the view is shown when its query returns no results (ldh:showWhenEmpty). LinkedDataHub shows it unless this is false. |
ldh-AddObjectBlock
Appends an object block to a LinkedDataHub document content mode using sequence properties. Only XHTML blocks and object blocks are shown in the content mode. Other resources can still be added to the document, but they will not be displayed in the content mode. Object blocks reference external resources via URI and can have different display modes. Only RDF Linked Data objects can be rendered by using display modes, so if you think you're using an RDF URI value, make sure it returns a valid RDF resource (e.g. use the GET operation to verify). Non-RDF r…
| Parameter | Type | Description |
|---|---|---|
url * | string | The URI of the document to append the object block to. |
value * | string | URI of the object resource to reference. |
description | string | Optional description for the object block. |
fragment | string | Optional fragment identifier for the object block URI (e.g., 'intro' creates #intro). |
graph | string | Optional URI of the document that describes the value, read in place of dereferencing the value's URI (ldh:graph). |
mode | string | Optional URI of the mode the block shows its resource in (an object mode, not a view's layout). Defaults to ReadMode. |
title | string | Optional title for the object block. |
ldh-AddXHTMLBlock
Appends an XHTML block to a LinkedDataHub document using sequence properties. Only XHTML blocks and object blocks are shown in the content mode. Other resources can still be added to the document, but they will not be displayed in the content mode. IMPORTANT: The value parameter must be canonical XML literal - well-formed XHTML content that will be stored as rdf:XMLLiteral datatype. The top-level XHTML element must be <div xmlns="http://www.w3.org/1999/xhtml"></div>. The XHTML can use CSS classes for inline elements from Bootstrap 2.3.2, but no inline C…
| Parameter | Type | Description |
|---|---|---|
url * | string | The URI of the document to append the XHTML block to. |
value * | string | XHTML content as canonical XML literal (must be well-formed XML). |
description | string | Optional description for the XHTML block. |
fragment | string | Optional fragment identifier for the XHTML block URI (e.g., 'intro' creates #intro). |
title | string | Optional title for the XHTML block. |
ldh-RemoveBlock
Removes a content block from a LinkedDataHub document. This tool removes content blocks from LinkedDataHub documents by: - Deleting the sequence property that references the block (rdf:_N) - Deleting all properties of the block itself - If no specific block URI is provided, removes any blocks found via sequence properties The operation uses SPARQL UPDATE (HTTP PATCH) to perform the deletion.
| Parameter | Type | Description |
|---|---|---|
url * | string | The URI of the document to remove the block from. |
block | string | Optional URI of the specific content block to remove. If not provided, will remove blocks based on sequence properties. |
ldh-CreateContainer
Creates a LinkedDataHub Container document with proper structure. IMPORTANT CONSTRAINTS: - The document URL needs to end with a trailing slash (/) - Documents can only be created at URLs relative to existing container's URL - Example: if https://localhost/blog/ exists, you cannot create https://localhost/blog/posts/something/ before creating https://localhost/blog/posts/ - LinkedDataHub automatically manages timestamps (dct:created, dct:modified) - LinkedDataHub automatically manages parent-child relationships (sioc:has_parent…
| Parameter | Type | Description |
|---|---|---|
parent * | string | URI of the parent container |
title * | string | The title of the container |
children_view | boolean | Optional: whether the container's first content block lists its children (the shared ldh:ChildrenView). It does unless this is false; the content is then added with ldh-AddObjectBlock and ldh-AddXHTML… |
description | string | Description (optional) |
if_absent | boolean | Optional: whether a document already at the URI counts as success, left as it is (like mkdir -p). Without it the operation fails there. |
primary_topic | string | URI reference of what the container is about, resolved against its URI (optional), e.g. #this. |
slug | string | URL path segment (optional). Defaults to a random UUID. |
ldh-CreateItem
Creates a LinkedDataHub Item document with proper structure. IMPORTANT CONSTRAINTS: - The document URL needs to end with a trailing slash (/) - Documents can only be created at URLs relative to existing container's URL - Example: if https://localhost/blog/ exists, you cannot create https://localhost/blog/posts/something/ before creating https://localhost/blog/posts/ - LinkedDataHub automatically manages timestamps (dct:created, dct:modified) - LinkedDataHub automatically manages parent-child relationships (sioc:has_parent) base…
| Parameter | Type | Description |
|---|---|---|
container * | string | URI of the parent container |
title * | string | The title of the item |
description | string | Description (optional) |
if_absent | boolean | Optional: whether a document already at the URI counts as success, left as it is (like mkdir -p). Without it the operation fails there. |
primary_topic | string | URI reference of what the item is about, resolved against its URI (optional), e.g. #this. |
slug | string | URL path segment (optional). Defaults to a random UUID. |
ldh-List
Returns a list of children documents for the given URL as SPARQL results JSON.
| Parameter | Type | Description |
|---|---|---|
url * | string | The URL of the document to list children for. |
base | string | Base URL for constructing the SPARQL endpoint. Needs to end with a slash. Either 'endpoint' or 'base' must be provided. |
endpoint | string | The SPARQL endpoint URL to query. Either 'endpoint' or 'base' must be provided. |
Merge
Merges a list of RDF graphs as JSON-LD dicts into a single RDF graph as JSON-LD.
| Parameter | Type | Description |
|---|---|---|
graphs * | array | List of JSON-LD objects to merge into a single RDF graph. |
Now
Returns the current date and time as an xsd:dateTime literal in UTC, following SPARQL's NOW(): every Now in one run of a program returns the same value, the time the run began.
Reconcile
The entities a reconciliation service (the W3C Reconciliation Service API) offers for a name, as a result: one row per candidate, best first, binding ?entity (a URI), ?name, ?description, ?score and ?match. `type` is one of the service's type ids, `limit` caps the rows. Wikidata's service is https://wikidata-reconciliation.wmcloud.org/en/api, whose type ids are Wikidata items (Q515 city, Q6256 country, Q43229 organization).
| Parameter | Type | Description |
|---|---|---|
endpoint * | string | The reconciliation service's URL. |
query * | string | The name to reconcile. |
limit | integer | Optional: at most this many candidates. |
type | string | Optional: one of the service's type ids, e.g. Q515. |
ResolveURI
Creates a new URI relative to the base URL. The relative URI **must** be pre-encoded.
| Parameter | Type | Description |
|---|---|---|
base * | string | The base URI to resolve against. |
relative * | string | The relative URI to resolve. |
ExtractClasses
Extracts OWL classes (owl:Class candidates) from rdf:type usage in an RDF dataset, optionally scoped to the subjects in 'bindings'.
| Parameter | Type | Description |
|---|---|---|
endpoint * | string | SPARQL endpoint URL |
bindings | Optional SELECT result whose ?subject column scopes the extraction to those subjects |
ExtractDatatypeProperties
Extracts OWL datatype properties from literal-valued predicates in an RDF dataset, optionally scoped to the subjects in 'bindings'.
| Parameter | Type | Description |
|---|---|---|
endpoint * | string | SPARQL endpoint URL |
bindings | Optional SELECT result whose ?subject column scopes the extraction to those subjects |
ExtractObjectProperties
Extracts OWL object properties (and functional properties, closed-world) from IRI-valued predicates in an RDF dataset, optionally scoped to the subjects in 'bindings'.
| Parameter | Type | Description |
|---|---|---|
endpoint * | string | SPARQL endpoint URL |
bindings | Optional SELECT result whose ?subject column scopes the extraction to those subjects |
ExtractOntology
Extracts a complete OWL ontology (classes, datatype properties, and object properties with functional property restrictions) from an RDF dataset, optionally scoped to the subjects in 'bindings'.
| Parameter | Type | Description |
|---|---|---|
endpoint * | string | SPARQL endpoint URL |
bindings | Optional SELECT result whose ?subject column scopes the extraction to those subjects |
CONSTRUCT
Executes a SPARQL CONSTRUCT query over an endpoint or over a graph in hand.
| Parameter | Type | Description |
|---|---|---|
query * | string | |
endpoint | string | SPARQL endpoint URL (or give 'graph') |
graph | A graph to query locally (or give 'endpoint') |
DESCRIBE
Executes a SPARQL DESCRIBE query over an endpoint or over a graph in hand.
| Parameter | Type | Description |
|---|---|---|
query * | string | |
endpoint | string | SPARQL endpoint URL (or give 'graph') |
graph | A graph to query locally (or give 'endpoint') |
SELECT
Executes a SPARQL SELECT query over an endpoint or over a graph in hand
| Parameter | Type | Description |
|---|---|---|
query * | string | SPARQL SELECT query |
endpoint | string | SPARQL endpoint URL (or give 'graph') |
graph | A graph to query locally (or give 'endpoint') |
Substitute
Gives one variable of a SPARQL query or update a value without removing the variable: an inline VALUES block restricting it to the term is joined into every group of the query, so the query stays valid, a SELECT still projects the variable and every result row still carries it. Subqueries that do not project the variable keep their own copy (it is renamed there). The query must not assign the variable itself (AS or VALUES). A URI is written as <iri>, a literal escaped; a blank node is rejected. Substitute is Values over a one-row table; use Values for several variables or rows. For exa…
| Parameter | Type | Description |
|---|---|---|
binding * | object | A dictionary containing the value and type to substitute for the variable. |
query * | string | The SPARQL query string with variable placeholders. |
var * | string | The variable to substitute in the query (e.g., '?x'). |
Values
Restricts variables of a SPARQL query or update to the rows of a SPARQL result set, so one query is constrained by, or batched over, the results of another: an inline VALUES block with the rows is joined into every group of the query. The variables stay variables (still projected, still in templates). Columns default to the result's variables; vars selects and orders them; a row that does not bind a column leaves it free (UNDEF). Subqueries that do not project a column keep their own copy; the query must not assign a restricted variable itself (AS or VALUES). Blank nodes are rejected. Substitu…
| Parameter | Type | Description |
|---|---|---|
data * | object | A SPARQL result set (as produced by SELECT) whose variables and rows become the VALUES block. The variable names must match those used in the query. |
query * | string | The SPARQL query or update whose variables are restricted. It must not assign them itself (AS, VALUES). |
vars | array | Optional subset and ordering of variable names to emit as columns. Defaults to all variables of the result set. |
SPARQLString
Writes a SPARQL query for an endpoint from a natural language question, using an LLM. `projection` names the variables the query must project (because what follows reads them from its rows). `context` holds operations (e.g. a SELECT that inventories predicates, or looks a label up) whose results are shown to the model as what the endpoint holds, before it writes the query. A query that does not parse or lacks the projection goes back to the model, a few times at most.
| Parameter | Type | Description |
|---|---|---|
endpoint * | string | The SPARQL endpoint the query is for. |
question * | string | The natural language question to convert into a SPARQL query. |
context | array | Operations whose results show the model what the endpoint holds. |
projection | array | Variable names the query must be a SELECT projecting. |
Concat
Concatenates multiple string values into a single string, per SPARQL's CONCAT() function: if all inputs carry the same language tag the result carries it too, otherwise the result is a simple (xsd:string) literal.
| Parameter | Type | Description |
|---|---|---|
inputs * | array | Array of string values to concatenate. |
EncodeForURI
Encodes a string to be URI-safe, following SPARQL's `ENCODE_FOR_URI` behavior. It encodes characters that are not allowed in URIs, such as spaces, slashes, and colons.
| Parameter | Type | Description |
|---|---|---|
input * | string | The string to encode for use in a URI. |
Replace
Replaces occurrences of a regular-expression pattern in an input string, per SPARQL's REPLACE() / XPath fn:replace. The replacement string may reference capture groups as $1, $2, ...; flags `s`, `m`, `i`, `x`, `q` are supported. The result is a string literal of the same kind (datatype/language tag) as the input. Note: this function should not be used to build URIs! That should be done using EncodeForURI()/ResolveURI().
| Parameter | Type | Description |
|---|---|---|
input * | string | The input string to process |
pattern * | string | The regular expression to be replaced (XPath fn:replace syntax) |
replacement * | string | The replacement string; $1, $2, ... reference capture groups |
flags | string | Optional XPath regex flags: any of s, m, i, x, q |
StrUUID
Generates a fresh UUID (Universally Unique Identifier) as a string, following the behavior of SPARQL's STRUUID(). Each invocation produces a new unique identifier.