Developers
Render current chart requests and manage durable chart documents.
Szum gives applications one chart contract for immediate images, durable saved charts, interactive embeds, and the definitions shared with designers and agents.
Render a chart now
Start with a ChartDocument: semantic config, row data, and optional presentation, size, and output policy.
Send the same request to POST /validate before a changed render when you need structured diagnostics without consuming render allowance. Send it to POST /chart with an API key for image bytes, or to keyless GET /chart?config=... for small public requests.
Choose how the chart ships
Immediate image: POST /chart returns SVG or PNG bytes for one request.
Saved chart: POST /api/charts stores a complete ChartDocument and returns stable image, embed, edit, and management URLs.
Interactive embed: place the saved chart's /e/{id} URL in an iframe. It is responsive and interactive without a separate embed configuration.
Shared definition: read /api/charts/{id}/document to reuse or update the published document. A newer Studio draft is returned separately and is never silently substituted for the publication.
Use the SDK in production
Install the TypeScript SDK:
pnpm add @szum-io/sdkimport { writeFile } from "node:fs/promises";
import { Szum, type ChartDocument } from "@szum-io/sdk";
const request = {
"config": {
"type": "column",
"category": {
"field": "quarter"
},
"values": {
"type": "long",
"field": "revenue"
}
},
"data": [
{
"quarter": "Q1",
"revenue": 42
},
{
"quarter": "Q2",
"revenue": 58
}
],
"output": {
"format": "svg"
}
} satisfies ChartDocument;
const apiKey = process.env.SZUM_API_KEY;
if (!apiKey) {
throw new Error("SZUM_API_KEY is required");
}
const szum = new Szum({ apiKey });
const image = await szum.render(request);
await writeFile("chart.svg", image);The SDK adds the current chart version it was generated with when config.version or version is omitted. Raw HTTP callers must send the explicit current version.
Generated SDK types cover config, documents, validation, render metadata, and saved-chart operations. The public /schema.json describes the active data-free ChartConfig; other languages pair that generated config type with the document envelope documented here.
Production behavior
- Authenticate with one API key in the
Authorization: Bearerheader; never put a key in an image URL, iframe, client bundle, or public repository. - Reuse one idempotency key when retrying one intended saved-chart create.
- Treat
429as backpressure and honorRetry-After. - Read structured validation paths and codes rather than parsing human messages.
- Keep a saved chart id when updating; its public image and embed URLs stay stable.
- Expect CDN hits for saved images and embeds to avoid origin render charges.