Skip to content

HTTP API

OWLGraph exposes its API over HTTP on port 8080 (configurable). All endpoints accept and return JSON unless otherwise noted.

Load an OWL ontology in Turtle format.

Terminal window
curl -X POST http://localhost:8080/ontology \
-H "Content-Type: text/turtle" \
--data-binary @your-ontology.ttl

Response:

{
"classes": 11,
"objectProperties": 5,
"dataProperties": 4,
"compiledSchema": "type Animal { ... }",
"status": "success",
"message": "Ontology loaded and materializer activated"
}

What happens:

  1. Parses Turtle into OWL internal representation
  2. Validates OWL2 RL profile compliance
  3. Compiles classes to Dgraph types and properties to predicates
  4. Applies compiled schema to the database
  5. Persists ontology for restart recovery
  6. Initializes reasoning engine and introspection
  7. Triggers retroactive materialization for existing data

Validate an ontology without applying it:

Terminal window
curl -X POST "http://localhost:8080/ontology?validate=true" \
-H "Content-Type: text/turtle" \
--data-binary @your-ontology.ttl

Returns the compiled schema and class counts without side effects.

List all classes in the loaded ontology:

Terminal window
curl http://localhost:8080/ontology/introspect

Get details for a specific class:

Terminal window
curl "http://localhost:8080/ontology/introspect?class=Dog"
{
"iri": "Dog",
"superClasses": ["Mammal", "Animal"],
"subClasses": ["GoldenRetriever", "Labrador"],
"disjointWith": ["Cat"],
"properties": [
{
"iri": "hasOwner",
"type": "ObjectProperty",
"domain": ["Animal"],
"range": ["Person"],
"isFunctional": true
}
]
}

GET /ontology/introspect?subclasses=ClassName

Section titled “GET /ontology/introspect?subclasses=ClassName”

Get subclasses of a class:

Terminal window
# Direct subclasses only
curl "http://localhost:8080/ontology/introspect?subclasses=Animal"
# All descendants (transitive)
curl "http://localhost:8080/ontology/introspect?subclasses=Animal&transitive=true"

GET /ontology/introspect?superclasses=ClassName

Section titled “GET /ontology/introspect?superclasses=ClassName”

Get superclasses:

Terminal window
curl "http://localhost:8080/ontology/introspect?superclasses=GoldenRetriever&transitive=true"

Execute a DQL query:

Terminal window
curl -X POST http://localhost:8080/query \
-H "Content-Type: application/dql" \
-d '{ q(func: type(Animal)) { name dgraph.type } }'

Response:

{
"data": {
"q": [
{ "name": "Fido", "dgraph.type": ["Dog", "Mammal", "Animal"] }
]
},
"extensions": {
"server_latency": { "parsing_ns": 1234, "processing_ns": 5678 }
}
}

Execute a mutation:

Terminal window
# JSON mutation with immediate commit
curl -X POST "http://localhost:8080/mutate?commitNow=true" \
-H "Content-Type: application/json" \
-d '{
"set": [{ "dgraph.type": "Dog", "name": "Rex" }]
}'

Query parameters:

  • commitNow=true — commit immediately (no transaction)

Response:

{
"data": {
"uids": { "blank-0": "0x1" }
},
"extensions": {
"server_latency": { "parsing_ns": 1234, "processing_ns": 5678 }
}
}

Apply a schema change directly (bypasses ontology system):

Terminal window
curl -X POST http://localhost:8080/alter \
-d 'name: string @index(term) .'

Caution: Prefer loading ontologies via /ontology instead of raw /alter. The ontology endpoint handles schema compilation, materialization setup, and persistence automatically.

Terminal window
curl http://localhost:8080/health

Returns cluster health status.

Execute a GraphQL query against the auto-generated schema:

Terminal window
curl -X POST http://localhost:8080/graphql \
-H "Content-Type: application/json" \
-d '{ "query": "{ queryDog { name hasOwner { name } } }" }'