HTTP API
The platex service exposes a tiny HTTP API. You rarely call it directly — the client library and request handlers speak it for you — but here’s the wire format for building requests by hand, debugging, or writing a client in another language.
Endpoints
Section titled “Endpoints”| Method | Path | Description |
|---|---|---|
POST |
/compile |
Compile LaTeX. Body: CompileRequest JSON. Response: CompileResponse JSON |
GET |
/health |
Health check. Returns { "status": "ok" } (never requires auth) |
POST /compile
Section titled “POST /compile”Request body
Section titled “Request body”interface CompileRequest { source: string; // LaTeX source (main.tex content) engine: 'pdflatex' | 'xelatex' | 'lualatex'; passes: 'auto' | 1 | 2 | 3; bibliography: 'bibtex' | 'biber' | 'none'; files: Record<string, string>; // filename → base64-encoded content timeout: number; // milliseconds, overall pipeline budget, capped at 120s}Only source is required in practice — the handler fills in defaults for the
rest. files values are base64-encoded on the wire (unlike the library’s
Buffer values, which are encoded for you).
Response body
Section titled “Response body”interface CompileResponse { pdf: string | null; // base64-encoded PDF, or null on fatal error errors: LatexError[]; warnings: LatexWarning[]; logs: RawPassLog[];}See the API reference for LatexError,
LatexWarning, and RawPassLog.
Status codes
Section titled “Status codes”| Status | Meaning |
|---|---|
200 |
Compiled (check pdf for null on fatal LaTeX errors) |
400 |
Malformed request body |
401 |
Missing/invalid bearer token (when PLATEX_API_KEY is set) |
413 |
Request body exceeds maxRequestBodyBytes |
503 |
Instance at maxConcurrentCompiles — retry shortly |
Authentication
Section titled “Authentication”If the service is started with PLATEX_API_KEY set, POST /compile requires:
Authorization: Bearer <key>GET /health never requires auth. See
Server configuration.
Examples
Section titled “Examples”Compile and extract the PDF:
curl -X POST https://platex.example.com/compile \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $PLATEX_API_KEY" \ -d '{"source": "\\documentclass{article}\\begin{document}Hi\\end{document}"}' \ | jq -r '.pdf' | base64 -d > output.pdfHealth check:
curl https://platex.example.com/health# → {"status":"ok"}See also
Section titled “See also”Server configurationAuth, concurrency, and body-size caps.
Request handlersThe app-facing handler that speaks this API for you.