The official Node.js and TypeScript SDK for the CaptureKit screenshot API.
Capture websites as PNG, JPEG, WebP or PDF, extract their content, or analyse them with AI.
The SDK exposes 7 typed methods, one per documented endpoint, plus a generic request() for anything else.
- Node.js 20 or newer
npm install @capturekitdev/sdkThe SDK works with TypeScript and JavaScript (ES modules). The examples below use TypeScript; JavaScript users can use the same API by omitting TypeScript-only syntax.
Sign up for CaptureKit or sign in to your existing account, then copy your API key from the dashboard. Store it securely, for example in the CAPTUREKIT_API_KEY environment variable, which the client reads by default.
import { CaptureKitClient } from "@capturekitdev/sdk";
const client = new CaptureKitClient({ apiKey: process.env.CAPTUREKIT_API_KEY });
const response = await client.content({ url: "https://example.com" });
console.log(response.data);Every method takes a parameter object that mirrors the API reference (snake_case names, exactly as documented) and an optional RequestOptions object.
Some endpoints return a file (image, PDF…) instead of JSON. Their methods return an ApiResponse, so check kind:
import { writeFile } from "node:fs/promises";
const response = await client.capture({
url: "https://example.com",
format: "png",
});
if (response.kind === "binary") {
await writeFile("screenshot.png", response.bytes);
} else {
console.log(response.data);
}Any call accepts is_async: true (useful past the 60-second server limit): the response is then a job_id. waitForJob() polls GET /v1/jobs/{id} until the job reaches a terminal status (CompletedJob, Error, NotFound, BadRequest):
const submitted = await client.content({
url: "https://example.com",
is_async: true,
});
const job = await client.waitForJob(submitted.data.job_id, {
onProgress: (j) => console.log(`${j.status} ${j.progress ?? 0}%`),
});
console.log(JSON.stringify(job.data, null, 2));Methods use GET when the endpoint supports it: parameters travel in the query string. POST sends the same parameters as a JSON body.
await client.analyze({ url: "test" }, { method: "POST" });null, undefined and empty arrays are omitted, false and 0 are sent, and arrays repeat the parameter name (a=1&a=2).
request() reaches any path, including endpoints released after this SDK version:
const response = await client.request("GET", "/v1/usage");JsonResponse—kind: "json", the parsed body indata(pass a type argument to type it:client.content<MyType>(…)).BinaryResponse—kind: "binary", the body inbytesand itscontentType.
Both keep the buffered rawResponse (status, headers, content type, body bytes).
import { CaptureKitApiError } from "@capturekitdev/sdk";
try {
await client.content({ url: "https://example.com" });
} catch (error) {
if (error instanceof CaptureKitApiError) {
console.error(error.status, error.message, error.responseBody);
}
throw error;
}| Error | When |
|---|---|
CaptureKitConfigurationError |
Missing API key, invalid options or unsupported method. |
CaptureKitSerializationError |
A required parameter is missing or a value can't be sent. |
CaptureKitTransportError |
Network failure or client-side timeout. |
CaptureKitApiError |
The API answered with a non-2xx status (status, message, responseBody). |
CaptureKitResponseDecodingError |
A success response could not be decoded. |
All of them extend CaptureKitError. Common statuses: 400 invalid parameters, 401 invalid API key, 402 no credits left, 429 rate limit exceeded.
Requests are retried up to 3 times after a network error, a 408, 500, 502, 503 or 504, or a rate limit — which the API returns as 401 (or 429) with a Rate limit exceeded message. Per-key quota errors (…: quota daily) are not retried, nor are 400, 402, 404 or client-side timeouts. The delay starts at 1 second and grows 1.5× per retry (capped at 30 seconds); a Retry-After header wins.
const client = new CaptureKitClient({ maxRetries: 5, retryDelay: 500 });
// or for one request
await client.content({ url: "https://example.com" }, { maxRetries: 0 });batch() runs a task per item with at most 10 in flight (concurrency), and returns one result per item in input order, shaped like Promise.allSettled. One failure never stops the others.
const inputs = [
"https://example.com",
"https://www.capturekit.dev",
"https://github.com",
];
const results = await client.batch(inputs, (url) => client.content({ url }), {
concurrency: 5,
});
for (const result of results) {
if (result.status === "fulfilled") console.log(result.value.data);
else console.error(inputs[result.index], result.reason);
}| Constant | Default | Description |
|---|---|---|
DEFAULT_CONCURRENCY |
10 |
Tasks run at the same time by batch |
DEFAULT_TIMEOUT_MS |
120000 |
Request timeout (milliseconds) |
MAX_RETRIES |
3 |
Retry attempts after a network error, a 408/5xx or a rate limit |
RETRY_BACKOFF_FACTOR |
1.5 |
Exponential backoff multiplier |
DEFAULT_RETRY_DELAY_MS |
1000 |
Delay before the first retry (milliseconds) |
const client = new CaptureKitClient({ timeout: 60_000 }); // default 120000 ms, 0 disables
await client.content(
{ url: "https://example.com" },
{
signal: AbortSignal.timeout(30_000),
},
);import { CaptureKitClient, type CaptureKitFetch } from "@capturekitdev/sdk";
const loggingFetch: CaptureKitFetch = async (input, init) => {
const response = await fetch(input, init);
console.log(init.method, String(input), response.status);
return response;
};
const client = new CaptureKitClient({ fetch: loggingFetch });7 methods, generated from the OpenAPI document.
| Method | HTTP | Description |
|---|---|---|
analyze() |
GET / POST /v1/analyze |
AI Content API analyzes any webpage and returns AI insights summary, value proposition, features, categories, use cases, and optional conta… |
capture() |
GET / POST /v1/capture |
Browser-like Screenshot API that captures webpages as PNG/JPEG/WebP or PDF for previews, QA, reporting, monitoring, and archiving no headle… |
content() |
GET / POST /v1/content |
CaptureKit Content API extracts structured webpage data, metadata, links, HTML/Markdown: in one request for SEO, monitoring, indexing and a… |
jobs() |
GET /v1/jobs/{id} |
Poll the status, progress (0–100) and result of a job started with is_async=true. Polling is free. Poll until status is terminal: Completed… |
stats() |
GET /v1/stats |
Infrastructure health for an engine or endpoint over the last hour. Not scoped to your account or tenant. Enabled per account: HTTP 403 mea… |
usage() |
GET /v1/usage |
Retrieve real-time usage statistics and credit balance for your CaptureKit account. |
websiteCrawler() |
GET / POST /v1/website/crawler |
Website Crawler API fetches raw HTML from any webpage in request mode (no rendering) for fast scraping, audits, monitoring, and link/metada… |
| SDK | Package | Install |
|---|---|---|
| Node.js | @capturekitdev/sdk |
npm install @capturekitdev/sdk |
| Python | capturekitdev |
pip install capturekitdev |
| Go | capturekit-go |
go get github.com/capturekitdev/capturekit-go |
| .NET | CaptureKit |
dotnet add package CaptureKit |
| Ruby | capturekitdev |
gem install capturekitdev |
| PHP | capturekitdev/sdk |
composer require capturekitdev/sdk |
| Java | capturekit-java |
build from source, see its README |
| CLI | @capturekitdev/cli |
npm install -g @capturekitdev/cli |
| MCP server | @capturekitdev/mcp |
npx -y @capturekitdev/mcp |
MIT — see LICENSE.