TypeScript SDK

The fastest way to call Snapshot Site from Node.js and TypeScript

Use the official TypeScript SDK when you want typed payloads, a single client for screenshot, analyze, and compare, and a faster path to production than hand-written fetch wrappers.

@snapshot-site/sdk
Official package
Typed client
Screenshot, analyze, compare
Node.js
Services, scripts, full-stack apps
Install:pnpm add @snapshot-site/sdk
Auth:SNAPSHOT_SITE_API_KEY=ss_live_xxx
Get started for free
TypeScript workflow
Node.js and TypeScript screenshot API SDK connecting typed requests to capture, analysis, and comparison outputs
Good fits
Node.js services that need typed request and response payloads
Cron jobs and worker pipelines that capture or analyze pages
Full-stack apps that want one client for screenshot, compare, and analyze
Teams that want to avoid hand-writing raw HTTP wrappers

SDK overview

The TypeScript SDK wraps the Snapshot Site API in a single client. It is the lowest-friction option when your application already lives in JavaScript or TypeScript.

1

One client for all Snapshot Site endpoints

Use a single `SnapshotSiteClient` instance to run screenshot, analyze, and compare workflows.

2

Typed payloads

The SDK is designed to reduce mistakes in request shapes and keep integrations readable.

3

Good fit for backend automation

Use it in Node.js services, background jobs, scripts, and full-stack application backends.

4

Closer to production than raw fetch

You can move from API key to working integration without rebuilding auth, paths, and request plumbing yourself.

Quick start

Install, configure, call the client

1

Install `@snapshot-site/sdk` in your app

2

Set `SNAPSHOT_SITE_API_KEY` in your environment

3

Instantiate `SnapshotSiteClient`

4

Call `screenshot`, `analyze`, or `compare` with typed payloads

Code examples

Screenshot

Minimal screenshot example

Capture a page in a few lines with a single client instance.

import { SnapshotSiteClient } from "@snapshot-site/sdk";

const client = new SnapshotSiteClient({
  apiKey: process.env.SNAPSHOT_SITE_API_KEY!,
});

const result = await client.screenshot({
  url: "https://snapshot-site.com/pricing",
  format: "png",
  width: 1440,
  fullSize: true,
  hideCookie: true,
});

console.log(result.link);
Analyze

Analyze example

Run page analysis and extract summary-oriented output.

const analysis = await client.analyze({
  url: "https://snapshot-site.com",
  width: 1440,
  fullSize: true,
  enableSummary: true,
  enableQuality: true,
});

console.log(analysis.summary);
Compare

Compare example

Compare two page states and inspect diff-oriented results.

const diff = await client.compare({
  before: {
    url: "https://snapshot-site.com/pricing",
    width: 1440,
    fullSize: true,
    hideCookie: true,
  },
  after: {
    url: "https://staging.snapshot-site.com/pricing",
    width: 1440,
    fullSize: true,
    hideCookie: true,
  },
  threshold: 0.1,
});

console.log(diff.diff?.link);
console.log(diff.summary?.mismatchPercentage);

A screenshot API client for Node.js applications

The official @snapshot-site/sdk package wraps Snapshot Site's screenshot, analysis, and comparison workflows in one SnapshotSiteClient. It is intended for Node.js code that can protect an API key: application servers, server routes, workers, scheduled scripts, and CI jobs.

The SDK requires Node.js 20.9 or later and ships as CommonJS with bundled type declarations. TypeScript users get typed request and response surfaces, while JavaScript applications can call the same runtime client without adopting TypeScript.

Use raw HTTP when a platform cannot run the package or when avoiding dependencies is a firm requirement. Use the SDK when a shared client, types, and consistent method names reduce repeated request plumbing across a Node.js codebase.

Configure the client securely

Create the client once with a server-side API key and reuse it in the scope appropriate for the application. Read the value from process.env.SNAPSHOT_SITE_API_KEY or a secret manager. Do not add it to a public environment variable, browser bundle, error response, or repository file.

import { SnapshotSiteClient } from "@snapshot-site/sdk";

export const snapshotSite = new SnapshotSiteClient({
  apiKey: process.env.SNAPSHOT_SITE_API_KEY!,
});

Validate that the environment variable exists during application startup. A non-null assertion satisfies TypeScript but does not create the value at runtime. Failing early produces a clearer deployment error than waiting for the first screenshot request.

Keep the SDK on the server

In a full-stack framework, place the configured client in server-only code. A Next.js route handler, server action, queue worker, or backend service can call it and return only the result the user is authorized to see. Browser-side code should call your server, not Snapshot Site with a private key.

