Skip to content
SDKsNode.js SDK

Node.js SDK

The renderkit-sdk package wraps the REST API with typed methods, automatic retries with backoff, and first-class TypeScript types. Works in Node 18+ and any modern runtime with fetch.

Install

npm i renderkit-sdk

Initialize

renderkit
import { RenderKit } from "renderkit-sdk";

// Reads RENDERKIT_API_KEY from the environment if no key is passed.
const rk = new RenderKit(process.env.RK_KEY);

Methods

MethodEndpoint
rk.screenshot(opts)POST /v1/screenshot
rk.pdf(opts)POST /v1/pdf
rk.extract(opts)POST /v1/extract
rk.jobs.get(id)GET /v1/jobs/:id

Example

render.ts
import { RenderKit } from "renderkit-sdk";

const rk = new RenderKit(process.env.RK_KEY);

const shot = await rk.screenshot({
  url: "https://stripe.com",
  full_page: true,
  block_ads: true,
  device_scale: 2,
});

console.log(shot.url);          // hosted PNG
console.log(shot.credits_used); // 1

Async + polling

async.ts
const job = await rk.pdf({ url: "https://slow.example", async: true });

let result = await rk.jobs.get(job.id);
while (result.status === "queued" || result.status === "processing") {
  await new Promise((r) => setTimeout(r, 1000));
  result = await rk.jobs.get(job.id);
}
console.log(result.url);

Errors throw

Non-2xx responses throw a RenderKitError carrying code, status, and request_id. Catch it and branch on err.code — the same codes documented under Errors.