ScreenshotNeo

BlogHow-to

How to capture a mobile viewport screenshot with Screenshotlayer

Capture a mobile-sized page with Screenshotlayer by setting its viewport and, when needed, a mobile User-Agent. See runnable examples, limits, and a ScreenshotNeo alternative.

By the ScreenshotNeo team4 October 20266 min read

To capture a mobile viewport screenshot with Screenshotlayer, call its capture endpoint with your access key, the page URL, and viewport=375x667 (or another width and height in CSS pixels). Add a mobile user_agent if the site serves different layouts based on User-Agent. Screenshotlayer’s published example uses 375×667 and an older iPhone 6 User-Agent; that example shows request shape, not a guarantee of current physical-device behavior. Screenshotlayer’s homepage

1. Build a mobile viewport request

The endpoint is https://api.screenshotlayer.com/api/capture. Each request requires the access key issued for your account. Keep it private: do not put a real key in public source code, browser-side JavaScript, shared examples, or logs.

https://api.screenshotlayer.com/api/capture?access_key=YOUR_ACCESS_KEY&url=https%3A%2F%2Fexample.com&viewport=375x667&user_agent=YOUR_MOBILE_USER_AGENT

Replace the placeholder URL with the exact page to capture. Encode query parameter values with your HTTP client rather than concatenating unescaped strings. The research material confirms the parameter names and example, but does not establish every current dimension limit or encoding edge case; check Screenshotlayer’s live documentation before relying on specific bounds.

2. Runnable examples

cURL

curl -G 'https://api.screenshotlayer.com/api/capture' \
  --data-urlencode 'access_key=YOUR_ACCESS_KEY' \
  --data-urlencode 'url=https://example.com' \
  --data-urlencode 'viewport=375x667' \
  --data-urlencode 'user_agent=YOUR_MOBILE_USER_AGENT' \
  --data-urlencode 'accept_lang=en-US' \
  -o screenshot.png

Use the mobile User-Agent string appropriate to your test. The provider’s example references an iPhone 6 string, but it is not a current device recommendation.

Python

import requests

endpoint = "https://api.screenshotlayer.com/api/capture"
params = {
    "access_key": "YOUR_ACCESS_KEY",
    "url": "https://example.com",
    "viewport": "375x667",
    "user_agent": "YOUR_MOBILE_USER_AGENT",
    "accept_lang": "en-US",
}

response = requests.get(endpoint, params=params, timeout=90)
response.raise_for_status()

content_type = response.headers.get("Content-Type", "")
if not content_type.startswith("image/"):
    raise RuntimeError(f"Expected an image response, got {content_type!r}: {response.text[:500]}")

with open("screenshot.png", "wb") as output:
    output.write(response.content)

Node.js

const endpoint = new URL('https://api.screenshotlayer.com/api/capture');
const params = {
  access_key: 'YOUR_ACCESS_KEY',
  url: 'https://example.com',
  viewport: '375x667',
  user_agent: 'YOUR_MOBILE_USER_AGENT',
  accept_lang: 'en-US',
};
for (const [key, value] of Object.entries(params)) {
  endpoint.searchParams.set(key, value);
}

const response = await fetch(endpoint);
if (!response.ok) {
  throw new Error(`Screenshotlayer returned HTTP ${response.status}: ${await response.text()}`);
}
const contentType = response.headers.get('content-type') || '';
if (!contentType.startsWith('image/')) {
  throw new Error(`Expected an image response, got ${contentType}`);
}
await import('node:fs/promises').then(fs => fs.writeFile('screenshot.png', Buffer.from(await response.arrayBuffer())));

For production code, also set an explicit request timeout using the HTTP library or runtime mechanism available in your Node.js version, and handle provider error responses according to the live API documentation.

3. Choose viewport, User-Agent, and language

