@thefatbaby/sdk
v0.1.0
Published
Official JavaScript/TypeScript SDK for TheFatBaby APIs — PDF, image, video, web, OCR and developer utilities.
Maintainers
Readme
@thefatbaby/sdk
Official JavaScript/TypeScript SDK for TheFatBaby APIs.
Install
npm install @thefatbaby/sdkNode.js 18+ (native fetch, FormData, Blob).
Quick start
import { writeFile } from 'node:fs/promises';
import { FatBaby } from '@thefatbaby/sdk';
const fb = new FatBaby({ apiKey: process.env.FATBABY_API_KEY! });
// Sync binary — screenshot
const shot = await fb.web.screenshot({ url: 'https://example.com', full_page: true });
await writeFile(shot.filename || 'shot.png', Buffer.from(shot.data));
// Async job — PDF compress, wait, download
const job = await fb.pdf.compress({ file: './doc.pdf' });
await job.wait();
await job.downloadTo('./doc-compressed.pdf');Auth & base URL
- API keys:
fb_live_…orfb_test_… - Default base:
https://thefatbaby.com/api - Header:
Authorization: Bearer <key>
new FatBaby({
apiKey: 'fb_test_…',
baseUrl: 'http://127.0.0.1:4000', // local API
timeout: 60_000,
maxRetries: 2 // GET-only for 429/502/503/504 — POSTs are never auto-retried
});Resources
| Resource | Examples |
|----------|----------|
| fb.web | screenshot, toPdf, scrape, linkPreview, status, dns, ssl |
| fb.image | resize, compress, convert, backgroundRemove, upscale, … |
| fb.pdf | metadata, merge, compress, ocr, fromUrl, … (async → Job) |
| fb.video / fb.audio | convert, compress, trim, thumbnail, … (async → Job) |
| fb.ocr | extract |
| fb.sheets | xlsxToCsv, xlsxToJson, csvToXlsx, … |
| fb.tools | qr, barcode, hash, jsonFormat, base64 |
| fb.email | validate, batchValidate, disposableCheck |
| fb.jobs | get, list, cancel, download |
Escape hatch for any path:
await fb.requestJson({ method: 'POST', path: '/v1/web/scrape', json: { url: '…' } });Jobs
PDF and media create endpoints return a Job:
const job = await fb.video.convert({ file: './clip.mp4', format: 'mp4' });
const done = await job.wait({ timeout: 300_000, pollInterval: 2_000 });
const { data, filename } = await job.download();Paid POSTs are not auto-retried (the API has no idempotency keys).
Errors
Typed errors: AuthenticationError, ValidationError, RateLimitError, InsufficientCreditsError, NotFoundError, ServerError, TimeoutError.
Credit headers are exposed on every result as meta.creditsUsed / meta.creditsRemaining.
License
MIT
