Language Examples
Render charts from Node, Python, Go, Ruby, or curl.
Node / TypeScript (SDK)
The official SDK gives you types, autocomplete, timeout handling, and typed errors:
npm install @szum-io/sdkimport { Szum } from "@szum-io/sdk";
const szum = new Szum({ apiKey: "YOUR_API_KEY" });
const svg = await szum.render({
format: "svg",
theme: "editorial",
marks: [{ type: "barY", data: [{ x: "Q1", y: 42 }, { x: "Q2", y: 58 }] }],
});Save to a file:
import { writeFile } from "node:fs/promises";
await writeFile("chart.svg", svg);The SDK automatically injects the schema version it was built against – no need to pass version in your config. You can also use fetch directly if you prefer – see the API reference for the raw HTTP interface.
Python
import requests
config = {
"version": "2026-03-20",
"format": "svg",
"theme": "editorial",
"marks": [{"type": "barY", "data": [{"x": "Q1", "y": 42}, {"x": "Q2", "y": 58}]}],
}
res = requests.post(
"https://szum.io/chart",
json=config,
headers={"Authorization": "Bearer YOUR_API_KEY"},
)
with open("chart.svg", "wb") as f:
f.write(res.content)format is required. The example above uses "svg" – change to "png" for raster output (emails, Slack).
Go
package main
import (
"bytes"
"encoding/json"
"io"
"net/http"
"os"
)
func main() {
config := map[string]any{
"version": "2026-03-20",
"format": "svg",
"theme": "editorial",
"marks": []map[string]any{{
"type": "barY",
"data": []map[string]any{
{"x": "Q1", "y": 42},
{"x": "Q2", "y": 58},
},
}},
}
body, _ := json.Marshal(config)
req, _ := http.NewRequest("POST", "https://szum.io/chart", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
f, _ := os.Create("chart.svg")
defer f.Close()
io.Copy(f, res.Body)
}Ruby
require "net/http"
require "json"
require "uri"
config = {
version: "2026-03-20",
format: "svg",
theme: "editorial",
marks: [{ type: "barY", data: [{ x: "Q1", y: 42 }, { x: "Q2", y: 58 }] }],
}
uri = URI("https://szum.io/chart")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer YOUR_API_KEY"
req["Content-Type"] = "application/json"
req.body = JSON.generate(config)
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
File.write("chart.svg", res.body)curl
curl -X POST https://szum.io/chart \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"version":"2026-03-20","format":"svg","marks":[{"type":"barY","data":[{"x":"Q1","y":42},{"x":"Q2","y":58}]}]}' \
-o chart.svgEmbedding as an image
Keyless GET embeds need no API key. Construct the URL directly – works anywhere images render:
<!-- HTML / Email -->
<img src='https://szum.io/chart?config={"version":"2026-03-20","format":"png","marks":[{"type":"barY","data":[{"x":"Q1","y":42},{"x":"Q2","y":58}]}]}' /><!-- Markdown / GitHub README -->
GET URLs must be percent-encoded in production. We show them unencoded here for readability. Your HTTP client or browser will typically handle this for you.