# Funktionsnachweis – API-Calls mit Beispielantworten (curl / Postman)

*Diese Seite ist das Audit-Dokument für die Funktionsfähigkeit aller produktiv genutzten APIs. Pro Service ein nachvollziehbarer Beispiel-Call mit Request, erwarteter Response, Status-Code und Use-Case. Im echten Audit werden die Calls live durchgespielt und Screenshots / Postman-Exports beigelegt.*

---

## 1. Aufbau pro Eintrag

- **Service &amp; Endpoint:** was wird aufgerufen
- **Request:** curl-Befehl, exakt
- **Erwartete Response:** repräsentatives Antwort-Beispiel
- **Status:** erwarteter HTTP-Code
- **Use-Case:** wofür der Call konkret eingesetzt wird

## 2. Postman-Setup (für interaktive Demos)

1. Postman Desktop oder Postman-Web öffnen
2. Workspace "Local-AI-Manager" anlegen
3. Collection "Lokales KI-Setup" erstellen
4. Environment "kistudent-LAN" mit Variablen: 
    - `HOST_POPOS` = `192.168.0.16`
    - `HOST_SYNO` = `192.168.0.82`
    - `OLLAMA_PORT` = `8000`
    - `LOCALAI_PORT` = `8085`
    - `ANYTHINGLLM_TOKEN` = *(secret)*
    - `FLOWISE_TOKEN` = *(secret)*
    - `PAPERLESS_TOKEN` = *(secret)*
    - `AKAUNTING_TOKEN` = *(secret)*
    - `BOOKSTACK_AUTH` = *Token id:secret*
5. Pro Service einen Folder anlegen, Requests aus dieser Seite übernehmen
6. Collection exportieren (JSON), als Anhang im BookStack hochladen

---

## 3. Ollama

### 3.1 Modelle listen

```
curl http://192.168.0.16:8000/api/tags
```

**Response (200):**

```
{
  "models": [
    {"name":"qwen2.5:14b","size":9000000000,"modified_at":"2026-05-01T08:00:00Z"},
    {"name":"qwen3:8b","size":5200000000,"modified_at":"2026-05-01T08:05:00Z"},
    {"name":"nomic-embed-text:latest","size":274000000,"modified_at":"2026-04-15T12:00:00Z"}
  ]
}
```

**Use-Case:** Initial-Verifikation, Monitoring-Healthcheck.

### 3.2 Chat (non-stream)

```
curl http://192.168.0.16:8000/api/chat \
  -H "Content-Type: application/json" \
  -d '{
    "model":"qwen2.5:14b",
    "stream":false,
    "messages":[{"role":"user","content":"Sage in einem Satz, was ein DC-Link-Kondensator macht."}]
  }'
```

**Response (200):**

```
{
  "model":"qwen2.5:14b",
  "created_at":"2026-05-26T19:00:00Z",
  "message":{"role":"assistant","content":"Ein DC-Link-Kondensator glättet die Zwischenkreis-Gleichspannung und puffert Lastspitzen."},
  "done":true,
  "total_duration": 2100000000
}
```

**Use-Case:** Standard-Chat aus n8n, KI-CRM, Continue (VS Code).

---

## 4. LocalAI

### 4.1 OpenAI-kompatibler Chat

```
curl http://192.168.0.16:8085/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model":"qwen",
    "messages":[{"role":"user","content":"Liste 3 Kondensatortypen."}],
    "temperature":0.2
  }'
```

**Response (200):**

```
{
  "id":"chatcmpl-abc",
  "object":"chat.completion",
  "model":"qwen",
  "choices":[{
    "index":0,
    "message":{"role":"assistant","content":"1) Elektrolyt-Kondensatoren, 2) Film-Kondensatoren, 3) Keramik-Kondensatoren."},
    "finish_reason":"stop"
  }],
  "usage":{"prompt_tokens":20,"completion_tokens":24,"total_tokens":44}
}
```

**Status:** 200  
**Use-Case:** Als OpenAI-Drop-in für jede Software, die die OpenAI-API erwartet.

### 4.2 Embedding

```
curl http://192.168.0.16:8085/v1/embeddings \
  -H "Content-Type: application/json" \
  -d '{"model":"nomic-embed-text","input":"Kondensatoren glätten Spannung."}'
```

**Response (200):**

```
{
  "object":"list",
  "data":[{"object":"embedding","index":0,"embedding":[0.0123,-0.0456,0.0789, ... ]}],
  "model":"nomic-embed-text"
}
```

