{"openapi":"3.0.3","info":{"title":"InputLayer API","description":"REST API for InputLayer Datalog Database","contact":{"name":"InputLayer Team","url":"https://inputlayer.io"},"license":{"name":"Apache-2.0 WITH Commons Clause","url":"https://github.com/inputlayer/inputlayer/blob/main/LICENSE"},"version":"1.0.0"},"servers":[{"url":"/api/v1","description":"API v1"}],"paths":{"/databases":{"get":{"tags":["databases"],"summary":"List all databases","operationId":"list_databases","responses":{"200":{"description":"List of databases","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"500":{"description":"Internal server error"}}},"post":{"tags":["databases"],"summary":"Create a new database","operationId":"create_database","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateDatabaseRequest"}}},"required":true},"responses":{"200":{"description":"Database created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Invalid request"},"500":{"description":"Internal server error"}}}},"/databases/{db}/relations":{"get":{"tags":["relations"],"summary":"List all relations in a database","operationId":"list_relations","parameters":[{"name":"db","in":"path","description":"Database name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"List of relations","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Database not found"},"500":{"description":"Internal server error"}}}},"/databases/{db}/relations/{name}":{"get":{"tags":["relations"],"summary":"Get relation details","operationId":"get_relation","parameters":[{"name":"db","in":"path","description":"Database name","required":true,"schema":{"type":"string"}},{"name":"name","in":"path","description":"Relation name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Relation details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Relation not found"},"500":{"description":"Internal server error"}}}},"/databases/{db}/relations/{name}/data":{"get":{"tags":["relations"],"summary":"Get relation data with pagination","operationId":"get_relation_data","parameters":[{"name":"db","in":"path","description":"Database name","required":true,"schema":{"type":"string"}},{"name":"name","in":"path","description":"Relation name","required":true,"schema":{"type":"string"}},{"name":"offset","in":"query","description":"Offset for pagination","required":false,"schema":{"type":"integer","nullable":true,"minimum":0}},{"name":"limit","in":"query","description":"Limit for pagination","required":false,"schema":{"type":"integer","nullable":true,"minimum":0}}],"responses":{"200":{"description":"Relation data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Relation not found"},"500":{"description":"Internal server error"}}}},"/databases/{db}/views":{"get":{"tags":["views"],"summary":"List all views in a database","operationId":"list_views","parameters":[{"name":"db","in":"path","description":"Database name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"List of views","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Database not found"},"500":{"description":"Internal server error"}}},"post":{"tags":["views"],"summary":"Create a new view","operationId":"create_view","parameters":[{"name":"db","in":"path","description":"Database name","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateViewRequest"}}},"required":true},"responses":{"200":{"description":"View created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Invalid view definition"},"500":{"description":"Internal server error"}}}},"/databases/{db}/views/{name}":{"get":{"tags":["views"],"summary":"Get view details","operationId":"get_view","parameters":[{"name":"db","in":"path","description":"Database name","required":true,"schema":{"type":"string"}},{"name":"name","in":"path","description":"View name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"View details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"View not found"},"500":{"description":"Internal server error"}}},"delete":{"tags":["views"],"summary":"Delete a view","operationId":"delete_view","parameters":[{"name":"db","in":"path","description":"Database name","required":true,"schema":{"type":"string"}},{"name":"name","in":"path","description":"View name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"View deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"View not found"},"500":{"description":"Internal server error"}}}},"/databases/{db}/views/{name}/data":{"get":{"tags":["views"],"summary":"Get view data with pagination","operationId":"get_view_data","parameters":[{"name":"db","in":"path","description":"Database name","required":true,"schema":{"type":"string"}},{"name":"name","in":"path","description":"View name","required":true,"schema":{"type":"string"}},{"name":"offset","in":"query","description":"Offset for pagination","required":false,"schema":{"type":"integer","nullable":true,"minimum":0}},{"name":"limit","in":"query","description":"Limit for pagination","required":false,"schema":{"type":"integer","nullable":true,"minimum":0}}],"responses":{"200":{"description":"View data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"View not found"},"500":{"description":"Internal server error"}}}},"/databases/{name}":{"get":{"tags":["databases"],"summary":"Get database details","operationId":"get_database","parameters":[{"name":"name","in":"path","description":"Database name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Database details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Database not found"},"500":{"description":"Internal server error"}}},"delete":{"tags":["databases"],"summary":"Delete a database","operationId":"delete_database","parameters":[{"name":"name","in":"path","description":"Database name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Database deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Database not found"},"500":{"description":"Internal server error"}}}},"/health":{"get":{"tags":["admin"],"summary":"Health check endpoint","operationId":"health","responses":{"200":{"description":"Server is healthy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}}},"/query/execute":{"post":{"tags":["queries"],"summary":"Execute a Datalog query","operationId":"execute_query","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueryRequest"}}},"required":true},"responses":{"200":{"description":"Query executed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Invalid query"},"500":{"description":"Internal server error"}}}},"/query/explain":{"post":{"tags":["queries"],"summary":"Explain a query plan","operationId":"explain_query","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExplainRequest"}}},"required":true},"responses":{"200":{"description":"Query plan explanation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Invalid query"},"500":{"description":"Internal server error"}}}},"/stats":{"get":{"tags":["admin"],"summary":"Server statistics endpoint","operationId":"stats","responses":{"200":{"description":"Server statistics","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}}}},"components":{"schemas":{"ApiErrorDto":{"type":"object","description":"Error details in API response","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}}},"ApiResponse":{"type":"object","description":"Standard API response wrapper","required":["success"],"properties":{"data":{"allOf":[{"$ref":"#/components/schemas/T"}],"nullable":true},"error":{"allOf":[{"$ref":"#/components/schemas/ApiErrorDto"}],"nullable":true},"success":{"type":"boolean"}}},"CreateDatabaseRequest":{"type":"object","description":"Create database request","required":["name"],"properties":{"description":{"type":"string","nullable":true},"name":{"type":"string"}}},"CreateViewRequest":{"type":"object","description":"Create view request","required":["name","definition"],"properties":{"definition":{"type":"string"},"name":{"type":"string"}}},"DatabaseDto":{"type":"object","description":"Database information","required":["name","relations_count","views_count"],"properties":{"description":{"type":"string","nullable":true},"name":{"type":"string"},"relations_count":{"type":"integer","minimum":0},"views_count":{"type":"integer","minimum":0}}},"DatabaseListDto":{"type":"object","description":"List of databases","required":["databases","current"],"properties":{"current":{"type":"string"},"databases":{"type":"array","items":{"$ref":"#/components/schemas/DatabaseDto"}}}},"ExplainRequest":{"type":"object","description":"Query explanation request","required":["query","database"],"properties":{"database":{"type":"string"},"query":{"type":"string"}}},"ExplainResponse":{"type":"object","description":"Query explanation response","required":["query","plan","optimizations"],"properties":{"optimizations":{"type":"array","items":{"type":"string"}},"plan":{"type":"string"},"query":{"type":"string"}}},"HealthDto":{"type":"object","description":"Health check response","required":["status","version","uptime_secs"],"properties":{"status":{"type":"string"},"uptime_secs":{"type":"integer","format":"int64","minimum":0},"version":{"type":"string"}}},"QueryRequest":{"type":"object","description":"Query execution request","required":["query","database"],"properties":{"database":{"type":"string","description":"Database to execute against"},"query":{"type":"string","description":"The Datalog query to execute"},"timeout_ms":{"type":"integer","format":"int64","description":"Optional timeout in milliseconds","minimum":0}}},"QueryResponse":{"type":"object","description":"Query execution response","required":["query","status","columns","rows","row_count","execution_time_ms"],"properties":{"columns":{"type":"array","items":{"type":"string"}},"error":{"type":"string","nullable":true},"execution_time_ms":{"type":"integer","format":"int64","minimum":0},"query":{"type":"string"},"row_count":{"type":"integer","minimum":0},"rows":{"type":"array","items":{"type":"array","items":{}}},"status":{"$ref":"#/components/schemas/QueryStatus"}}},"QueryStatus":{"type":"string","description":"Query execution status","enum":["success","error"]},"RelationDataDto":{"type":"object","description":"Relation data response","required":["name","columns","rows","row_count","total_count"],"properties":{"columns":{"type":"array","items":{"type":"string"}},"limit":{"type":"integer","nullable":true,"minimum":0},"name":{"type":"string"},"offset":{"type":"integer","nullable":true,"minimum":0},"row_count":{"type":"integer","minimum":0},"rows":{"type":"array","items":{"type":"array","items":{}}},"total_count":{"type":"integer","minimum":0}}},"RelationDataQuery":{"type":"object","description":"Query parameters for relation data","properties":{"limit":{"type":"integer","nullable":true,"minimum":0},"offset":{"type":"integer","nullable":true,"minimum":0}}},"RelationDto":{"type":"object","description":"Relation information","required":["name","arity","tuple_count","columns","is_view"],"properties":{"arity":{"type":"integer","minimum":0},"columns":{"type":"array","items":{"type":"string"}},"is_view":{"type":"boolean"},"name":{"type":"string"},"tuple_count":{"type":"integer","minimum":0}}},"RelationListDto":{"type":"object","description":"Relation list response","required":["relations"],"properties":{"relations":{"type":"array","items":{"$ref":"#/components/schemas/RelationDto"}}}},"StatsDto":{"type":"object","description":"Server statistics response","required":["databases","relations","views","memory_usage_bytes","query_count","uptime_secs"],"properties":{"databases":{"type":"integer","minimum":0},"memory_usage_bytes":{"type":"integer","format":"int64","minimum":0},"query_count":{"type":"integer","format":"int64","minimum":0},"relations":{"type":"integer","minimum":0},"uptime_secs":{"type":"integer","format":"int64","minimum":0},"views":{"type":"integer","minimum":0}}},"ViewDto":{"type":"object","description":"View information","required":["name","definition","arity","columns","dependencies"],"properties":{"arity":{"type":"integer","minimum":0},"columns":{"type":"array","items":{"type":"string"}},"definition":{"type":"string"},"dependencies":{"type":"array","items":{"type":"string"}},"name":{"type":"string"}}},"ViewListDto":{"type":"object","description":"View list response","required":["views"],"properties":{"views":{"type":"array","items":{"$ref":"#/components/schemas/ViewDto"}}}}}},"tags":[{"name":"databases","description":"Database management operations"},{"name":"queries","description":"Query execution and explanation"},{"name":"relations","description":"Relation data access"},{"name":"views","description":"View management"},{"name":"admin","description":"Server administration and health"}]}