Aller au contenu

API

Escriba expose une petite API REST, pratique pour l’automatisation (n8n, scripts). L’authentification est toujours requise.

Avec un token d’API (définissez API_TOKEN) :

Fenêtre de terminal
curl -H "X-API-Key: YOUR_TOKEN" \
-F "file=@document.pdf" \
https://your-domain/api/convert
# Force OCR / set language: -F "ocr=true" -F "lang=es-ES"

Avec un cookie de session :

Fenêtre de terminal
curl -c cookies.txt -F "password=$GOD_PASSWORD" https://your-domain/api/login
curl -b cookies.txt -F "file=@document.pdf" https://your-domain/api/convert

POST /api/convert (multipart/form-data) : file ou url, plus les options lang, ocr, pages, llm_provider, llm_api_key, llm_model. Réponse :

{ "source": "", "title": "", "markdown": "",
"words": 1234, "chars": 5678, "elapsed_ms": 87,
"pdf_type": "scanned", "ocr_applied": true, "note": null }

POST /api/redact (multipart/form-data) : file (PDF ou image), options lang, anon_strict, anon_detectors, anon_rules. Renvoie le PDF caviardé (binaire) avec l’en-tête X-Redacted-Entities qui compte ce qui a été noirci.

JSON en entrée, JSON ou fichier en sortie :

EndpointMéthodeDescription
/api/exportPOSTConvertir le Markdown vers un format cible (docx, odt, epub, html, latex, rst, docbook, jats, tei, opml).
/api/compactPOSTMarkdown débarrassé des espaces pour économiser des tokens.
/api/chunkPOSTMorceaux RAG bornés en tokens (renvoie .jsonl).
/api/model_pricesGETTarifs et fenêtres de contexte des modèles en temps réel (OpenRouter, en cache).