**Use-Case:** RAG-Pipelines, AnythingLLM Embedding-Provider.

### 4.3 Whisper-Transkription

```
curl http://192.168.0.16:8085/v1/audio/transcriptions \
  -F file="@diktat.mp3" -F model="whisper-1" -F language="de"
```

**Response (200):**

```
{"text":"Vermerk zum Kundenbesuch bei Firma ACME..."}
```

**Use-Case:** Diktat-zu-Bericht im KI-CRM.

---

## 5. AnythingLLM

### 5.1 Auth-Verifikation

```
curl https://rag.kistudent.local/api/v1/auth \
  -H "Authorization: Bearer $ANYTHINGLLM_TOKEN"
```

**Response (200):**

```
{"authenticated":true}
```

**Use-Case:** Health-Probe vor Workflow-Start.

### 5.2 Workspace-Chat (RAG)

```
curl -X POST https://rag.kistudent.local/api/v1/workspace/produkte-jianghai/chat \
  -H "Authorization: Bearer $ANYTHINGLLM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message":"Welche EDLC-Serien führen wir?","mode":"query"}'
```

**Response (200):**

```
{
  "id":"resp-001",
  "type":"abort|textResponseChunk|textResponse",
  "textResponse":"Im Workspace sind die Serien CDA, CDH und CD29HD dokumentiert...",
  "sources":[
    {"title":"Jianghai-EDLC-Katalog.pdf","chunkSource":"page 4"},
    {"title":"Datenblatt-CD29HD.pdf","chunkSource":"page 1"}
  ],
  "chatId":"abc-123"
}
```

**Use-Case:** KI-CRM-Produkt-Recherche, intern.

---

## 6. Flowise

### 6.1 Flow-Aufruf

```
curl -X POST https://flowise.kistudent.local/api/v1/prediction/<flowId> \
  -H "Authorization: Bearer $FLOWISE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"question":"Was ist der Unterschied zwischen EDLC und LIC?"}'
```

**Response (200):**

```
{
  "text":"EDLCs (Electric Double-Layer Capacitors) speichern Energie elektrostatisch... LICs (Lithium-Ion Capacitors) kombinieren EDLC- und Batterie-Mechanismen...",
  "question":"Was ist der Unterschied zwischen EDLC und LIC?",
  "chatId":"xyz-001",
  "chatMessageId":"msg-001",
  "sessionId":"session-001"
}
```

**Use-Case:** Komplexere RAG-Flows mit Document-Loader, Memory und Tools.

---

## 7. SearXNG

### 7.1 JSON-Suche

```
curl "http://192.168.0.82:<PORT>/search?q=Jianghai+CDA+EDLC&format=json&language=de"
```

**Response (200):**

```
{
  "query":"Jianghai CDA EDLC",
  "number_of_results":0,
  "results":[
    {
      "url":"https://jianghai-europe.com/products/cda-series/",
      "title":"CDA EDLC Series - Jianghai Europe",
      "content":"Long-life Electric Double Layer Capacitor for industrial applications...",
      "engine":"duckduckgo"
    },
    {
      "url":"https://www.exista.ch/produkte/jianghai-cda/",
      "title":"Jianghai CDA — Exista AG",
      "content":"Distributor in der Schweiz...",
      "engine":"brave"
    }
  ]
}
```

**Use-Case:** AnythingLLM-Web-Search, n8n-Firmen-Anreicherung.

---

## 8. BookStack

### 8.1 Bücher listen

```
curl https://bookstack.kistudent.synology.me/api/books \
  -H "Authorization: Token $BOOKSTACK_AUTH"
```

**Response (200):**

```
{
  "data":[
    {"id":34,"name":"ts-study-ai-solutions-and-architect-engineer","slug":"ts-study-ai-solutions-and-architect-engineer", "..." :"..."}
  ],
  "total":1
}
```

### 8.2 Seite erstellen (HTML)

```
curl -X POST https://bookstack.kistudent.synology.me/api/pages \
  -H "Authorization: Token $BOOKSTACK_AUTH" \
  -H "Content-Type: application/json" \
  -d '{
    "book_id":34,
    "chapter_id":40,
    "name":"Test-Seite",
    "html":"<p>Beispielinhalt</p>"
  }'
```

**Response (200):**

