HTML to PDF API integration guide

This guide takes you from an API key to a working html to pdf call in your own stack: plain HTTP, Node.js, Python, Bubble, Make and n8n. Every example calls the same endpoint, /v1/pdf/from-html, and gets the same response. The parameters are listed in the HTML to PDF API reference.

Before you write code, try the same job in the free online version. It runs on the same worker, so what you see there is what the API returns.

HTML or URL

Send html when you build the document yourself, for example an invoice template filled by your app. Send url for a page that is already online. Exactly one of the two. A url that points to a private or internal address is refused, and so is any request the page makes to one while it loads.

Step 1: get a key

Create an account to get 1 USD of free credit, with no card. At $0.006 a call, that is 166 calls. Keep the key on your server or in a backend workflow. Never put it in browser code.

Step 2: make the call with curl

curl https://api.justapi.tech/v1/pdf/from-html \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"html": "<h1>Invoice #1042</h1><p>Total: $120.00</p>", "options": {"format": "Letter", "margin": "12mm", "footer_html": "<div style=\"font-size:9px;width:100%;text-align:center\"><span class=\"pageNumber\"></span> / <span class=\"totalPages\"></span></div>"}}'

The response has status, a result with a download url that expires, and billing.charged_micros, the exact charge in millionths of a dollar.

Step 3: Node.js

const res = await fetch('https://api.justapi.tech/v1/pdf/from-html', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.JUSTAPI_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': crypto.randomUUID(),
  },
  body: JSON.stringify({"html": "<h1>Invoice #1042</h1><p>Total: $120.00</p>", "options": {"format": "Letter", "margin": "12mm", "footer_html": "<div style=\"font-size:9px;width:100%;text-align:center\"><span class=\"pageNumber\"></span> / <span class=\"totalPages\"></span></div>"}}),
});
const job = await res.json();
if (!res.ok) throw new Error(`${job.error.code}: ${job.error.message}`);
console.log(job.result.url, job.billing.charged_micros);

Step 4: Python

import os, uuid, requests

res = requests.post(
    "https://api.justapi.tech/v1/pdf/from-html",
    headers={
        "Authorization": f"Bearer {os.environ['JUSTAPI_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
    "html": "<h1>Invoice #1042</h1><p>Total: $120.00</p>",
    "options": {
        "format": "Letter",
        "margin": "12mm",
        "footer_html": "<div style=\"font-size:9px;width:100%;text-align:center\"><span class=\"pageNumber\"></span> / <span class=\"totalPages\"></span></div>"
    }
},
    timeout=60,
)
job = res.json()
res.raise_for_status()
print(job["result"]["url"], job["billing"]["charged_micros"])

Step 5: Bubble

  1. Install the API Connector plugin and add an API called JustAPI.
  2. Add a shared header Authorization with the value Bearer YOUR_API_KEY, and tick Private so it never reaches the browser.
  3. Add a call named html-to-pdf: method POST, URL https://api.justapi.tech/v1/pdf/from-html, Use as: Action, body type JSON.
  4. Paste this body and replace the file URL with a dynamic value:
{"html": "<h1>Invoice #1042</h1><p>Total: $120.00</p>", "options": {"format": "Letter", "margin": "12mm", "footer_html": "<div style=\"font-size:9px;width:100%;text-align:center\"><span class=\"pageNumber\"></span> / <span class=\"totalPages\"></span></div>"}}
  1. Initialize the call with a real file, then use it in a backend workflow. Save result url to your thing, or download it to Bubble storage if you need it after the link expires.

Step 6: Make and n8n

In Make, use the HTTP > Make a request module; in n8n, the HTTP Request node. Method POST, the URL above, the Authorization header, body type JSON with the same body. Turn on "parse response" so the next step can read result.url.

Errors and retries

Recommendations

What it will cost

Use case What it does Calls a month Estimated cost a month
SaaS invoices Renders one invoice per customer per month from an HTML template. 3,000 $16.00
Reports from a dashboard Saves a dashboard page as PDF for weekly emails. 800 $4.80
Tickets and certificates Generates event tickets and course certificates. 25,000 $111

Costs use the published volume tiers: the first 1,000 calls of the month at tier 1, calls 1,001 to 10,000 at tier 2, and every call after that at tier 3. Failed calls cost nothing, so they are not in these figures.

Compare providers in HTML to PDF API pricing compared: 5 services, 3 bills, and see every price on the pricing page.