TypeScript SDK i wiersz poleceń
Typowany klient bez zależności (Node 18+, Deno, Bun) i narzędzie wiersza poleceń einv. Zainstaluj je z npm: npm install @einvoiceengine/sdk (licencja MIT); CLI jest wtedy dostępne jako npx einv.
Klient
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" });
Każda metoda odpowiada jednemu endpointowi API. Błędy są zgłaszane jako EInvoicingError z status, code, message, details i requestId. Odpowiedzi 429 lub 5xx są ponawiane z narastającym opóźnieniem (z uwzględnieniem Retry-After, domyślnie 3 ponowienia); wywołania, które coś tworzą, wysyłają Idempotency-Key, więc ponowienie nigdy nie jest rozliczane dwa razy. lang ustawia język wyjaśnień i sugestii.
Wiersz poleceń
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
Kody wyjścia: 0 wszystko przeszło, 1 faktura nie przeszła walidacji lub dwie faktury się różnią, 2 błąd użycia lub błąd API. einv ci działa jak einv-ci.mjs: z --update-baseline zapisuje dzisiejsze wyniki, a później build psują tylko nowe błędy.
E-Invoicing API