Overview
SPARQL (SPARQL Protocol and RDF Query Language) is the standard query language for knowledge graphs built on RDF data. In Nadoo AI, SPARQL is the primary way to query, filter, and aggregate data across entities and relationships in your knowledge graphs.API Endpoints
Execute a Query
| Parameter | Type | Required | Description |
|---|---|---|---|
query | String | Yes | The SPARQL query to execute |
dataset | String | No | Target dataset/graph. Defaults to the workspace’s default graph. |
format | String | No | Response format: json (default), csv, xml |
timeout | Integer | No | Query timeout in milliseconds (default: 30000) |
List Available Datasets
SPARQL Query Basics
SELECT Queries
Retrieve specific data by matching patterns in the graph.ASK Queries
Check whether a pattern exists in the graph. Returnstrue or false.
CONSTRUCT Queries
Build a new RDF graph from matched patterns. Useful for extracting subgraphs.Example Queries
Find All Entities of a Type
Retrieve all services registered in the knowledge graph.Traverse Relationships
Find all downstream dependencies of a given service (one hop).Multi-Hop Traversal
Find all transitive dependencies (up to 3 hops deep) using property paths.Aggregate Data
Count the number of services per team.Filter with Conditions
Find services created after a specific date that use Python.Find Shortest Path
Find the shortest dependency path between two services.Integration with Workflow Nodes
SPARQL queries can be executed from within a Nadoo AI workflow using the Knowledge Graph Query node.Node Configuration
| Field | Description |
|---|---|
| Query | The SPARQL query to execute. Supports variable interpolation from the workflow context. |
| Dataset | The target knowledge graph dataset. |
| Output Variable | The workflow variable to store query results in. |
Variable Interpolation
Use{{variable_name}} syntax to inject workflow variables into SPARQL queries:
{{user_input.service_name}} is replaced at runtime with the value from the workflow context.
Example Workflow
Query Best Practices
Use PREFIX declarations
Use PREFIX declarations
Always declare prefixes at the top of your queries for readability. Avoid using full URIs in the query body.
Use OPTIONAL for nullable properties
Use OPTIONAL for nullable properties
Wrap optional properties in
OPTIONAL {} blocks so that entities missing those properties are still returned.Limit results for performance
Limit results for performance
Always use
LIMIT for exploratory queries, especially on large graphs. Unbounded queries can be slow and return excessive data.Use FILTER for precise conditions
Use FILTER for precise conditions
SPARQL
FILTER supports regex, comparison operators, and boolean logic for precise data selection.