```
{
  "id":123,
  "book_id":34,
  "chapter_id":40,
  "name":"Test-Seite",
  "slug":"test-seite",
  "html":"<p>Beispielinhalt</p>",
  "created_at":"2026-05-26T20:00:00Z"
}
```

**Use-Case:** Automatisches Anlegen von Doku-Seiten aus n8n (z.B. nach Meeting-Mitschriften).

---

## 9. Paperless-ngx

### 9.1 Inbox-Dokumente filtern

```
curl "https://docs.kistudent.local/api/documents/?tags__id__in=12&tags__id__none=15" \
  -H "Authorization: Token $PAPERLESS_TOKEN"
```

**Response (200):**

```
{
  "count":3,
  "next":null,
  "previous":null,
  "results":[
    {"id":201,"title":"ACME-Rechnung","correspondent":7,"document_type":2,"tags":[12]},
    {"id":202,"title":"Vertrag XYZ","correspondent":8,"document_type":4,"tags":[12]},
    {"id":203,"title":"Datenblatt CDA","correspondent":null,"document_type":5,"tags":[12]}
  ]
}
```

### 9.2 Volltext lesen

```
curl "https://docs.kistudent.local/api/documents/201/" \
  -H "Authorization: Token $PAPERLESS_TOKEN"
```

**Response-Auszug (200):**

```
{
  "id":201,
  "title":"ACME-Rechnung",
  "content":"Rechnung Nr. ACME-2026-0145 vom 20.05.2026, Betrag CHF 1245.50...",
  "tags":[12],
  "correspondent":7,
  "document_type":2
}
```

**Use-Case:** LLM-Extraktion in n8n.

### 9.3 Tag setzen (verarbeitet)

```
curl -X PATCH https://docs.kistudent.local/api/documents/201/ \
  -H "Authorization: Token $PAPERLESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tags":[12,15]}'
```

**Response (200):** komplettes Dokument-Objekt mit neuen Tags.

---

## 10. Akaunting

### 10.1 Tax-Sätze abfragen

```
curl "https://buchhaltung.kistudent.local/api/taxes?company_id=1" \
  -H "Authorization: Bearer $AKAUNTING_TOKEN"
```

**Response (200):**

```
{
  "data":[
    {"id":1,"name":"MWST 0%","rate":0.00,"type":"normal"},
    {"id":2,"name":"MWST 2.6%","rate":2.60,"type":"normal"},
    {"id":3,"name":"MWST 8.1%","rate":8.10,"type":"normal"},
    {"id":4,"name":"MWST 3.8%","rate":3.80,"type":"normal"}
  ]
}
```

### 10.2 Eingangsrechnung als Draft anlegen

```
curl -X POST "https://buchhaltung.kistudent.local/api/documents?company_id=1" \
  -H "Authorization: Bearer $AKAUNTING_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type":"bill",
    "document_number":"ACME-2026-0145",
    "issued_at":"2026-05-20",
    "due_at":"2026-06-19",
    "contact_id":42,
    "currency_code":"CHF",
    "items":[{"name":"Lieferung Kondensatoren","quantity":100,"price":12.50,"tax_ids":[3]}],
    "status":"draft"
  }'
```

**Response (201):**

```
{
  "data":{
    "id":789,
    "type":"bill",
    "document_number":"ACME-2026-0145",
    "status":"draft",
    "amount":1351.25
  }
}
```

**Use-Case:** n8n-Workflow aus Paperless-Rechnung.

---

## 11. Nextcloud (WebDAV)

### 11.1 Ordner-Listing (PROPFIND)

```
curl -X PROPFIND -u "user:app-passwort" \
  -H "Depth: 1" \
  "https://cloud.kistudent.local/remote.php/dav/files/user/KI-RAG/Produkte/"
```

**Response (207 Multi-Status):**

```
<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:">
  <d:response>
    <d:href>/remote.php/dav/files/user/KI-RAG/Produkte/Datenblatt-CDA.pdf</d:href>
    <d:propstat>
      <d:prop>
        <d:getlastmodified>Mon, 26 May 2026 18:30:00 GMT</d:getlastmodified>
        <d:getcontentlength>1245678</d:getcontentlength>
      </d:prop>
    </d:propstat>
  </d:response>
  ...
</d:multistatus>
```

**Use-Case:** n8n-Polling für RAG-Synchronisation.

### 11.2 Datei laden

```
curl -u "user:app-passwort" \
  "https://cloud.kistudent.local/remote.php/dav/files/user/KI-RAG/Produkte/Datenblatt-CDA.pdf" \
  -o Datenblatt-CDA.pdf
```

