Node.js SDK

Parse Invoices to JSON with Node.js

One API call. Structured JSON with every invoice field — vendor, amounts, due date, and line items. TypeScript-first, async ready.

TypeScript types included Sync & async modes Webhook support
parse-invoice.ts
import Parselyze from 'parselyze';

const parselyze = new Parselyze(process.env.PARSELYZE_API_KEY!);

const job = await parselyze.documents.parseAsync({
  file:       './invoices/acme-q3.pdf',
  templateId: 'tpl_invoice',
});

const result = await parselyze.jobs.get(job.jobId);
// ✓ Structured JSON — ready to use
console.log(result.result.vendor_name);   // 'ACME Corporation'
console.log(result.result.total_amount);  // 1500.00
console.log(result.result.line_items);   // [{ description, qty, unit_price, total }]
Integration Guide

From zero to invoice JSON in 4 steps

No boilerplate. No configuration. Just install, initialize, and parse.

01

Install the SDK

Add the Parselyze Node.js package to your project with npm or yarn.

npm install parselyze
02

Initialize the client

Create a Parselyze client with your API key from the dashboard. API keys start with plz_.

import Parselyze from 'parselyze';
const parselyze = new Parselyze(process.env.PARSELYZE_API_KEY!);
03

Submit an invoice

Pass a file path, URL, or Buffer. Returns a job ID immediately — no blocking wait.

const job = await parselyze.documents.parseAsync({
  file: './invoices/acme-q3.pdf',
  templateId: 'tpl_invoice',
});
// job.jobId = 'job_xkP3mR...'
04

Retrieve the structured JSON

Poll the job with the returned job ID. Access every extracted field on the result object.

const result = await parselyze.jobs.get(job.jobId);
if (result.status === 'completed') {
  console.log(result.result.vendor_name);  // 'ACME Corporation'
  console.log(result.result.total_amount); // 1500.00
  console.log(result.result.line_items);   // [{...}]
}
Async Processing

Process invoices at scale with async jobs

For batch processing, large files, or non-blocking pipelines, use async jobs and receive results via webhook.

Submit an async invoice job

const job = await parselyze.documents.parseAsync({
  file:       './invoices/batch-001.pdf',
  templateId: 'tpl_invoice',
});

// Returns immediately — job is queued
console.log(job.jobId); // 'job_xkP3mR...'

// Poll or wait for webhook notification
const result = await parselyze.jobs.get(job.jobId);

Handle the webhook result

const parselyze = new Parselyze(
  process.env.PARSELYZE_API_KEY!,
  process.env.WEBHOOK_SECRET!,
);

app.post('/hooks/parselyze', async (req, res) => {
  parselyze.webhooks.verifySignature(
    req.body,
    req.headers['x-webhook-signature'],
  );

  const { result } = req.body;
  await saveInvoiceToDatabase(result);
  res.sendStatus(200);
});
Output Example

What the JSON response looks like

Every field, fully typed. Ready for TypeScript interfaces.

result.result
{
  "invoice_number": "FCT-000342",
  "invoice_date":   "2024-05-28",
  "due_date":       "2024-06-27",
  "vendor_name":    "ACME Corporation",
  "currency":       "USD",
  "subtotal":       1300.00,
  "tax_amount":     200.00,
  "total_amount":   1500.00,
  "line_items": [
    {
      "description": "Consulting services",
      "qty":         8,
      "unit_price":  125.00,
      "total":       1000.00
    },
    {
      "description": "Design mockups",
      "qty":         1,
      "unit_price":  300.00,
      "total":       300.00
    }
  ]
}

Frequently asked questions

Everything about parsing invoices in Node.js.

How do I parse invoice PDFs in Node.js?

Install the Parselyze Node.js SDK with npm install parselyze, initialize the client with your API key, and call parselyze.documents.parseAsync() with your invoice file path or URL. Poll the result with parselyze.jobs.get(job.jobId) to receive structured JSON with every invoice field extracted.

Does the Node.js SDK support async invoice processing?

Yes. parselyze.documents.parseAsync() submits your invoice and returns a job ID immediately. Call parselyze.jobs.get(job.jobId) to poll the result, or configure a webhook in the dashboard to receive results automatically when processing completes.

Can I extract line items from invoices in Node.js?

Yes. The extracted JSON includes a line_items array where each element contains description, quantity, unit_price, and total. Line items are fully typed in the TypeScript SDK.

How do I handle invoice results with a webhook in Node.js?

Register a webhook URL in the Parselyze dashboard. Parselyze sends a POST to your endpoint when extraction completes. The SDK includes a webhooks.verifySignature() helper to validate the x-webhook-signature header and ensure the payload is genuine.

Is the Parselyze Node.js SDK written in TypeScript?

Yes. The SDK ships with full TypeScript types for all request and response objects. No @types package is required.

Start parsing invoices in Node.js today

Free plan · 50 pages/month · No credit card required