Node.js / TypeScript SDK for content moderation
Official Node.js SDK for VideoCensor API. Analyze and censor text, audio, and video. Full TypeScript typing for models and endpoints, auto-retry, stream support. Works in Node.js, Deno, Bun, and Cloudflare Workers.
100% TypeScript
Every model, every endpoint — strict typing. JobStatus, JobResult, AnalyzeTextResult, BatchResponse interfaces exported. Zero any.
ESM + CJS
Dual-format build: ESM (import) and CJS (require). Works in any bundler — Next.js, Vite, tsc, esbuild.
Auto-retry with backoff
Retries on 429/5xx with exponential backoff, configurable max_retries. Retry-After header respected automatically.
Stream support
analyzeMedia accepts fs.ReadStream, Buffer, or path. No need to load the file into memory — streamed directly to multipart.
waitForJob helper
client.waitForJob(jobId, timeoutMs) — polls until completion. Supports AbortSignal and onProgress callback.
Typed errors
VideoCensorError, RateLimitError, AuthenticationError — catch via instanceof. Include retryAfter, statusCode, requestId.
Quick start
import { VideoCensor } from "@videocensor/sdk";
const client = new VideoCensor({ apiKey: process.env.VIDEOCENSOR_API_KEY! });
const result = await client.analyzeText("text to check");
// result: { flaggedCount, categories, words }import { VideoCensor } from "@videocensor/sdk";
const client = new VideoCensor({ apiKey: process.env.VIDEOCENSOR_API_KEY! });
const job = await client.analyzeMedia("/path/to/video.mp4");
const done = await client.waitForJob(job.id);
const result = await client.getJobResult(done.id);
// result: { censoredCount, words, downloadUrl }const job = await client.censorMediaUrl(
"https://youtube.com/watch?v=...",
{ wayOfBlocking: "beep" }
);
const done = await client.waitForJob(job.id);
await client.downloadJob(done.id, "./clean.mp4");import { VideoCensor, RateLimitError, AuthenticationError } from "@videocensor/sdk";
try {
await client.analyzeText("test");
} catch (err) {
if (err instanceof RateLimitError) {
// log retry after err.retryAfter seconds
} else if (err instanceof AuthenticationError) {
// log invalid api key
}
}What the SDK can do
Next.js API routes
POST /api/moderate → client.analyzeText → return Response. Edge or Node runtime — works everywhere.
NestJS backend
Inject VideoCensor via DI provider, use in services. Full typing fits nestjs best practices.
Express / Fastify
Middleware for moderating req.body.text before handler. Webhook delivery on job completion.
AWS Lambda
~50 KB SDK, fast cold start. Use webhook for long files instead of wait.
Cloudflare Workers
Runs in V8 Isolates, uses native fetch. Perfect for edge moderation.
Discord / Telegram bots
Instant moderation of messages with photo/video attachments — download, run through censor_media_url.
Node.js SDK — FAQ
Which Node.js version is required?+
Node 18+. Uses built-in fetch, FormData, AbortController. Also works in Deno, Bun, Cloudflare Workers.
Are types included?+
SDK is written in TypeScript. Full .d.ts in the package, typing for every endpoint, interface, and error.
Does it work in Cloudflare Workers / Deno?+
Yes. No Node-specific APIs outside the file upload helper, which can be passed as ReadableStream.
Is CommonJS supported?+
Yes. Dual-format ESM + CJS build. require('@videocensor/sdk') works.
How do I update?+
npm install @videocensor/sdk@latest. Follow SemVer: breaking changes in major versions, 3-month deprecation notice.
Where's the source code?+
Open source on GitHub — github.com/dzhumaevn/videocensor/tree/main/sdk/nodejs. MIT license.
Install the SDK in seconds
npm install @videocensor/sdk — typed client for all popular Node frameworks.