Skip to content

TypeScript SDK

On this TypeScript SDK page

Official typed client: generate, poll, publish, verify webhooks.

Install

npm install @reeloop/sdk
  • npm: npm install @reeloop/sdk
  • Published version: 0.1.0 on npm. Pin it with npm install @reeloop/sdk@0.1.0. Do not assume a newer version is already published.
  • Requires: Node.js >= 18 (uses the global fetch)

API key

The published 0.1.0 package is the TypeScript client. It does not include a shortloom or reeloop command. Pass the key yourself:

export SHORTLOOM_API_KEY=fl_…

Quickstart

import { ReeloopClient } from "@reeloop/sdk";

const reeloop = new ReeloopClient(process.env.SHORTLOOM_API_KEY!);

const { jobId } = await reeloop.generate({
  topic: "5 facts about the ocean nobody knows",
  style: "documentary",
  voice: "charlotte",
  duration: "30",
  mode: "instant", // charge + render now; "director" (the default) is a free draft
});

const done = await reeloop.waitForCompletion(jobId);
console.log(done.finalVideoUrl);

What the SDK handles for you

  • Idempotency - every generate() sends a fresh Idempotency-Key, so a network retry replays the original response instead of double-charging. Pass your own key to dedupe across calls.
  • Correct completion detection - waitForCompletion() checks renderStatus/finalVideoUrl (a job can read status: "completed" with a FAILED, refunded render) and rejects on failure.
  • Typed errors - ReeloopApiError exposes status, the API's code, rate-limit headers, and a retryable flag.
  • Webhook verification - verifyWebhookSignature(rawBody, signatureHeader, secret) validates X-ShortLoom-Signature (HMAC-SHA256, constant-time) and returns the parsed payload.
import { verifyWebhookSignature } from "@reeloop/sdk";

const payload = verifyWebhookSignature(rawBody, headers["x-shortloom-signature"], secret);
if (!payload) return new Response("bad signature", { status: 401 });

Sandbox

Use an fl_test_ key (see the Sandbox doc) to develop without spending credits - the SDK works identically against test keys.

Python

A Python client (reeloop-sdk) mirrors this SDK's method surface field-for-field. Not yet published to PyPI.

from reeloop_sdk import ReeloopClient

reeloop = ReeloopClient(api_key)
job = reeloop.generate(topic="5 facts about the ocean nobody knows", mode="instant")
done = reeloop.wait_for_completion(job["jobId"])