API Overview

Lectito exposes the same extraction and trope-analysis engine through four surfaces:

  • Rust Crate API for native applications and server integrations.
  • CLI Usage for files, stdin, URLs, and AT URIs.
  • The HTTP service for JSON requests at /v1/extract, /v1/evaluate, /v1/transform, and /v1/tropes/analyze.
  • WASM API for browser, web worker, bundler, and Node.js integrations.

Rust owns the implementation. The CLI, HTTP service, and WASM binding call the same core functions, so trope findings use the same rule IDs, ranges, scores, and provenance on every surface.

HTTP trope analysis

Send text to POST /api/v1/tropes/analyze:

curl -X POST https://lectito.stormlightlabs.org/api/v1/tropes/analyze \
  -H 'content-type: application/json' \
  -d '{
    "text":"It is worth noting that this serves as an example.",
    "options":{"minSeverity":"medium"}
  }'

The response contains report and an elapsedMs measurement.

The report uses the core JSON shape: score, signal, findings, and summary. Request option names use camelCase; report fields retain their Rust snake_case names.

The endpoint returns heuristic writing diagnostics, not an authorship score. A finding is evidence that a phrase or structure matches a bundled rule; it does not show who wrote the text.

POST /api/v1/extract can include the same report by setting "tropeDiagnostics": true.

The analyzer scans the extracted article's text_content, not the source HTML.

The field is omitted from the response when the flag is false.

The built-in rules come from the vendored tropes.md catalog and each finding includes its source file and heading. The HTTP API does not accept custom rules; the options object selects a preset, severity floor, and whether to include suggestions. balanced is the default. lenient removes low-severity findings and requires stronger repeated evidence; strict includes lower-evidence structural and document findings.