HTTP API
OWLGraph exposes its API over HTTP on port 8080 (configurable). All endpoints accept and return JSON unless otherwise noted.
Ontology Endpoints
Section titled “Ontology Endpoints”POST /ontology
Section titled “POST /ontology”Load an OWL ontology in Turtle format.
curl -X POST http://localhost:8080/ontology \ -H "Content-Type: text/turtle" \ --data-binary @your-ontology.ttlResponse:
{ "classes": 11, "objectProperties": 5, "dataProperties": 4, "compiledSchema": "type Animal { ... }", "status": "success", "message": "Ontology loaded and materializer activated"}What happens:
- Parses Turtle into OWL internal representation
- Validates OWL2 RL profile compliance
- Compiles classes to Dgraph types and properties to predicates
- Applies compiled schema to the database
- Persists ontology for restart recovery
- Initializes reasoning engine and introspection
- Triggers retroactive materialization for existing data
POST /ontology?validate=true
Section titled “POST /ontology?validate=true”Validate an ontology without applying it:
curl -X POST "http://localhost:8080/ontology?validate=true" \ -H "Content-Type: text/turtle" \ --data-binary @your-ontology.ttlReturns the compiled schema and class counts without side effects.
GET /ontology/introspect
Section titled “GET /ontology/introspect”List all classes in the loaded ontology:
curl http://localhost:8080/ontology/introspectGET /ontology/introspect?class=ClassName
Section titled “GET /ontology/introspect?class=ClassName”Get details for a specific class:
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:
# Direct subclasses onlycurl "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:
curl "http://localhost:8080/ontology/introspect?superclasses=GoldenRetriever&transitive=true"Query Endpoints
Section titled “Query Endpoints”POST /query
Section titled “POST /query”Execute a DQL query:
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 } }}Mutation Endpoints
Section titled “Mutation Endpoints”POST /mutate
Section titled “POST /mutate”Execute a mutation:
# JSON mutation with immediate commitcurl -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 } }}Schema Endpoints
Section titled “Schema Endpoints”POST /alter
Section titled “POST /alter”Apply a schema change directly (bypasses ontology system):
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.
Health Endpoint
Section titled “Health Endpoint”GET /health
Section titled “GET /health”curl http://localhost:8080/healthReturns cluster health status.
GraphQL Endpoint
Section titled “GraphQL Endpoint”POST /graphql
Section titled “POST /graphql”Execute a GraphQL query against the auto-generated schema:
curl -X POST http://localhost:8080/graphql \ -H "Content-Type: application/json" \ -d '{ "query": "{ queryDog { name hasOwner { name } } }" }'