Dokumentation » API » Docs API
Docs API
Erstellt: 2025-12-27 | Aktualisiert: 2025-12-27
REST-API für Dokumentations-Management mit CRUD-Operationen, semantischer Suche und RAG-Chat.
| Controller | Controller\Api\DocsController |
| Base-URL | /api/v1/docs |
| Datenbank | ki_dev.dokumentation |
| Format | JSON |
Endpoints-Übersicht
| Methode | Pfad | Beschreibung |
| GET | /api/v1/docs | Liste aller Dokumente |
| GET | /api/v1/docs/{id} | Dokument nach ID |
| GET | /api/v1/docs/path/{path} | Dokument nach Pfad |
| GET | /api/v1/docs/search | Semantische Suche |
| GET | /api/v1/docs/hierarchy | Dokumentationsbaum |
| POST | /api/v1/docs | Dokument erstellen |
| PUT | /api/v1/docs/{id} | Dokument aktualisieren |
| DELETE | /api/v1/docs/{id} | Dokument löschen |
| POST | /api/v1/docs/chat | RAG-Chat mit Dokumentation |
Dokumente auflisten
GET /api/v1/docs?status=published&parent_id=51&search=apache&limit=50&offset=0
| Parameter | Typ | Default | Beschreibung |
| status | string | - | published, draft |
| parent_id | int | - | Filter nach Parent-Dokument |
| search | string | - | Volltextsuche in Titel/Content |
| limit | int | 50 | Max. Ergebnisse (max 100) |
| offset | int | 0 | Pagination-Offset |
Response
{
"success": true,
"data": [
{
"id": 1,
"parent_id": null,
"slug": "server",
"path": "/server",
"title": "Server",
"description": "Server-Dokumentation",
"status": "published",
"depth": 0,
"created_at": "2025-12-20T10:00:00",
"updated_at": "2025-12-27T12:00:00"
}
],
"meta": {
"total": 100,
"limit": 50,
"offset": 0
}
}
Dokument nach ID
GET /api/v1/docs/{id}?include_children=1&include_breadcrumb=1
| Parameter | Typ | Beschreibung |
| include_children | 0|1 | Kind-Dokumente einschließen |
| include_breadcrumb | 0|1 | Breadcrumb-Pfad einschließen |
Response
{
"success": true,
"data": {
"id": 51,
"title": "API",
"path": "/api",
"content": "...",
...
},
"children": [...],
"breadcrumb": [
{"id": 51, "title": "API", "path": "/api"}
]
}
Dokument nach Pfad
GET /api/v1/docs/path/api/chat
Liefert Dokument mit Pfad /api/chat.
Semantische Suche
GET /api/v1/docs/search?q=Apache+SSL&limit=5&category=Betrieb
| Parameter | Typ | Default | Beschreibung |
| q | string | required | Suchanfrage |
| limit | int | 5 | Max. Ergebnisse |
| category | string | - | Taxonomie-Kategorie-Filter |
Response
{
"success": true,
"data": [
{
"chunk_id": 42,
"content": "Apache SSL Konfiguration...",
"score": 0.92,
"dokument_title": "Apache",
"path": "/server/apache"
}
],
"meta": {
"query": "Apache SSL",
"limit": 5,
"count": 3
}
}
Dokumentationsbaum
GET /api/v1/docs/hierarchy
Liefert vollständigen Dokumentationsbaum als verschachtelte Struktur.
Response
{
"success": true,
"data": [
{
"id": 1,
"title": "Server",
"path": "/server",
"children": [
{"id": 2, "title": "SSH", "path": "/server/ssh", "children": []},
{"id": 3, "title": "UFW", "path": "/server/ufw", "children": []}
]
}
]
}
Dokument erstellen
POST /api/v1/docs
Content-Type: application/json
{
"title": "Neues Dokument",
"slug": "neues-dokument",
"content": "Inhalt
Text...
",
"description": "Beschreibung",
"parent_id": 51,
"status": "draft",
"sort_order": 10
}
| Feld | Typ | Pflicht | Beschreibung |
| title | string | Ja | Dokumenttitel |
| slug | string | Ja | URL-Slug (eindeutig pro Parent) |
| content | string | Nein | HTML-Inhalt |
| description | string | Nein | Kurzbeschreibung |
| parent_id | int | Nein | Parent-Dokument-ID |
| status | string | Nein | draft (default) oder published |
| sort_order | int | Nein | Sortierreihenfolge |
Response (201 Created)
{
"success": true,
"data": {...},
"message": "Dokument erstellt"
}
Dokument aktualisieren
PUT /api/v1/docs/{id}
Content-Type: application/json
{
"title": "Aktualisierter Titel",
"content": "Neuer Inhalt
",
"description": "Neue Beschreibung",
"status": "published"
}
Alle Felder sind optional - nur übergebene Felder werden aktualisiert.
Dokument löschen
DELETE /api/v1/docs/{id}
Wichtig: Dokumente mit Unterdokumenten können nicht gelöscht werden. Lösche zuerst alle Kind-Dokumente.
Fehler-Response
{
"success": false,
"error": "Dokument hat Unterdokumente. Lösche diese zuerst."
}
RAG-Chat
POST /api/v1/docs/chat
Content-Type: application/json
{
"question": "Wie konfiguriere ich Apache SSL?",
"model": "mistral",
"limit": 5
}
| Parameter | Typ | Default | Beschreibung |
| question | string | required | Benutzer-Frage |
| model | string | mistral | LLM-Modell (Ollama) |
| limit | int | 5 | Max. Kontext-Chunks |
Response
{
"success": true,
"data": {
"answer": "Um Apache SSL zu konfigurieren...",
"sources": [
{"title": "Apache", "path": "/server/apache", "score": 0.89}
],
"model": "mistral",
"tokens": {"input": 1200, "output": 350}
}
}
Fehlerbehandlung
| HTTP Code | Bedeutung |
| 400 | Fehlende oder ungültige Parameter |
| 404 | Dokument nicht gefunden |
| 500 | Server-Fehler |
Services
| Service | Beschreibung |
| DokumentationRepository | CRUD-Operationen für Dokumente |
| ChunkSearchService | Semantische Suche über Chunks |
| DocumentationChatUseCase | RAG-Chat mit Dokumentation |
Verwandte Dokumentation
]]>