Official Node.js SDK for RemoveBGVideo Public API (/v1)
📘 Full Documentation · 🧪 API Playground · 🔐 API Management · 🐙 GitHub
removebgvideo-node wraps the /v1 REST API and gives you:
- Consistent authentication (
X-Api-Key) and request timeout handling - Typed method signatures for jobs, uploads, usage, and admin operations
- Built-in polling helper (
waitForCompletion) for async video workflows - Structured API errors (
ApiError) withstatusCode,code, andrequestId
npm install removebgvideo-node- Node.js 18+
- RemoveBGVideo API key for public endpoints
- Optional admin token for admin endpoints
import { RemoveBGVideoClient } from 'removebgvideo-node';
const client = new RemoveBGVideoClient({
apiKey: process.env.REMOVEBGVIDEO_API_KEY,
});
const created = await client.createJob({
video_url: 'https://cdn.example.com/input.mp4',
model: 'original',
bg_type: 'transparent',
output_format: 'webm',
webhook_url: 'https://your-app.com/webhooks/removebgvideo',
auto_start: true,
});
const result = await client.waitForCompletion(created.id, {
intervalMs: 2000,
timeoutMs: 10 * 60 * 1000,
});
console.log(result.output_url);import { RemoveBGVideoClient } from 'removebgvideo-node';
const client = new RemoveBGVideoClient({
apiKey: process.env.REMOVEBGVIDEO_API_KEY,
baseUrl: 'https://api.removebgvideo.com',
timeoutMs: 30000,
});import { RemoveBGVideoAdminClient } from 'removebgvideo-node';
const admin = new RemoveBGVideoAdminClient({
adminToken: process.env.REMOVEBGVIDEO_ADMIN_TOKEN,
baseUrl: 'https://api.removebgvideo.com',
timeoutMs: 30000,
});const created = await client.createJob({
video_url: 'https://cdn.example.com/input.mp4',
model: 'human',
bg_type: 'transparent',
output_format: 'webm',
auto_start: true,
});
const done = await client.waitForCompletion(created.id);
console.log(done.status, done.output_url);import fs from 'node:fs/promises';
const file = await fs.readFile('./input.mp4');
const blob = new Blob([file], { type: 'video/mp4' });
const uploaded = await client.upload(blob, 'input.mp4');
const created = await client.createJob({
video_url: uploaded.video_url,
model: 'light',
output_format: 'webm',
auto_start: true,
});
const done = await client.waitForCompletion(created.id);
console.log(done.output_url);const created = await client.createJob({
video_url: 'https://cdn.example.com/input.mp4',
model: 'pro',
text_prompt: 'person wearing red jacket',
auto_start: false,
});
await client.startJob(created.id, {
webhook_url: 'https://your-app.com/webhooks/removebgvideo',
});
const done = await client.waitForCompletion(created.id);| Model | Speed | Quality | Best For | text_prompt |
|---|---|---|---|---|
original |
Standard | Highest | General quality-first segmentation | No |
light |
Fastest cost/perf | High | Simple scenes, throughput-first workloads | No |
pro |
Slowest | Highest | Complex objects with prompt-based targeting | Yes |
human |
Fast | High | Portraits / human subjects | No |
createJob(options) accepts:
video_url(string, required)model(original|light|pro|human, defaultoriginal)bg_type(string, defaultgreen)output_format(string, defaultwebm)text_prompt(string, optional, meaningful forpro)webhook_url(string, optional, receive async callbacks)bg_color(number[], optional)auto_start(boolean, defaulttrue)metadata(object, optional)
new RemoveBGVideoClient({
apiKey: string,
baseUrl?: string,
timeoutMs?: number,
})upload(fileOrBlob, filename?)->POST /v1/uploadscreateJob(options)->POST /v1/jobsstartJob(jobId, overrides?)->POST /v1/jobs/{id}/startgetJob(jobId)->GET /v1/jobs/{id}listJobs({ limit, offset, status })->GET /v1/jobsusageSummary({ days })->GET /v1/usage/summaryusageEvents({ limit })->GET /v1/usage/eventswaitForCompletion(jobId, { intervalMs, timeoutMs })-> polling helper
To receive server-to-server callbacks, pass webhook_url in createJob or startJob.
Events:
job.startedjob.completedjob.failed
Headers:
X-Webhook-EventX-Webhook-Delivery-IdX-Webhook-TimestampX-Webhook-Signature(when signing secret is configured server-side)
Node signature verification example:
import crypto from 'node:crypto';
function verifyWebhook(rawBody, timestamp, signature, secret) {
const digest = crypto
.createHmac('sha256', secret)
.update(`${timestamp}.${rawBody}`)
.digest('hex');
const expected = `sha256=${digest}`;
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature || ''));
}- Returns job payload when
status === completed - Throws
ApiErrorwhenstatus === failed - Throws timeout error when elapsed time exceeds
timeoutMs
new RemoveBGVideoAdminClient({
adminToken: string,
baseUrl?: string,
timeoutMs?: number,
})getConfig()->GET /v1/admin/configlistKeys()->GET /v1/admin/keyscreateKey({ client_id, note })->POST /v1/admin/keysdisableKey({ key_fingerprint })->POST /v1/admin/keys/disableenableKey({ key_fingerprint })->POST /v1/admin/keys/enable
All non-2xx API responses throw ApiError:
import { ApiError } from 'removebgvideo-node';
try {
await client.getJob('invalid-id');
} catch (err) {
if (err instanceof ApiError) {
console.error('status:', err.statusCode);
console.error('code:', err.code);
console.error('requestId:', err.requestId);
console.error('message:', err.message);
} else {
console.error(err);
}
}Retry only transient failures:
- Retry: HTTP
429,500,502,503,504 - Do not retry without mutation: validation/auth errors (
400,401,403,404)
async function withRetry(fn, max = 3) {
let attempt = 0;
while (true) {
try {
return await fn();
} catch (err) {
attempt += 1;
const retryable = err?.statusCode && [429, 500, 502, 503, 504].includes(err.statusCode);
if (!retryable || attempt > max) throw err;
await new Promise((r) => setTimeout(r, attempt * 500));
}
}
}const summary = await client.usageSummary({ days: 7 });
const events = await client.usageEvents({ limit: 50 });
console.log(summary);
console.log(events);Typical pattern:
- Call
usageSummaryfor dashboard metrics. - Call
usageEventsfor detailed event feed and reconciliation.
This package ships src/index.d.ts. If you use TS, you get typed constructors and method signatures out of the box.
examples/basic.js: basic create + waitexamples/upload-then-process.js: upload local file then processexamples/admin.js: admin key operations
REMOVEBGVIDEO_API_KEYREMOVEBGVIDEO_ADMIN_TOKEN(admin only)
- Changelog: CHANGELOG.md
- Release process: RELEASING.md
Please read CONTRIBUTING.md.
MIT
