Install
openclaw skills install rdf-triple-store-integrationConnect to RDF triple stores and execute SPARQL queries for storing, retrieving, and managing semantic knowledge graph data
openclaw skills install rdf-triple-store-integrationThis skill enables comprehensive interaction with RDF triple stores for querying, inserting, updating, and managing semantic knowledge graph data using SPARQL.
RDF (Resource Description Framework) represents knowledge as triples - the fundamental building block of semantic web:
Alice → knows → BobSPARQL is the standardized query and update language for RDF, enabling complex queries across semantic datasets.
Use this skill when:
{
"endpoint": "http://localhost:3030/dataset/sparql",
"update_endpoint": "http://localhost:3030/dataset/update",
"timeout": 30,
"max_retries": 3,
"default_graph": "http://example.com/default"
}
| Parameter | Type | Default | Description |
|---|---|---|---|
| endpoint | string | required | SPARQL query endpoint URL |
| update_endpoint | string | optional | SPARQL update endpoint URL |
| timeout | integer | 30 | Request timeout in seconds |
| max_retries | integer | 3 | Maximum retry attempts |
| default_graph | string | optional | Default graph URI |
| username | string | optional | Authentication username |
| password | string | optional | Authentication password |
| format | string | json | Response format (json, xml) |
http://example.com/alicehttp://foaf.com/knows"Alice"@en, 30^^xsd:integerex:Alice foaf:knows ex:BobSELECT ?var1 ?var2
WHERE {
?var1 ?var2 ?var3
}
Returns bindings of variables
CONSTRUCT { ?s ?p ?o }
WHERE { ?s ?p ?o }
Returns RDF triples
ASK {
?s ?p ?o
}
Returns boolean result
DESCRIBE ?resource
Returns RDF description of resource
?subject ?predicate ?object
Matches any triple in the store
ex:Alice ?predicate ?object
Query properties of specific resource
?person foaf:knows ?friend .
?friend foaf:name ?name .
Join multiple triple patterns
SELECT ?person ?name
WHERE {
?person foaf:name ?name
}
SELECT ?name
WHERE {
?person foaf:name ?name ;
foaf:age ?age
}
WHERE {
?person foaf:age ?age .
FILTER (?age > 18)
}
FILTER (CONTAINS(?name, "Alice"))
FILTER (STRSTARTS(?email, "alice@"))
FILTER (isLiteral(?value))
FILTER (isIRI(?resource))
SELECT (COUNT(?person) as ?count)
WHERE {
?person rdf:type foaf:Person
}
SELECT ?department (COUNT(?person) as ?count)
WHERE {
?person foaf:workDepartment ?department
}
GROUP BY ?department
SELECT (COUNT(?x) as ?c) (SUM(?age) as ?total)
WHERE { ... }
SELECT ?name ?email
WHERE {
?person foaf:name ?name
OPTIONAL { ?person foaf:email ?email }
}
WHERE {
{ ?person foaf:knows ?friend }
UNION
{ ?person foaf:colleague ?friend }
}
ORDER BY ?name
ORDER BY DESC(?age)
LIMIT 10
OFFSET 20
?entity rdf:type ex:Person
?entity rdf:type owl:Class
?entity rdf:type* ex:Animal // Including subclasses
INSERT DATA {
ex:Alice ex:knows ex:Bob .
ex:Alice foaf:age 30 .
}
INSERT {
?person foaf:status "active"
}
WHERE {
?person foaf:age ?age .
FILTER (?age > 18)
}
DELETE DATA {
ex:Alice ex:knows ex:Bob .
}
DELETE WHERE {
?person foaf:age ?age .
FILTER (?age < 0)
}
DELETE {
?person foaf:age ?old
}
INSERT {
?person foaf:age ?new
}
WHERE {
?person foaf:age ?old .
BIND (?old + 1 as ?new)
}
SELECT ?s ?p ?o
FROM NAMED <http://example.com/graph1>
WHERE {
GRAPH <http://example.com/graph1> { ?s ?p ?o }
}
INSERT DATA {
GRAPH <http://example.com/graph1> {
ex:Alice ex:knows ex:Bob
}
}
?person foaf:type ex:Person .
?person rdfs:subClassOf ex:Agent
?book dc:author ?author .
?author foaf:knows ?colleague
SELECT ?name
WHERE {
SERVICE <http://dbpedia.org/sparql> {
?resource rdfs:label ?name
}
}
SELECT ?name ?age ?status
WHERE {
?person foaf:name ?name ;
foaf:age ?age
BIND (IF(?age >= 18, "Adult", "Minor") as ?status)
}
?person foaf:knows{2} ?distant_friend // 2 hops
?resource dc:subject* ?topic // Any hops
| Error | Cause | Solution |
|---|---|---|
| Endpoint unreachable | Server down or wrong URL | Verify endpoint URL and server status |
| Invalid SPARQL syntax | Malformed query | Validate query syntax |
| Query timeout | Complex query or large dataset | Add LIMIT, simplify patterns, add FILTER |
| Unauthorized | Missing credentials | Add authentication headers |
| Bad request | Invalid parameters | Check parameter encoding |
| Server error | Endpoint issue | Check endpoint logs |
✅ Filter early with FILTER clauses
✅ Use LIMIT to restrict result sets
✅ Avoid expensive joins when possible
✅ Use specific properties instead of wildcards
✅ Create indexes on frequently queried predicates
✅ Use consistent URIs for resources
✅ Apply ontologies consistently
✅ Use named graphs for data organization
✅ Maintain referential integrity
✅ Document ontology extensions
✅ Use transactions for multi-step updates
✅ Validate data before insertion
✅ Use parameterized queries
✅ Handle duplicates appropriately
✅ Log all modifications
✅ Version ontologies
✅ Document classes and properties
✅ Use standard vocabularies (FOAF, Dublin Core, etc.)
✅ Define constraints and restrictions
✅ Maintain semantic consistency
✅ Use compression for large datasets
✅ Index high-cardinality predicates
✅ Monitor query performance
✅ Use CONSTRUCT for large result sets
✅ Batch inserts for better throughput
✅ Use OWL constraints
✅ Enable reasoning when needed
✅ Validate against ontologies
✅ Check cardinality constraints
✅ Maintain type consistency
✅ Follow HTTP URIs standards
✅ Use standard vocabularies
✅ Provide resolvable URIs
✅ Include owl:sameAs links
✅ Support content negotiation
✅ Authenticate connections
✅ Validate SPARQL queries
✅ Use HTTPS for endpoints
✅ Implement access control
✅ Sanitize user input
| Library | Purpose |
|---|---|
| rdflib | Python RDF library |
| SPARQLWrapper | SPARQL endpoint client |
| requests | HTTP client |
| json | JSON handling |
| Library | Purpose |
|---|---|
| owlrl | OWL reasoning |
| pydantic | Data validation |
| pandas | Data transformation |
pip install rdflib sparqlwrapper requests pydantic
Using this skill enables:
✅ Semantic Integration - Leverage RDF and ontologies for knowledge representation
✅ Interoperability - Work with linked open data and semantic web standards
✅ Complex Queries - SPARQL supports sophisticated graph queries
✅ Reasoning - Enable ontology-based inference
✅ Standards-Based - Build on W3C standards (RDF, OWL, SPARQL)
✅ Scalability - Modern triple stores handle large datasets
✅ Flexibility - Support multiple data formats and serializations
connector = RDFStoreConnector()
connector.connect(config)
result = connector.execute_query(sparql_query)
connector.close()
# Query by type
SELECT ?entity WHERE { ?entity rdf:type ex:Person }
# Query properties
SELECT ?name WHERE { ex:Alice foaf:name ?name }
# Filter results
SELECT ?person WHERE {
?person foaf:age ?age .
FILTER (?age > 18)
}
# Insert triples
connector.insert_data(triples)
# Delete triples
connector.delete_data(pattern)
# Update data
connector.update_data(delete_pattern, insert_pattern, where_clause)
# Create graph
connector.create_graph(graph_uri)
# Query graph
result = connector.query_graph(graph_uri, sparql_query)
# List graphs
graphs = connector.list_graphs()
Version: 1.0.0
Last Updated: April 12, 2026