Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can take a website screenshot from Deno with its built-in fetch API; you do not need a browser automation package for the HTTP request. Send the target URL and capture options to Screenshot API’s REST endpoint, check the HTTP response, and read the result in the format the endpoint returned. Its normal documented response is JSON containing a CDN URL; a redirect option can instead send you to the image or PDF.

Make your first screenshot request from Deno

Screenshot API’s documented endpoint is https://api.screenshot-api.org/api/v1/screenshot. Its quick start uses a POST request with a JSON body and bearer-token authentication. The following script follows that shape and reads the normal response as JSON. It prints the response rather than assuming an undocumented property name for the returned CDN URL.

const apiKey = Deno.env.get("SCREENSHOT_API_KEY");
if (!apiKey) throw new Error("SCREENSHOT_API_KEY is required");

const response = await fetch("https://api.screenshot-api.org/api/v1/screenshot", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://example.com",
    format: "png",
    fullPage: false,
  }),
});

if (!response.ok) {
  const detail = await response.text();
  throw new Error(`Screenshot request failed: ${response.status} ${detail}`);
}

const result = await response.json();
console.log(result);

Save it as screenshot.ts. Set the key in the environment and run it with network access for the API host and permission to read that environment variable:

SCREENSHOT_API_KEY="YOUR_API_KEY" deno run --allow-env=SCREENSHOT_API_KEY --allow-net=api.screenshot-api.org screenshot.ts

Replace https://example.com with a public page you are authorized to capture. The format and fullPage fields above match the official quick-start request. A successful HTTP status means the API request succeeded; inspect the returned JSON to find the result URL or other response details rather than treating the response body as image bytes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose GET or POST

Screenshot API documents both GET and POST for /api/v1/screenshot. GET accepts query parameters and returns JSON by default. POST carries options in a JSON body and is documented as useful for complex configurations. Either way, the HTTP response still needs to be checked before you parse its body.

POST with JSON for configured captures

The first example is the most direct starting point when your code already has a capture configuration object. Add only parameters supported by the service’s live API documentation; the retrieved documentation establishes url, format and fullPage for the shown request, but not a complete parameter reference.

GET with query parameters

Use URL and URLSearchParams to encode query values safely, especially the target URL. The key can be supplied as the documented key query parameter, though a header is preferable because query strings are more likely to be recorded in logs. This GET example keeps the recommended bearer header:

const apiKey = Deno.env.get("SCREENSHOT_API_KEY");
if (!apiKey) throw new Error("SCREENSHOT_API_KEY is required");

const endpoint = new URL("https://api.screenshot-api.org/api/v1/screenshot");
endpoint.search = new URLSearchParams({
  url: "https://example.com",
  format: "png",
  fullPage: "false",
}).toString();

const response = await fetch(endpoint, {
  headers: { Authorization: `Bearer ${apiKey}` },
});

if (!response.ok) {
  throw new Error(`Screenshot request failed: ${response.status} ${await response.text()}`);
}

console.log(await response.json());

GET is convenient for a small request, but query parameters can become awkward as the configuration grows. POST keeps the configuration in the request body and avoids placing capture settings in the URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Request a redirect when you need the asset response

The API documentation describes redirect=1 as a way to receive a 302 redirect to the image or PDF instead of the normal JSON result. Deno’s fetch follows redirects by default, so a request using the option may resolve to the asset response. If you need to inspect the redirect itself, set redirect: "manual" and inspect the status and Location header:

const endpoint = new URL("https://api.screenshot-api.org/api/v1/screenshot");
endpoint.search = new URLSearchParams({
  url: "https://example.com",
  format: "png",
  redirect: "1",
}).toString();

const response = await fetch(endpoint, {
  headers: { Authorization: `Bearer ${apiKey}` },
  redirect: "manual",
});

if (response.status !== 302) {
  throw new Error(`Expected a redirect; received ${response.status}`);
}

const assetUrl = response.headers.get("Location");
if (!assetUrl) throw new Error("Redirect response did not include Location");
console.log(assetUrl);

Keep the key definition from the earlier example in scope when using this fragment. If you leave redirect handling to the default fetch behavior, the response you receive may be for the redirected asset rather than the initial 302; inspect the final status and content type before deciding how to read the body.

Authenticate without exposing your API key

The documented authentication options are Authorization: Bearer YOUR_API_KEY, X-API-Key: YOUR_API_KEY, and the key query parameter. The examples use the bearer header, which the service recommends. Keep the secret in an environment variable or a secret manager on the server that makes the request; do not embed it in browser-side JavaScript, commit it to source control, or print it in logs.

If your environment standardizes on the alternative header, change the request headers to:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
headers: { "X-API-Key": apiKey }

Do not send a key in both a header and the query string unless the API documentation specifically calls for it. Query-string credentials may be copied into access logs, proxy logs, monitoring traces or error reports.

Read the response according to what the endpoint returned

A Deno fetch call returns a Response, not automatically a decoded image. Check response.ok or response.status first, then choose the body reader that matches the response:

  • response.json() for the endpoint’s usual JSON result, which the quick start describes as containing a CDN URL.
  • response.text() for diagnostic text on an error response, or another documented text response.
  • response.arrayBuffer() or response.blob() if the response is the image or PDF itself, such as after following a redirect.

