ScreenshotNeo

BlogHow-to

How to Set the Screenshotlayer Screenshot Format to PNG or JPEG

Use Screenshotlayer’s format parameter to request PNG or JPEG. See the documented values, runnable examples, and what to verify before using JPEG.

By the ScreenshotNeo team4 October 20265 min read

Set Screenshotlayer’s format request parameter to png to explicitly request a PNG. Screenshotlayer’s official FAQ says PNG is the default and lists JPEG and GIF as supported formats. The FAQ does not establish whether the JPEG value must be jpg or jpeg, so verify that spelling in the current interactive documentation before using it in a production request. Screenshotlayer FAQ

Request format

Screenshotlayer’s capture endpoint is /api/capture. Requests include an access key and the URL to capture; include format as another query parameter:

https://api.screenshotlayer.com/api/capture?access_key=YOUR_ACCESS_KEY&url=https%3A%2F%2Fexample.com&format=png

Use your actual account’s documented endpoint and keep the access key private. The URL above illustrates the request shape, and the encoded target URL avoids ambiguity when it contains query parameters or other reserved characters.

Request a PNG

PNG is the documented default, so omitting format is described as producing PNG. Setting format=png makes the intent explicit and easier to spot in application code.

cURL

curl -G "https://api.screenshotlayer.com/api/capture" \\
  --data-urlencode "access_key=YOUR_ACCESS_KEY" \\
  --data-urlencode "url=https://example.com" \\
  --data-urlencode "format=png" \\
  -o screenshot.png

Python

import requests

response = requests.get(
    "https://api.screenshotlayer.com/api/capture",
    params={
        "access_key": "YOUR_ACCESS_KEY",
        "url": "https://example.com",
        "format": "png",
    },
    timeout=90,
)
response.raise_for_status()
with open("screenshot.png", "wb") as screenshot:
    screenshot.write(response.content)

Node.js

const params = new URLSearchParams({
  access_key: process.env.SCREENSHOTLAYER_ACCESS_KEY,
  url: 'https://example.com',
  format: 'png',
});

const response = await fetch(
  `https://api.screenshotlayer.com/api/capture?${params}`
);
if (!response.ok) {
  throw new Error(`Screenshotlayer request failed: ${response.status}`);
}
const image = Buffer.from(await response.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('screenshot.png', image));

Request a JPEG

The official FAQ confirms JPEG as an available output format, but the retrieved FAQ text does not say whether to send format=jpg or format=jpeg. Do not assume one spelling based on the filename extension: check Screenshotlayer’s live API documentation for the accepted parameter value, then use that exact value in the same request shape. Save the response with a matching .jpg or .jpeg extension once the output format is confirmed.

For example, after confirming the accepted token, replace png in the examples above with that token and change the output filename to screenshot.jpg. The endpoint, access key, target URL, and binary response handling stay the same.

Choosing PNG, JPEG, or the default

Choice What the available Screenshotlayer source establishes Practical action
PNG PNG is supported and is the default. Omit format or set format=png.
JPEG JPEG is supported, but the retrieved FAQ does not establish the exact enum spelling. Check the current interactive API docs for jpg versus jpeg.
GIF The FAQ also lists GIF. Use only if it fits your use case and the current API docs confirm the accepted value.

The source does not compare Screenshotlayer’s formats for file size, transparency, or image quality. Those tradeoffs depend on the image content and encoding choices; treat them as general image-format considerations rather than a documented Screenshotlayer guarantee.

Implementation details and edge cases

  • URL encoding: Pass query parameters through a URL builder or a client library’s params option. This safely handles nested target URLs.
  • Binary response: Write response bytes to disk. Do not decode an image response as UTF-8 text.
  • Filename and content: Keep the extension aligned with the format you requested and confirm the response is an image before passing it to downstream image processing.
  • Credentials: Use an environment variable or secret manager for the access key. Avoid committing it to source control or exposing it in browser-side code.
  • Omitted format: The FAQ identifies PNG as the default. Explicitly pass the format when reproducible configuration is more important than relying on a default.

Troubleshooting

Symptom Likely cause What to do
The request rejects the format value The JPEG token may be spelled differently than assumed, or the parameter value is unsupported. Check the live interactive documentation for the accepted exact value. PNG is documented as png.
The saved file is not a usable image The response may contain an API error rather than image bytes. Check the HTTP status and inspect the response content type or error body before saving or decoding it.
The target URL is malformed Nested query characters were not encoded correctly. Use curl --data-urlencode, Python’s params, or Node’s URLSearchParams.
The access key appears in logs or a public client The key was placed in a URL that is exposed to users or recorded by infrastructure. Keep requests server-side where possible, store the key as a secret, and rotate it if exposed.
The output extension and actual format disagree The filename was changed without changing the request format, or the API returned an error payload. Match the filename to the verified format and validate the response before storing it.

Performance, reliability, and cost

Use a reasonable request timeout and handle non-success responses before writing output. If your application captures many URLs, account for request latency and your Screenshotlayer plan’s limits; the cited FAQ does not specify performance benchmarks, retry guarantees, or pricing, so check the provider’s current account documentation for those details. Retry transient network failures with a bounded policy, and avoid blindly retrying invalid parameters or authentication errors.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server for developers. One GET request can return PNG, JPEG, WebP, or PDF, with options for full-page capture, element screenshots, viewport and device presets, custom CSS and JavaScript, waits, and more. See the ScreenshotNeo API documentation.

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

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot. Bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Sign up for ScreenshotNeo’s free 1,000 screenshots per month.

FAQ

What is Screenshotlayer’s format parameter?

It is the format request parameter used to choose the screenshot output format.

Does Screenshotlayer return PNG when I omit the parameter?

Its official FAQ identifies PNG as the default.

Is Screenshotlayer JPEG spelled jpg or jpeg?

The retrieved FAQ confirms JPEG support but does not specify the literal value. Verify it in the current interactive API documentation before relying on a copy-paste request.

Does Screenshotlayer support GIF?

Yes. The official FAQ lists GIF alongside PNG and JPEG.