@rendoc/sdk
v1.0.0
Published
Official rendoc SDK for JavaScript/TypeScript - PDF generation API
Maintainers
Readme
rendoc
Official JavaScript/TypeScript SDK for rendoc - PDF generation API.
Zero dependencies. Works with Node.js 18+, Bun, Deno, and browsers.
Installation
npm install rendocQuick Start
ESM
import { Rendoc } from "rendoc";
const client = new Rendoc({ apiKey: "rnd_..." });
// Generate a PDF from markup
const doc = await client.documents.generate({
markup: "<h1>{{title}}</h1><p>{{body}}</p>",
data: { title: "Invoice #001", body: "Thank you for your purchase." },
paperSize: "A4",
filename: "invoice.pdf",
});
console.log(doc.downloadUrl);CommonJS
const { Rendoc } = require("rendoc");
const client = new Rendoc({ apiKey: "rnd_..." });Usage
Generate a PDF from a template
const doc = await client.documents.generate({
templateId: "tmpl_123",
data: { name: "John Doe", amount: 99.99 },
});Retrieve a document
const doc = await client.documents.get("doc_abc123");List templates
const templates = await client.templates.list();
// Filter by category
const invoices = await client.templates.list({ category: "INVOICE" });Create a template
const template = await client.templates.create({
name: "Invoice",
slug: "invoice",
markup: "<h1>Invoice for {{name}}</h1>",
schema: { type: "object", properties: { name: { type: "string" } } },
});Manage API keys
const keys = await client.apiKeys.list();
const newKey = await client.apiKeys.create({
name: "production",
scopes: ["documents:write"],
});Check usage
const usage = await client.usage.get();
console.log(`${usage.usage.documents}/${usage.usage.limit} documents used`);
// Historical usage
const jan = await client.usage.get({ year: 2026, month: 1 });Error Handling
import { Rendoc, AuthenticationError, RateLimitError } from "rendoc";
try {
const doc = await client.documents.generate({ ... });
} catch (error) {
if (error instanceof AuthenticationError) {
console.error("Invalid API key");
} else if (error instanceof RateLimitError) {
console.error("Rate limited, retry later");
}
}Custom Base URL
const client = new Rendoc({
apiKey: "rnd_...",
baseUrl: "https://custom.rendoc.dev",
});Documentation
Full API documentation at https://rendoc.dev/docs.
License
MIT
