SDKs

Node.js / TypeScript

Thunderbit Open API를 위한 Node.js의 관용적인 패턴

Thunderbit API 는 내장 fetch(Node 18+) 와 함께 동작합니다 —— SDK 가 필요 없습니다. 대규모에서 HTTP/2 와 connection pooling 이 필요하다면 undici 또는 axios 로 전환하세요.

설정

const API = "https://openapi.thunderbit.com/openapi/v1";
const H = {
  "Authorization": `Bearer ${process.env.THUNDERBIT_API_KEY}`,
  "Content-Type": "application/json",
};

페이지 Distill

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);

구조화된 데이터 Extract

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());

핸들러에서 Webhook 시그니처를 검증하세요 —— Webhooks 를 참고하세요.

공식 Node.js SDK 가 개발 중입니다 —— 곧 다시 확인해 주세요.