DEV Community

Invovate
Invovate

Posted on • Originally published at invovate.com

How to generate PDF invoices from JSON with a free API

Generating a clean, professional PDF invoice in code is one of those tasks that looks trivial until you start. You reach for a PDF library, then fight with layout, fonts, multi-currency formatting, VAT/tax math, and right-to-left languages. An hour later you have a brittle template and you still have to maintain it.

This post shows a shortcut: turn one JSON payload into a finished invoice — PDF, JSON totals, or UBL XML — with a single HTTP POST, using the free Invovate API. No PDF library, no template engine.

Try it with zero setup (no API key)

Anonymous calls can compute invoice totals — handy for validating tax/discount math before you render anything:

curl -X POST https://invovate.com/api/generate-invoice \
  -H "Content-Type: application/json" \
  -d '{
    "output": "json",
    "from": { "name": "Acme Inc" },
    "to":   { "name": "Globex LLC" },
    "items": [
      { "description": "Consulting", "quantity": 10, "unit_price": 150, "tax_rate": 20 }
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

You get back subtotal, total_tax, and grand_total as JSON. No account needed.

Get a free key (for PDF / UBL / shareable links)

Rendering an actual PDF (or UBL, or a shareable hosted link) needs a free API key:

  1. Create a free account at invovate.com, verify your email.
  2. Copy your key from the dashboard — it starts with inv_.
  3. Pass it as a bearer token: Authorization: Bearer inv_yourkey.

The free tier is 40 requests/hour, 400/week — plenty to build and run low volume.

Render a PDF (cURL)

curl -X POST https://invovate.com/api/generate-invoice \
  -H "Authorization: Bearer inv_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "output": "pdf",
    "template": "navy",
    "invoice": { "number": "INV-2026-001", "currency": "EUR", "language": "fr" },
    "from": { "name": "Acme Inc" },
    "to":   { "name": "Globex LLC", "address": "1 Rue de Rivoli, Paris" },
    "items": [
      { "description": "Consulting", "quantity": 10, "unit_price": 150, "tax_rate": 20 }
    ]
  }' --output invoice.pdf
Enter fullscreen mode Exit fullscreen mode

That's a French-language, EUR, VAT-20% invoice on the navy template — written to invoice.pdf.

Node.js

import { writeFileSync } from "node:fs";

const res = await fetch("https://invovate.com/api/generate-invoice", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.INVOVATE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    output: "pdf",
    invoice: { number: "INV-2026-001", currency: "USD", language: "en" },
    from: { name: "Acme Inc" },
    to:   { name: "Globex LLC" },
    items: [{ description: "Website design", quantity: 1, unit_price: 1500, tax_rate: 10 }],
  }),
});

writeFileSync("invoice.pdf", Buffer.from(await res.arrayBuffer()));
Enter fullscreen mode Exit fullscreen mode

Prefer a wrapper? There's an SDK: npm i invovate.

Python

import requests

resp = requests.post(
    "https://invovate.com/api/generate-invoice",
    headers={
        "Authorization": f"Bearer {INVOVATE_API_KEY}",
        # Set a User-Agent — the CDN in front of the API rejects the default
        # python-urllib / bare client UA.
        "User-Agent": "my-app/1.0",
    },
    json={
        "output": "pdf",
        "invoice": {"number": "INV-2026-001", "currency": "USD"},
        "from": {"name": "Acme Inc"},
        "to":   {"name": "Globex LLC"},
        "items": [{"description": "Website design", "quantity": 1, "unit_price": 1500, "tax_rate": 10}],
    },
)
open("invoice.pdf", "wb").write(resp.content)
Enter fullscreen mode Exit fullscreen mode

There's a Python SDK too: pip install invovate.

Languages, currencies, and tax

Set invoice.language (11 supported, including ar, ja, hi, ru with proper fonts and RTL) and invoice.currency (20+, with correct symbol/decimal handling). Per-line tax_rate and discount are supported, plus invoice-level global_tax, global_discount, and amount_paid for partial payments. The math comes back identical whether you request json or pdf.

Shareable link + QR code

Add features to get a hosted, shareable invoice URL (and optionally a scan-to-view QR):

{
  "output": "json",
  "features": { "hosted_link": true, "qr": true },
  "invoice": { "currency": "USD" },
  "from": { "name": "Acme Inc" },
  "to":   { "name": "Globex LLC" },
  "items": [{ "description": "Retainer", "quantity": 1, "unit_price": 800 }]
}
Enter fullscreen mode Exit fullscreen mode

The response includes a hosted_url you can email to a client — no login on their end.

UBL for e-invoicing

Need a machine-readable invoice? Request "output": "ubl" to get a UBL 2.1 XML document instead of a PDF — useful as a starting point for structured invoice exchange. (Note: Invovate produces the document; it does not submit to national e-invoicing networks.)

For AI agents

If you're building with LLMs, there's an MCP server (npx invovate-mcp) that exposes invoice generation as tools to Claude Desktop, Cursor, and Windsurf — so an assistant can create a real invoice from a natural-language request.

Wrap-up

One POST → a finished invoice. No PDF library to babysit, no template to maintain, and i18n + tax handled for you. The free tier (40 req/hr) is enough to ship a side project or a low-volume integration; paid plans start at $9/mo when you need more.

Disclosure: I work on Invovate. Feedback welcome — happy to answer API questions in the comments.

Top comments (0)