SDK de TypeScript y línea de comandos
Un cliente tipado sin dependencias (Node 18+, Deno, Bun) y la herramienta de línea de comandos einv. Instálelo desde npm: npm install @einvoiceengine/sdk (licencia MIT); la CLI queda entonces disponible como npx einv.
Cliente
import { EInvoicing, EInvoicingError } from "@einvoiceengine/sdk";
const einv = new EInvoicing({ apiKey: process.env.EINV_KEY!, lang: "de" });
const r = await einv.validate(xml); // string, Uint8Array or ArrayBuffer; PDFs are detected
if (!r.valid) for (const f of r.findings) console.log(f.ruleId, f.explanation, f.suggestion);
const cii = await einv.convert(xml, "cii");
const diff = await einv.compare(xml, cii.document); // business-level, not billed
const proposals = await einv.analyze(rejected, "Abgelehnt: BR-DE-15");
const set = await einv.testdata("xrechnung-ubl"); // synthetic test invoices
const run = await einv.testSets.run(setId); // stored test set: expectations + diff to the previous run
const session = await einv.widgetSession({ origin: "https://app.example.com" });
Cada método corresponde a un endpoint de la API. Los errores se lanzan como EInvoicingError con status, code, message, details y requestId. Las respuestas 429 o 5xx se reintentan con espera progresiva (respetando Retry-After, 3 reintentos por defecto); las llamadas que crean algo llevan una Idempotency-Key, de modo que un reintento nunca se factura dos veces. lang establece el idioma de las explicaciones y sugerencias.
Línea de comandos
export EINV_KEY=einv_test_…
einv validate invoice.xml other.pdf --lang de
einv convert invoice.xml --to zugferd-facturx --out invoice.pdf
einv compare erp-export.xml received.xml
einv explain BR-CO-16
einv testdata --target xrechnung-cii --out fixtures # synthetic invoices + expected.json
einv ci out/invoices --rules 2026-11 --baseline einv-baseline.json
einv ci --test-set <id> --rules 2026-11 # run a test set stored in your account
einv formats
Códigos de salida: 0 todo ha superado la validación, 1 una factura ha fallado o dos facturas difieren, 2 error de uso o de la API. einv ci funciona como einv-ci.mjs: con --update-baseline registra los resultados actuales; después, solo los fallos nuevos hacen fallar la compilación.
E-Invoicing API