Response bodies are streams and should be consumed once. In particular, if you read the body with text() to include an error detail in an exception, do not then try to parse that same body with json(). For code that must support both JSON and asset responses, branch on the response’s Content-Type header and handle each format intentionally.

Use batch capture only when you need multiple URLs

The documented batch route is POST /api/v1/screenshot/batch, and its response includes a batch ID for tracking progress. That is a different workflow from a single screenshot request: your application must retain the identifier and use the service’s documented tracking mechanism. The available endpoint summary does not establish the exact batch request schema, progress URL, completion response, or polling interval, so do not infer those details from the single-capture example. Check the current API documentation before implementing batch submission or status tracking.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use cURL, Python or Node.js to check the same HTTP contract

Deno is not required on the server side of the API. The same endpoint and bearer-token pattern can help isolate whether a problem is specific to the Deno application or affects the request itself.

cURL

curl -X POST "https://api.screenshot-api.org/api/v1/screenshot" 
  -H "authorization: Bearer YOUR_API_KEY" 
  -H "content-type: application/json" 
  -d '{"url":"https://example.com","format":"png","fullPage":false}'

Python

import os
import requests

api_key = os.environ["SCREENSHOT_API_KEY"]
response = requests.post(
    "https://api.screenshot-api.org/api/v1/screenshot",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"url": "https://example.com", "format": "png", "fullPage": False},
    timeout=90,
)
response.raise_for_status()
print(response.json())

Node.js

const apiKey = process.env.SCREENSHOT_API_KEY;
if (!apiKey) throw new Error("SCREENSHOT_API_KEY is required");

const response = await fetch("https://api.screenshot-api.org/api/v1/screenshot", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ url: "https://example.com", format: "png", fullPage: false }),
});
if (!response.ok) {
  throw new Error(`Screenshot request failed: ${response.status} ${await response.text()}`);
}
console.log(await response.json());

Or skip the browser setup

If you want a screenshot service that does more than return a capture, ScreenshotNeo is a website screenshot API and MCP server for developers. This is a separate service from Screenshot API: it uses its own endpoint, key and response behavior. Its API can remove cookie and consent banners, newsletter popups and chat widgets before capture; those cleanup steps can each be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server exposes screenshot, page-info and PDF tools to AI agents using Claude, Cursor or another MCP client.

One cURL request looks like this; see the ScreenshotNeo API documentation for request options:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo’s Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common integration failures

Deno reports a missing environment variable

Confirm that SCREENSHOT_API_KEY is set in the process environment and that the run command includes --allow-env=SCREENSHOT_API_KEY. Deno does not receive a shell variable that was never exported or included for that command.

The request fails before reaching the API

Check the network permission. A command restricted to --allow-net=api.screenshot-api.org authorizes the host used by this request; a broader permission may be needed only if your own application also contacts other hosts. DNS, proxy and outbound firewall failures are separate from API-level errors.

The response is non-2xx or JSON parsing fails

Log the status code and read the body once as text before raising an error. A parsing error can mean the response was not JSON—for example, it may be a redirect or an asset—or that an error response is plain text. Verify the URL, authentication header, JSON content type and request fields, then consult the live service documentation for the response details. The documented pages do not establish a complete error-code table.

You expected image bytes but received JSON or a redirect

The normal GET result is JSON, not necessarily a byte stream. Use the documented redirect option if you need to reach the asset, and account for fetch’s default redirect-following behavior. Then inspect the response status and content type before selecting json(), arrayBuffer() or another reader.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A batch request cannot be tracked

Save the batch ID returned by the batch route. Consult the current API documentation for the tracking method and payload shape; neither can safely be derived from the single-screenshot endpoint.

Plan for timeouts, retries and operating cost

The documentation available for this integration does not establish a quota policy, service-specific retry rules, response-time guarantee or complete error map. Treat these as service-specific questions rather than assuming behavior from Deno or the generic HTTP contract. Check the account plan and current API documentation before designing a production workload.

For resilience, give each request a bounded timeout appropriate to your application, surface the HTTP status and a safe diagnostic body to logs, and avoid retrying blindly. A repeated POST could initiate another capture; retry only when the service’s documented behavior and your application’s idempotency requirements make that safe. If you add retries, use a bounded attempt count and backoff, and distinguish transient connection failures from a valid non-2xx response. Do not log authorization headers or full URLs if they may contain sensitive query values.

For high-volume work, the batch endpoint may fit better than serial single requests, but confirm its actual payload, tracking behavior and account limits first. For a single capture, keep the request small and consume the response according to its content type rather than downloading a redirected asset when all you need is the returned URL.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Does Deno need a screenshot package to call Screenshot API?

No. The raw REST integration uses Deno’s built-in fetch; no browser package is needed for this request path.

Does the Deno example capture a page in a local browser?

No. It asks the hosted API to capture the supplied URL. Deno makes the HTTP request; the API performs the screenshot capture.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.