Web Scraping
Screenshot API
Screenshot API — capture any webpage as a PNG in headless Chrome. Viewport, full-page, or a single element by CSS selector, with custom window size. $0.02 per call.
Pricing, live playground and use cases: Screenshot API on YepAPI
POST
$0.02/call/v1/scrape/screenshotThe Screenshot API renders a page in headless Chrome and returns a PNG as base64. Capture the visible viewport, the full scrollable page with fullPage, or just one element — a chart, a pricing table, a tweet embed — with selector.
Usage
const res = await fetch('https://api.yepapi.com/v1/scrape/screenshot', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ url: 'https://example.com', width: 1440, height: 900 }),
});
const { data } = await res.json();
// data.image is a base64-encoded PNG
const img = Buffer.from(data.image, 'base64');curl -X POST https://api.yepapi.com/v1/scrape/screenshot \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "selector": "main h1"}'import base64, requests
res = requests.post(
"https://api.yepapi.com/v1/scrape/screenshot",
headers={"x-api-key": "YOUR_API_KEY"},
json={"url": "https://example.com", "fullPage": True},
)
with open("page.png", "wb") as f:
f.write(base64.b64decode(res.json()["data"]["image"]))Request Body
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
url | string | Yes | Full http(s) URL of the page (max 4096 characters) | — |
fullPage | boolean | No | Capture the entire scrollable page instead of the viewport | false |
selector | string | No | CSS selector — capture just this element. Overrides fullPage (max 500 characters) | — |
width | number | No | Browser window width in pixels, 100–4000 | 1920 |
height | number | No | Browser window height in pixels, 100–4000 | 1080 |
Response
{
"ok": true,
"data": {
"url": "https://example.com",
"image": "iVBORw0KGgoAAAANSUhEUgAA...(base64 PNG)",
"width": 1440,
"height": 900
}
}Response Fields
| Field | Type | Description |
|---|---|---|
ok | boolean | Whether the request succeeded |
data.url | string | The URL you sent |
data.image | string | Base64-encoded PNG |
data.width | number | Browser window width used (your width, or 1920) |
data.height | number | Browser window height used (your height, or 1080) |
Info
width and height describe the browser window, not the image. A fullPage or selector capture can be taller or smaller — read the PNG's own dimensions if you need them. Screenshots are never cached; every call captures the page fresh.
Errors
| Status | Code | When |
|---|---|---|
400 | VALIDATION_ERROR | url is missing or invalid; width / height is outside 100–4000; selector is too long or invalid; or the URL is a Google page |
404 | NOT_FOUND | The target page returned 404 Not Found |
429 | RATE_LIMITED_UPSTREAM | Too many requests in flight — retry in a few seconds |
502 | UPSTREAM_ERROR | The page could not be loaded or captured — retry |
503 | UPSTREAM_TIMEOUT | The page took too long to load — retry |
Failed calls are not charged.
Related Endpoints
- JavaScript Scrape API — the rendered page as Markdown or HTML, with browser scripting
- Web Scraping API — smart-mode scrape of any URL