SDKs
Node.js / TypeScript
Idiomatische Node.js-Patterns für die Thunderbit Open API
Die Thunderbit API funktioniert mit dem eingebauten fetch (Node 18+) — kein SDK nötig. Für HTTP/2 und Connection Pooling im großen Stil wechselst du zu undici oder axios.
Konfigurieren
const API = "https://openapi.thunderbit.com/openapi/v1";
const H = {
"Authorization": `Bearer ${process.env.THUNDERBIT_API_KEY}`,
"Content-Type": "application/json",
};Eine Seite distillen
const r = await fetch(`${API}/distill`, {
method: "POST",
headers: H,
body: JSON.stringify({ url: "https://thunderbit.com/playground" }),
});
const { data } = await r.json();
console.log(data.markdown);Strukturierte Daten extrahieren
type Product = { name: string; price: number; currency?: string };
const r = await fetch(`${API}/extract`, {
method: "POST",
headers: H,
body: JSON.stringify({
url: "https://example.com/product/iphone-15-pro",
schema: {
type: "object",
properties: {
name: { type: "string" },
price: { type: "number" },
},
required: ["name", "price"],
},
}),
});
const { data } = await r.json() as { data: Product };Batch + Webhook (TypeScript)
const job = await fetch(`${API}/batch/distill`, {
method: "POST",
headers: H,
body: JSON.stringify({
urls: ["https://example.com/page1", "https://example.com/page2"],
webhook: {
url: "https://your-server.com/webhook",
secret: process.env.WEBHOOK_SECRET,
},
}),
}).then(r => r.json());Verifiziere die Webhook-Signatur in deinem Handler — siehe Webhooks.
Ein offizielles Node.js SDK ist in Entwicklung — schau bald wieder rein.