Choose the method by workflow

screenshot() for rendered assets

Use client.screenshot() when the application needs a website image or document. Keep width explicit, set fullSize when the entire scrollable page matters, and choose the output format according to the consumer. The full-page screenshot guide covers long-page timing and cleanup decisions.

analyze() for structured page insights

Use client.analyze() when a rendered page should also produce summary or quality information. Request only the analysis options the workflow uses, and preserve the source screenshot when a reviewer may need to inspect the evidence.

compare() for visual differences

Use client.compare() with two controlled sources to receive before, after, and diff information. Keep capture settings identical across both states. The Visual Diff API page explains baselines, mismatch thresholds, and false-positive control.

Organize a production integration

Keep capture configuration close to the use case instead of scattering raw objects across the application. A documentation job, social-preview generator, and release comparison require different widths, formats, and timing. Named configuration builders make those decisions reviewable.

const documentationCapture = (url: string) => ({
  url,
  format: "webp" as const,
  width: 1440,
  fullSize: true,
  hideCookie: true,
  delay: 2,
});

const result = await snapshotSite.screenshot(
  documentationCapture("https://example.com/docs/start"),
);

Validate user-supplied URLs before building a request. If the product is intended to capture only approved sites, enforce an allowlist in your application. Avoid logging URLs containing credentials, private identifiers, or sensitive query parameters.

Error handling and retries

Treat every remote call as a fallible application operation. Wrap jobs with context that identifies the sanitized URL and workflow, and decide which failures should be retried. Invalid input and authorization failures need correction; repeated retries do not fix them.

For a batch, record success or failure per URL. Use a queue or small worker pool rather than launching an unbounded Promise.all. Bounded concurrency protects application memory, respects service limits, and lets the job resume without repeating completed work.

for (const url of urls) {
  try {
    const result = await snapshotSite.screenshot({ url, format: "webp" });
    await saveResult(url, result);
  } catch (error) {
    await recordFailure(url, error);
  }
}

Sequential code is intentionally simple; introduce concurrency only after measuring the real workload and defining retry behavior.

Performance practices

Cache outputs that remain valid instead of capturing the same stable page on every application request. Use viewport screenshots when only the fold is needed and full-page mode when content completeness matters. Choose a deliberate delay based on page behavior rather than adding a large wait to every request.

For scheduled jobs, prevent overlapping runs over the same URL set. Store enough configuration with the result to reproduce it later. If an image will be compared, keep width, timing, cookie handling, and other visual settings stable.

Common Node.js integration mistakes

  • Importing a configured SDK client into browser-bundled code.
  • Assuming a TypeScript non-null assertion validates an environment variable.
  • Launching thousands of requests in one unbounded Promise.all.
  • Retrying invalid requests indefinitely.
  • Logging the API key or sensitive target URLs.
  • Recreating the same stable capture instead of caching it.
  • Comparing images produced with different settings.

Use the API documentation as the endpoint source of truth and the package README for runtime compatibility. Start with one typed server-side call, then extract shared configuration as the integration grows.

Node.js screenshot API SDK FAQ

Is the Snapshot Site SDK intended for Node.js or browser code?

Use it in Node.js services, server routes, background workers, scripts, and trusted full-stack backends. Keeping the SDK server-side prevents the API key from being exposed to visitors.

Which Node.js version does the SDK require?

The current SDK package requires Node.js 20.9 or later. Check the package README and release metadata when upgrading an existing application.

Does the SDK include TypeScript declarations?

Yes. The package ships bundled type declarations for its client, request payloads, and response types.

Which methods are available?

The verified client surface includes screenshot, analyze, and compare methods on SnapshotSiteClient. Each method maps to the corresponding Snapshot Site workflow.

Can I use the SDK from a Next.js application?

Yes, from server routes, server actions, jobs, or other server-only code. Do not import a configured client into code that is bundled for the browser.

How should I store the API key?

Read it from a server-side environment variable or secret manager and pass it to SnapshotSiteClient. Never hardcode it in source control or return it to the client.

Should I use the SDK or raw fetch?

Use the SDK when typed payloads and a shared client improve maintainability. Raw fetch remains useful when dependencies must stay minimal or the runtime is not supported by the package.

Can I run screenshot jobs in parallel?

Yes, but use bounded concurrency that matches your plan and application capacity. Handle each result independently and avoid launching an unbounded Promise.all over a large URL list.

Add the SDK to one server-side workflow

Start with a typed screenshot request, verify its output, and reuse the same client when analysis or visual comparison becomes part of the application.