**Response (200):** Binärdaten (PDF).

---

## 12. KI-CRM (Eigenentwicklung)

### 12.1 Firma suchen

```
curl "https://crm.kistudent.local/api/firmen?search=ACME" \
  -H "Authorization: Bearer $CRM_TOKEN"
```

**Response (200):**

```
{
  "data":[
    {"firma_id":1024,"name":"ACME Ltd.","ort":"Zürich","branche":"Elektronik"}
  ],
  "total":1
}
```

### 12.2 Besuchsbericht aus Diktat anlegen

```
curl -X POST "https://crm.kistudent.local/api/besuchsplanung" \
  -H "Authorization: Bearer $CRM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "firma_id":1024,
    "datum":"2026-05-26",
    "teilnehmer":"H. Müller (ACME), T. Schütz (Exista)",
    "themen":"Jianghai CDA Lieferzeiten, Preisanpassung 2026",
    "vereinbarungen":"Angebot bis 02.06.2026"
  }'
```

**Response (201):**

```
{"id":4321,"firma_id":1024,"datum":"2026-05-26","status":"erstellt"}
```

**Use-Case:** Endpunkt der Diktat-zu-Bericht-Pipeline.

---

## 13. n8n Webhook (eingehend)

### 13.1 Trigger einer Anreicherung

```
curl -X POST https://n8n.kistudent.local/webhook/firma-anreichern \
  -H "Content-Type: application/json" \
  -H "X-Webhook-Secret: $N8N_WEBHOOK_SECRET" \
  -d '{"firma_id":1024,"firma_name":"ACME Ltd."}'
```

**Response (200):**

```
{"status":"queued","executionId":"exec-9876"}
```

**Use-Case:** Aufruf aus dem KI-CRM bei Klick auf "Anreichern".

---

## 14. Postman-Tests einbauen (kurz)

Für jeden Request in der Postman-Collection kann ein "Test"-Skript hinterlegt werden, das den Status &amp; Antwortinhalt prüft:

```
pm.test("Status 200", function () {
  pm.response.to.have.status(200);
});

pm.test("Antwort enthält 'choices'", function () {
  pm.expect(pm.response.text()).to.include("choices");
});

pm.test("Antwort < 5 s", function () {
  pm.expect(pm.response.responseTime).to.be.below(5000);
});
```

Damit wird die Collection zu einer Mini-Test-Suite – auch im Audit-Termin demonstrierbar.

## 15. Schritt-für-Schritt-Demo (Reihenfolge im Audit)

1. Ollama: `/api/tags` – zeigt verfügbare Modelle
2. LocalAI: `/v1/chat/completions` – Antwort auf einfache Frage
3. LocalAI: `/v1/embeddings` – Vektor zurück
4. LocalAI: `/v1/audio/transcriptions` – Mini-Audio-File transkribieren
5. AnythingLLM: `/api/v1/auth` + `/workspace/.../chat` – RAG mit Sources
6. Flowise: `/api/v1/prediction/...` – ein produktiver Flow antwortet
7. SearXNG: JSON-Suche – Web-Treffer
8. BookStack: `/api/books` – Doku-Buch erscheint
9. Paperless: `/api/documents/...` – Volltext-Auszug
10. Akaunting: `/api/taxes` + `/api/documents` – Draft-Beleg entsteht
11. Nextcloud: `PROPFIND` – Dateiliste
12. KI-CRM: Firma-Lookup + Besuchsbericht-Anlage
13. n8n: Webhook-Trigger – Workflow-Execution in der UI sichtbar

## 16. Dokumentations-Hinweis

- Echte Responses (mit aktuellen IDs und Werten) als Anhang ins BookStack
- Postman-Collection-Export ebenfalls als Anhang
- Bei jeder grösseren Konfigurationsänderung Tests erneut laufen lassen
- Token in den Beispielen NICHT im Klartext exportieren – maskieren oder via Environment-Variable

## 17. Checkliste

- ☐ Postman-Workspace mit Environment angelegt
- ☐ Collection enthält pro Service mindestens einen funktionierenden Request
- ☐ Tests (Status, Inhalt, Laufzeit) hinterlegt
- ☐ Sensible Werte ausschliesslich in Environment-Variablen
- ☐ Beispiel-Responses als Screenshot/Export im BookStack
- ☐ Demo-Reihenfolge geprobt
- ☐ Collection-Export als Anhang gespeichert

---