Parameter How to use it What it does not guarantee
viewport Provide width and height such as 375x667, representing the requested browser viewport in CSS pixels. It does not establish a named-device preset, device pixel ratio, or exact physical-device rendering.
user_agent Set a mobile browser User-Agent when the site varies markup or behavior by User-Agent. Screenshotlayer’s FAQ confirms custom User-Agent support. A User-Agent alone does not prove the capture has all characteristics of that phone, such as its hardware or pixel density.
accept_lang Set a language preference when the page selects localized content; the provider’s example uses es-ES. It cannot force a translation the site does not provide or override every application-specific locale choice.

Choose dimensions that match the responsive breakpoint or scenario you are checking. A mobile-width viewport is useful for responsive layout checks, while a mobile User-Agent is relevant only when the site changes behavior based on that header. Do not treat the example’s 375×667 dimensions as universal.

4. Output format, delay, and caching

Screenshotlayer’s FAQ says PNG is the default and lists JPEG and GIF through the format parameter. Confirm the current accepted values in the provider’s documentation before changing formats. PNG is a practical default for sharp text and interface details; JPEG can be useful when smaller photographic output matters, subject to the provider’s supported behavior.

For pages that need time to render effects or content, the FAQ documents a delay parameter. Use a delay only when the page requires it; a longer wait increases capture latency. The FAQ states that the default cache period is 2,592,000 seconds (30 days), and that ttl can request a shorter period. A long cache can return an older capture after the page changes, so set a shorter TTL when freshness matters. Exact parameter bounds are not established by the available documentation excerpt.

5. Troubleshooting

Symptom Likely cause What to check
Authentication or access error The key is missing, invalid, or not authorized for the request. Confirm the issued key is present and belongs to the intended account. Keep it out of client-side code and rotate it if exposed.
Desktop layout appears in the image The site may select its layout from User-Agent, or the viewport may not cross its mobile breakpoint. Check the requested width and send a suitable mobile User-Agent if required. A User-Agent does not emulate every physical device feature.
Wrong language appears The page may ignore the language preference or select locale through cookies, URL, or account state. Set accept_lang and use a locale-specific URL where the site supports one.
Capture looks stale The cached screenshot may be reused; the documented default cache period is 30 days. Request a shorter ttl and confirm the accepted value in current docs.
Animation or delayed content is missing The capture may occur before the content appears. Try the documented delay parameter and use the shortest wait that produces the needed state.
Downloaded file is not a valid image The endpoint may have returned an error body or an unexpected content type that the script saved as an image. Inspect the HTTP status, response headers, and a small portion of the body before saving. Do not assume every successful transport response is an image.
Request fails for an unusually long URL Query-string length or escaping behavior may be involved; exact limits are not established in the available source material. Use the client’s parameter encoder and consult the live API reference for request limits.

6. Performance, reliability, and cost

Each capture requires a network request and a remote page render. Keep the requested viewport and output format to what the task needs, avoid unnecessary delay, and use caching when a fresh render is not required. For changing pages, a shorter TTL improves freshness at the expense of potentially more capture work.

Screenshotlayer’s FAQ says overage fees may apply after an account reaches its request allowance, while its terms say monthly limits depend on the subscription. The pricing page’s displayed plans and quotas can change. Check the current plan page and your account terms before estimating production cost; do not assume requests beyond a quota are always available or free. Screenshotlayer’s terms also make the account holder responsible for keeping credentials secret.

7. Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. One GET request can return a PNG, JPEG, WebP, or PDF; its API documentation covers the request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo removes cookie banners, popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are never billed. An 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 1,000 free screenshots a month, with no card.

FAQ

Does setting a mobile User-Agent make this an exact phone screenshot?

No. It sends a User-Agent value and requests a viewport size. The available source does not establish that this reproduces every physical-device feature or pixel behavior.

Is 375×667 the only mobile viewport?

No. It is the dimensions in Screenshotlayer’s published example. Select dimensions that fit the layout or breakpoint you need to inspect.

Can I use Screenshotlayer output commercially?

The homepage labels Free usage as non-commercial, and plan terms distinguish commercial use. Check the current plan and terms for the use you have in mind.

Where can I confirm current parameter limits and prices?

Use Screenshotlayer’s live API documentation and pricing page. The available research confirms example parameters, but not all current bounds or plan terms.